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-2375: Implement a new rule for checking audit logging is enabled #11731

Merged

Conversation

rhmdnd
Copy link
Collaborator

@rhmdnd rhmdnd commented Mar 19, 2024

We already have a rule that checks that audit logging is configured to a
specific level called audit_profile_set. While this works, it was being
used for CIS OpenShift controls 3.2.1 and 3.2.2.

CIS 3.2.1 is really just checking if audit logging is enabled, or that
the profile isn't set to None.

CIS 3.2.2 is checking that the audit profile is set to
WriteRequestBodies.

Using the same rule for both controls was causing confusion because
control 3.2.1 should be satisfied by default with OpenShift using the
Default audit profile. Control 3.2.2 is a level 2 control that
requires users to make a change to the api server configuration to
remediate the finding.

This commit breaks the rule into two separate rules so that its easier
to see that one rule is clearly for CIS 3.2.1 and the other is for CIS
3.2.2.

We already have a rule that checks that audit logging is configured to a
specific level called audit_profile_set. While this works, it was being
used for CIS OpenShift controls 3.2.1 and 3.2.2.

CIS 3.2.1 is really just checking if audit logging is enabled, or that
the profile isn't set to `None`.

CIS 3.2.2 is checking that the audit profile is set to
`WriteRequestBodies`.

Using the same rule for both controls was causing confusion because
control 3.2.1 should be satisfied by default with OpenShift using the
`Default` audit profile. Control 3.2.2 is a level 2 control that
requires users to make a change to the api server configuration to
remediate the finding.

This commit breaks the rule into two separate rules so that its easier
to see that one rule is clearly for CIS 3.2.1 and the other is for CIS
3.2.2.
@rhmdnd rhmdnd added OpenShift OpenShift product related. CIS CIS Benchmark related. labels Mar 19, 2024
Copy link

Start a new ephemeral environment with changes proposed in this pull request:

rhel8 (from CTF) Environment (using Fedora as testing environment)
Open in Gitpod

Fedora Testing Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@rhmdnd
Copy link
Collaborator Author

rhmdnd commented Mar 19, 2024

/test

Copy link

openshift-ci bot commented Mar 19, 2024

@rhmdnd: The /test command needs one or more targets.
The following commands are available to trigger required jobs:

  • /test 4.13-e2e-aws-ocp4-cis
  • /test 4.13-e2e-aws-ocp4-cis-node
  • /test 4.13-e2e-aws-ocp4-e8
  • /test 4.13-e2e-aws-ocp4-high
  • /test 4.13-e2e-aws-ocp4-high-node
  • /test 4.13-e2e-aws-ocp4-moderate
  • /test 4.13-e2e-aws-ocp4-moderate-node
  • /test 4.13-e2e-aws-ocp4-pci-dss
  • /test 4.13-e2e-aws-ocp4-pci-dss-node
  • /test 4.13-e2e-aws-ocp4-stig
  • /test 4.13-e2e-aws-ocp4-stig-node
  • /test 4.13-e2e-aws-rhcos4-e8
  • /test 4.13-e2e-aws-rhcos4-high
  • /test 4.13-e2e-aws-rhcos4-moderate
  • /test 4.13-e2e-aws-rhcos4-stig
  • /test 4.13-images
  • /test 4.14-images
  • /test 4.15-e2e-aws-ocp4-cis
  • /test 4.15-e2e-aws-ocp4-cis-node
  • /test 4.15-e2e-aws-ocp4-e8
  • /test 4.15-e2e-aws-ocp4-high
  • /test 4.15-e2e-aws-ocp4-high-node
  • /test 4.15-e2e-aws-ocp4-moderate
  • /test 4.15-e2e-aws-ocp4-moderate-node
  • /test 4.15-e2e-aws-ocp4-pci-dss
  • /test 4.15-e2e-aws-ocp4-pci-dss-node
  • /test 4.15-e2e-aws-ocp4-stig
  • /test 4.15-e2e-aws-ocp4-stig-node
  • /test 4.15-e2e-aws-rhcos4-e8
  • /test 4.15-e2e-aws-rhcos4-high
  • /test 4.15-e2e-aws-rhcos4-moderate
  • /test 4.15-e2e-aws-rhcos4-stig
  • /test 4.15-images
  • /test 4.16-e2e-aws-ocp4-cis
  • /test 4.16-e2e-aws-ocp4-cis-node
  • /test 4.16-e2e-aws-ocp4-e8
  • /test 4.16-e2e-aws-ocp4-high
  • /test 4.16-e2e-aws-ocp4-high-node
  • /test 4.16-e2e-aws-ocp4-moderate
  • /test 4.16-e2e-aws-ocp4-moderate-node
  • /test 4.16-e2e-aws-ocp4-pci-dss
  • /test 4.16-e2e-aws-ocp4-pci-dss-node
  • /test 4.16-e2e-aws-ocp4-stig
  • /test 4.16-e2e-aws-ocp4-stig-node
  • /test 4.16-e2e-aws-rhcos4-e8
  • /test 4.16-e2e-aws-rhcos4-high
  • /test 4.16-e2e-aws-rhcos4-moderate
  • /test 4.16-e2e-aws-rhcos4-stig
  • /test 4.16-images
  • /test e2e-aws-ocp4-cis
  • /test e2e-aws-ocp4-cis-node
  • /test e2e-aws-ocp4-e8
  • /test e2e-aws-ocp4-high
  • /test e2e-aws-ocp4-high-node
  • /test e2e-aws-ocp4-moderate
  • /test e2e-aws-ocp4-moderate-node
  • /test e2e-aws-ocp4-pci-dss
  • /test e2e-aws-ocp4-pci-dss-node
  • /test e2e-aws-ocp4-stig
  • /test e2e-aws-ocp4-stig-node
  • /test e2e-aws-rhcos4-e8
  • /test e2e-aws-rhcos4-high
  • /test e2e-aws-rhcos4-moderate
  • /test e2e-aws-rhcos4-stig
  • /test images

Use /test all to run the following jobs that were automatically triggered:

  • pull-ci-ComplianceAsCode-content-master-4.13-images
  • pull-ci-ComplianceAsCode-content-master-4.14-images
  • pull-ci-ComplianceAsCode-content-master-4.15-images
  • pull-ci-ComplianceAsCode-content-master-4.16-images
  • pull-ci-ComplianceAsCode-content-master-images

In response to this:

/test

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.

@rhmdnd
Copy link
Collaborator Author

rhmdnd commented Mar 19, 2024

/test 4.13-e2e-aws-ocp4-cis
/test 4.15-e2e-aws-ocp4-cis
/test 4.16-e2e-aws-ocp4-cis
/test e2e-aws-ocp4-cis

Copy link

🤖 A k8s content image for this PR is available at:
ghcr.io/complianceascode/k8scontent:11731
This image was built from commit: fca4310

Click here to see how to deploy it

If you alread have Compliance Operator deployed:
utils/build_ds_container.py -i ghcr.io/complianceascode/k8scontent:11731

Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and:
CONTENT_IMAGE=ghcr.io/complianceascode/k8scontent:11731 make deploy-local

Copy link

codeclimate bot commented Mar 19, 2024

Code Climate has analyzed commit fca4310 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 59.3% (0.0% change).

View more on Code Climate.

@xiaojiey
Copy link
Collaborator

/hold for test

@openshift-ci openshift-ci bot added the do-not-merge/hold Used by openshift-ci-robot bot. label Mar 20, 2024
@xiaojiey
Copy link
Collaborator

Verification pass.

% oc get clusterversion
NAME      VERSION                              AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.16.0-0.nightly-2024-03-13-061822   True        False         56m     Cluster version is 4.16.0-0.nightly-2024-03-13-061822
% cat ssb_cis.yaml 
apiVersion: compliance.openshift.io/v1alpha1
kind: ScanSettingBinding
metadata:
  name: cis-compliance
  namespace: openshift-compliance
profiles:
  - name: upstream-ocp4-cis
    kind: Profile
    apiGroup: compliance.openshift.io/v1alpha1
settingsRef:
  name: default
  kind: ScanSetting
  apiGroup: compliance.openshift.io/v1alpha1

% oc apply -f ssb_cis.yaml
scansettingbinding.compliance.openshift.io/cis-compliance created
% oc get suite
NAME             PHASE   RESULT
cis-compliance   DONE    NON-COMPLIANT
% oc get ccr upstream-ocp4-cis-audit-logging-enabled
upstream-ocp4-cis-audit-logging-enabled                                    PASS     medium
% oc get ccr upstream-ocp4-cis-audit-logging-enabled  -o=jsonpath={.instructions}
Run the following command to retrieve the current audit profile:
$ oc get apiservers cluster -ojsonpath='{.spec.audit.profile}'
Make sure the value is not set to `None`.%
% oc get ccr upstream-ocp4-cis-audit-profile-set 
NAME                                  STATUS   SEVERITY
upstream-ocp4-cis-audit-profile-set   FAIL     medium
% oc get ccr upstream-ocp4-cis-audit-profile-set -o=jsonpath={.instructions}
Run the following command to retrieve the current audit profile:
$ oc get apiservers cluster -ojsonpath='{.spec.audit.profile}'
Make sure the profile returned matches the one that should be used.%                                                                        
% oc get apiservers cluster -ojsonpath='{.spec.audit.profile}'              
Default%

@xiaojiey
Copy link
Collaborator

/unhold
/lgtm

@openshift-ci openshift-ci bot removed the do-not-merge/hold Used by openshift-ci-robot bot. label Mar 20, 2024
Copy link
Contributor

@Vincent056 Vincent056 left a comment

Choose a reason for hiding this comment

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

/lgtm
Thanks for adding this rule

@GroceryBoyJr
Copy link

/lgtm

@rhmdnd rhmdnd merged commit faa019d into ComplianceAsCode:master Mar 26, 2024
44 of 48 checks passed
@Mab879 Mab879 added this to the 0.1.73 milestone Mar 26, 2024
@Mab879 Mab879 added the New Rule Issues or pull requests related to new Rules. label Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CIS CIS Benchmark related. New Rule Issues or pull requests related to new Rules. OpenShift OpenShift product related.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants