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

Remove kubernetes hardcoded solution for templated service_debug rules #11370

Merged
merged 3 commits into from
Mar 26, 2024

Conversation

CoreyCook8
Copy link
Contributor

@CoreyCook8 CoreyCook8 commented Dec 11, 2023

Description:

service_debug-shell_disabled and service_autofs_disabled have hardcoded remediations for the Kubernetes lang but templates exist for these rules.

Also, updates the jinja macro to reflect masking the service/socket.

Prior to this change there are two different fixes created for ignition and kubernetes

<xccdf-1.2:fix system="urn:xccdf:fix:script:kubernetes" id="service_autofs_disabled">---
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
spec:
  config:
    ignition:
      version: 3.1.0
    systemd:
      units:
      - enabled: false
        name: autofs.service
</xccdf-1.2:fix>
<xccdf-1.2:fix system="urn:xccdf:fix:script:ignition" id="service_autofs_disabled" complexity="low" disruption="medium" reboot="true" strategy="disable">apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
spec:
  config:
    ignition:
      version: 3.1.0
    systemd:
      units:
      - name: autofs.service
        enabled: false
        mask: true
      - name: autofs.socket
        enabled: false
        mask: true
</xccdf-1.2:fix>

After this change, the kubernetes lang takes the templated version and the two fixes are identical.

<xccdf-1.2:fix system="urn:xccdf:fix:script:kubernetes" id="service_autofs_disabled" complexity="low" disruption="medium" reboot="true" strategy="disable">apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
spec:
  config:
    ignition:
      version: 3.1.0
    systemd:
      units:
      - name: autofs.service
        enabled: false
        mask: true
      - name: autofs.socket
        enabled: false
        mask: true
</xccdf-1.2:fix>
<xccdf-1.2:fix system="urn:xccdf:fix:script:ignition" id="service_autofs_disabled" complexity="low" disruption="medium" reboot="true" strategy="disable">apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
spec:
  config:
    ignition:
      version: 3.1.0
    systemd:
      units:
      - name: autofs.service
        enabled: false
        mask: true
      - name: autofs.socket
        enabled: false
        mask: true
</xccdf-1.2:fix>

Rationale:

There is no need to create hardcoded remediation files for these since the template files exist.

Also, when using the OpenShift Compliance Operator, the fix used for this depends on the ordering of these fixes. In my case, the kubernetes fix was before the ignition fix in the list. This caused the compliance operator to apply the kubernetes fix which failed to mask the service.

If the rule is going to check for the services to be masked, then all of the available remediations should mask the service.

Copy link

openshift-ci bot commented Dec 11, 2023

Hi @CoreyCook8. Thanks for your PR.

I'm waiting for a ComplianceAsCode member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@openshift-ci openshift-ci bot added the needs-ok-to-test Used by openshift-ci bot. label Dec 11, 2023
Copy link

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

Fedora Environment
Open in Gitpod

Oracle Linux 8 Environment
Open in Gitpod

@marcusburghardt marcusburghardt added the Kubernetes Kubernetes remediation update. label Dec 12, 2023
@CoreyCook8
Copy link
Contributor Author

CoreyCook8 commented Jan 2, 2024

👋 Could I get some eyes on here when someone has a chance? 🙏

@CoreyCook8
Copy link
Contributor Author

Hey @rhmdnd could I get some 👀 on this one when you have a chance please? 🙏

@rhmdnd rhmdnd added the ok-to-test Used by openshift-ci bot. label Feb 5, 2024
@rhmdnd
Copy link
Collaborator

rhmdnd commented Feb 5, 2024

/test

@openshift-ci openshift-ci bot removed the needs-ok-to-test Used by openshift-ci bot. label Feb 5, 2024
Copy link

openshift-ci bot commented Feb 5, 2024

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

  • /test 4.13-images
  • /test 4.14-images
  • /test 4.15-images
  • /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

rhmdnd commented Feb 5, 2024

/test e2e-aws-rhcos4-high

@rhmdnd
Copy link
Collaborator

rhmdnd commented Feb 5, 2024

Thanks for the patch @CoreyCook8.

Testing this rule against a dev cluster and I noticed the default result changed since 1ce0c75 landed.

Running e2e tests to see what the outcome is of this patch with those changes.

@rhmdnd
Copy link
Collaborator

rhmdnd commented Feb 6, 2024

Based on the e2e results - this appears to be failing because the autofs package isn't installed.

#11546 should fix the e2e issues, but we might need to validate a different way to make sure the remediation still works (installing autofs manually).

Copy link

openshift-ci bot commented Feb 6, 2024

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

  • /test 4.13-images
  • /test 4.14-images
  • /test 4.15-images
  • /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.

@CoreyCook8
Copy link
Contributor Author

/retest

@rhmdnd
Copy link
Collaborator

rhmdnd commented Feb 12, 2024

/test

Copy link

openshift-ci bot commented Feb 12, 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

rhmdnd commented Feb 12, 2024

/test 4.15-e2e-aws-rhcos4-high

1 similar comment
@CoreyCook8
Copy link
Contributor Author

/test 4.15-e2e-aws-rhcos4-high

@CoreyCook8
Copy link
Contributor Author

/test e2e-aws-rhcos4-high

@CoreyCook8
Copy link
Contributor Author

Hey @rhmdnd looks like we are passing the tests now

@rhmdnd
Copy link
Collaborator

rhmdnd commented Mar 6, 2024

@CoreyCook8 looks like some of the build tests are hung up. @Mab879 should we just rekick these?

@CoreyCook8
Copy link
Contributor Author

Any way I can help rekick those?

@Mab879
Copy link
Member

Mab879 commented Mar 11, 2024

@CoreyCook8 looks like some of the build tests are hung up. @Mab879 should we just rekick these?

Sorry, I just saw this. First time contributors need approval for the CI to run. I just gave the approval.

@rhmdnd you should be able to do this as well.

Copy link

github-actions bot commented Mar 11, 2024

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

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:11370

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

@CoreyCook8
Copy link
Contributor Author

@rhmdnd looks good to go?

@yuumasato yuumasato self-assigned this Mar 15, 2024
@yuumasato
Copy link
Member

@CoreyCook8 Hi, sorry for the delay, the changes look good to me.

But could you please remove the merge commits? One way to do it is to:

$ git rebase --onto master 49de0664014309054881de12e2b73993951849ce~1 a710b6f5fbfa6ad22145c283505d2ec5148c1238
$ git checkout -B patch-1 HEAD

@CoreyCook8
Copy link
Contributor Author

👋 @yuumasato Look alright now?

@yuumasato
Copy link
Member

/test e2e-aws-rhcos4-high

Copy link

codeclimate bot commented Mar 21, 2024

Code Climate has analyzed commit 2ebd379 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.

@yuumasato yuumasato added this to the 0.1.73 milestone Mar 26, 2024
@yuumasato yuumasato merged commit 5d2b664 into ComplianceAsCode:master Mar 26, 2024
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Kubernetes Kubernetes remediation update. ok-to-test Used by openshift-ci bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants