Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMP-2401: Add STIG reference parser #494

Merged
merged 1 commit into from
Apr 8, 2024

Conversation

yuumasato
Copy link
Member

This ensures that rules part of STIG profile contain annotations with the STIGID.

One can see the STIG references as annotation on the rule when deployed together with content from ComplianceAsCode/content#11593

$ CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:11593 make deploy-local
$ oc get rule  ocp4-api-server-tls-security-profile -oyaml
...
metadata:
  annotations:
    compliance.openshift.io/image-digest: pb-ocp4vkwnn
    compliance.openshift.io/profiles: ocp4-moderate-rev-4,ocp4-stig,ocp4-high-rev-4,ocp4-stig-v1r1,ocp4-moderate,ocp4-high,ocp4-nerc-cip
    compliance.openshift.io/rule: api-server-tls-security-profile
    control.compliance.openshift.io/NIST-800-53: SC-8;SC-8(1)
    control.compliance.openshift.io/STIG: CNTR-OS-000020
    policies.open-cluster-management.io/controls: SC-8,SC-8(1),CNTR-OS-000020
    policies.open-cluster-management.io/standards: NIST-800-53,STIG
...

@yuumasato yuumasato changed the title Add SITG reference parser Add STIG reference parser Feb 27, 2024
@xiaojiey
Copy link
Collaborator

/hold for test

@xiaojiey
Copy link
Collaborator

@yuumasato It is weird. I noticed there is stig annotation for stig in the master branch without the PR:

$ oc get clusterversion
NAME      VERSION                              AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.16.0-0.nightly-2024-02-26-013420   True        False         11h     Cluster version is 4.16.0-0.nightly-2024-02-26-013420

$ oc get rule  ocp4-api-server-tls-security-profile -o=jsonpath={.metadata.annotations} | jq -r
{
  "compliance.openshift.io/image-digest": "pb-ocp4qrc9k",
  "compliance.openshift.io/profiles": "ocp4-nerc-cip,ocp4-high-rev-4,ocp4-stig-v1r1,ocp4-moderate,ocp4-stig,ocp4-moderate-rev-4,ocp4-high",
  "compliance.openshift.io/rule": "api-server-tls-security-profile",
  "control.compliance.openshift.io/NIST-800-53": "SC-8;SC-8(1)",
  "policies.open-cluster-management.io/controls": "SC-8,SC-8(1)",
  "policies.open-cluster-management.io/standards": "NIST-800-53"
}

@yuumasato
Copy link
Member Author

yuumasato commented Feb 29, 2024

"compliance.openshift.io/profiles": "ocp4-nerc-cip,ocp4-high-rev-4,ocp4-stig-v1r1,ocp4-moderate,ocp4-stig,ocp4-moderate-rev-4,ocp4-high",

@xiaojiey The compliance.openshift.io/profiles annotation was added in #398, and it lists the profiles in which a rule is selected.

This PR adds the following annotations listing more specific information about the STIG requirement implemented:
control.compliance.openshift.io/STIG: CNTR-OS-000020

And extends the policies.open-cluster-management.io/controls and policies.open-cluster-management.io/standards with STIG specific data:

    policies.open-cluster-management.io/controls: SC-8,SC-8(1),CNTR-OS-000020
    policies.open-cluster-management.io/standards: NIST-800-53,STIG

vs

  "policies.open-cluster-management.io/controls": "SC-8,SC-8(1)",
  "policies.open-cluster-management.io/standards": "NIST-800-53"

@xiaojiey
Copy link
Collaborator

xiaojiey commented Mar 1, 2024

Verification pass with 4.16.0-0.nightly-2024-02-29-062601:


$ utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:11593
2024-03-01 15:36:10,750:INFO: Created profile bundles for ocp4, rhcos4

$ oc get rule  ocp4-api-server-tls-security-profile -o=jsonpath={.metadata.annotations} | jq -r
{
  "compliance.openshift.io/image-digest": "pb-ocp44m6tp",
  "compliance.openshift.io/profiles": "ocp4-high,ocp4-stig,ocp4-moderate,ocp4-high-rev-4,ocp4-moderate-rev-4,ocp4-stig-v1r1,ocp4-nerc-cip",
  "compliance.openshift.io/rule": "api-server-tls-security-profile",
  "control.compliance.openshift.io/NIST-800-53": "SC-8;SC-8(1)",
  "policies.open-cluster-management.io/controls": "SC-8,SC-8(1)",
  "policies.open-cluster-management.io/standards": "NIST-800-53"
}
$ oc get rule  upstream-ocp4-api-server-tls-security-profile -o=jsonpath={.metadata.annotations} | jq -r
{
  "compliance.openshift.io/image-digest": "pb-upstream-ocp46k8b6",
  "compliance.openshift.io/profiles": "upstream-ocp4-high,upstream-ocp4-stig-v1r1,upstream-ocp4-stig,upstream-ocp4-moderate-rev-4,upstream-ocp4-moderate,upstream-ocp4-nerc-cip,upstream-ocp4-high-rev-4",
  "compliance.openshift.io/rule": "api-server-tls-security-profile",
  "control.compliance.openshift.io/NIST-800-53": "SC-8;SC-8(1)",
  "control.compliance.openshift.io/STIG": "CNTR-OS-000020",
  "policies.open-cluster-management.io/controls": "SC-8,SC-8(1),CNTR-OS-000020",
  "policies.open-cluster-management.io/standards": "NIST-800-53,STIG"
}

@xiaojiey
Copy link
Collaborator

xiaojiey commented Mar 1, 2024

/unhold

@yuumasato yuumasato changed the title Add STIG reference parser CMP-2401: Add STIG reference parser Mar 1, 2024
@openshift-ci-robot
Copy link
Collaborator

@yuumasato: This pull request references CMP-2401 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.16.0" version, but no target version was set.

In response to this:

This ensures that rules part of STIG profile contain annotations with the STIGID.

One can see the STIG references as annotation on the rule when deployed together with content from ComplianceAsCode/content#11593

$ CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:11593 make deploy-local
$ oc get rule  ocp4-api-server-tls-security-profile -oyaml
...
metadata:
 annotations:
   compliance.openshift.io/image-digest: pb-ocp4vkwnn
   compliance.openshift.io/profiles: ocp4-moderate-rev-4,ocp4-stig,ocp4-high-rev-4,ocp4-stig-v1r1,ocp4-moderate,ocp4-high,ocp4-nerc-cip
   compliance.openshift.io/rule: api-server-tls-security-profile
   control.compliance.openshift.io/NIST-800-53: SC-8;SC-8(1)
   control.compliance.openshift.io/STIG: CNTR-OS-000020
   policies.open-cluster-management.io/controls: SC-8,SC-8(1),CNTR-OS-000020
   policies.open-cluster-management.io/standards: NIST-800-53,STIG
...

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@yuumasato
Copy link
Member Author

@Vincent056 @rhmdnd This should be ready for review

@yuumasato
Copy link
Member Author

@rhmdnd @Vincent056 I have added a parser for SRGs.

When content from ComplianceAsCode/content#11647 is deployed, we can see the following annotations:

oc get rule  ocp4-api-server-tls-security-profile -o=jsonpath={.metadata.annotations} | jq -r
{
  "compliance.openshift.io/image-digest": "pb-ocp4j6dgh",
  "compliance.openshift.io/profiles": "ocp4-moderate-rev-4,ocp4-stig-v1r1,ocp4-high-rev-4,ocp4-high,ocp4-nerc-cip,ocp4-moderate,ocp4-stig",
  "compliance.openshift.io/rule": "api-server-tls-security-profile",
  "control.compliance.openshift.io/NIST-800-53": "SC-8;SC-8(1)",
  "control.compliance.openshift.io/SRG-APP-CTR": "SRG-APP-000014-CTR-000040;SRG-APP-000560-CTR-001340",
  "policies.open-cluster-management.io/controls": "SC-8,SC-8(1),SRG-APP-000014-CTR-000040,SRG-APP-000560-CTR-001340",
  "policies.open-cluster-management.io/standards": "NIST-800-53,SRG-APP-CTR"
}

Do you have any opinion on the control name SRG-APP-CTR?

@xiaojiey
Copy link
Collaborator

xiaojiey commented Mar 5, 2024

/hold for test

@xiaojiey
Copy link
Collaborator

xiaojiey commented Mar 5, 2024

Got the same result with comment #494 (comment) when content from ComplianceAsCode/content#11647 deployed

@xiaojiey
Copy link
Collaborator

xiaojiey commented Mar 5, 2024

/unhold

@xiaojiey
Copy link
Collaborator

xiaojiey commented Mar 5, 2024

/label qe-approved

}
srgperr := p.registerStandard("SRG-APP-CTR",`^https://public\.cyber\.mil/stigs/downloads/\?_dl_facet_stigs=container-platform$`)
if srgperr != nil {
log.Error(nciperr, "Could not register SRG-APP-CTR reference parser") // not much we can do here..
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could see where someone reading the logs might get confused by what this means compared to STIG one above.

If they're both related to the STIG, could we use the same error message?

Copy link
Member Author

@yuumasato yuumasato Mar 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my, you are totally correct.
Both the STIG ID CNTR-OS-XXXXXX and container SRG SRG-APP-XXXXXX-CTR-XXXXXX are found at https://public.cyber.mil/stigs/downloads/?_dl_facet_stigs=container-platform

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With same URI for both the STIGIDs and SRGs, the references will be listed together under the same name STIG :

$oc get rule  ocp4-api-server-tls-security-profile -o=jsonpath={.metadata.annotations} | jq -r
{
  "compliance.openshift.io/image-digest": "pb-ocp4jm9bc",
  "compliance.openshift.io/profiles": "ocp4-nerc-cip,ocp4-moderate-rev-4,ocp4-high-rev-4,ocp4-high,ocp4-moderate,ocp4-stig-v1r1,ocp4-stig",
  "compliance.openshift.io/rule": "api-server-tls-security-profile",
  "control.compliance.openshift.io/NIST-800-53": "SC-8;SC-8(1)",
  "control.compliance.openshift.io/STIG": "SRG-APP-000014-CTR-000040;SRG-APP-000560-CTR-001340;CNTR-OS-000020",
  "policies.open-cluster-management.io/controls": "SC-8,SC-8(1),SRG-APP-000014-CTR-000040,SRG-APP-000560-CTR-001340,CNTR-OS-000020",
  "policies.open-cluster-management.io/standards": "NIST-800-53,STIG"
}

"control.compliance.openshift.io/STIG": "SRG-APP-000014-CTR-000040;SRG-APP-000560-CTR-001340;CNTR-OS-000020",

@rhmdnd
Copy link

rhmdnd commented Mar 6, 2024

Do you have any opinion on the control name SRG-APP-CTR?

This should align with the cells in the STIG spreadsheets, right?

This ensures that rules part of STIG profile contain annotations with
the STIGID.
@yuumasato
Copy link
Member Author

Do you have any opinion on the control name SRG-APP-CTR?

This should align with the cells in the STIG spreadsheets, right?

Yes, but not necessarily.
The SRGs in each rule should match the ones in the spreadsheet, unless there were changes or bugs during generation of the spreadsheeet, and/or changes that DISA did from the spreadsheeet to the published xml.

@yuumasato
Copy link
Member Author

@Vincent056 should be ready for review

GroceryBoyJr

This comment was marked as duplicate.

Copy link
Collaborator

@GroceryBoyJr GroceryBoyJr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link

openshift-ci bot commented Apr 8, 2024

@GroceryBoyJr: changing LGTM is restricted to collaborators

In response to this:

lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

openshift-ci bot commented Apr 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GroceryBoyJr, rhmdnd, yuumasato

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@rhmdnd rhmdnd merged commit 015d0c8 into ComplianceAsCode:master Apr 8, 2024
19 of 24 checks passed
@yuumasato yuumasato deleted the parse_stig_references branch April 9, 2024 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants