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

Add rule type change detection in profile parse #401

Merged
merged 12 commits into from
Dec 1, 2023

Conversation

Vincent056
Copy link

@Vincent056 Vincent056 commented Sep 5, 2023

We went through migration cases for the new KubeletConfig changes. We decided to handle the TailoredProfile migration on the operator instead.

This fixes future rule checkType change migration issues as well as rule/variables deprecation issues.

To spot deprecated variables and rules, we'll use annotations derived from the content:

  • Variable/Rule deprecation: compliance.openshift.io/deprecated

During the profileParser upgrade, we'll detect rule TypeChanges by comparing existing rule types against the new updates. If there's a change, the annotation compliance.openshift.io/rule-last-check-type will be added to the rule.

We will issues event and show warning in the TailoredProfile Status, if there are any deprecated or migrated rules/variables in the TailoredProfile, and user can also choose to set following annotation on the tailoredProfile: compliance.openshift.io/prune-outdated-references, so that the tailoredProfile controller will removal of all deprecated rules and variables along with migrated rules references from that specific tailoredProfile object.

To bypass migration and deprecation validation on specific TailoredProfile object, add the tag: compliance.openshift.io/disable-outdated-reference-validation.

Testing Profiles:

  • Initial Setup:
    • Install CO prior to the release of the KubeletConfig patch.
    • Wait for all the profile bundles to reach a 'ready' state.
  • Deploying TailoredProfile (TP):
    • Deploy the TP. This should lead to an 'all ready' state for TP.
  • Modifying ProfileBundle Deployment:
    • Remove the profile bundle deployment. Important: Ensure that the profile bundle object remains intact and isn't deleted.
  • Re-deploying CO with the Patch:
    • Make sure the operator pod has restarted and ProfileBundle deployment is being created
  • Validation:
    • Verify that the TP displays the appropriate states.

Check comment for testing profiles

@openshift-ci openshift-ci bot requested review from mrogers950 and rhmdnd September 5, 2023 07:55
@openshift-ci openshift-ci bot added the approved label Sep 5, 2023
@Vincent056 Vincent056 force-pushed the type_change branch 2 times, most recently from 7cb8d66 to dcd2c5d Compare September 12, 2023 02:18
@Vincent056
Copy link
Author

Vincent056 commented Sep 12, 2023

Testing profiles

---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-noextend-disableonly-rules
  namespace: openshift-compliance
spec:
  description: Test
  disableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-noextend-enableonly-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-noextend-disablemix-rules
  namespace: openshift-compliance
spec:
  description: Test
  disableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-noextend-disablemix-enableonly-rules
  namespace: openshift-compliance
spec:
  description: Test
  disableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  enableRules:
  - name: ocp4-kubelet-enable-streaming-connections
    rationale: test
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-noextend-enablemix-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-noextend-enablemix-disableonly-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  disableRules:
  - name: ocp4-kubelet-enable-streaming-connections
    rationale: test
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-noextend-enablemix-disablemix-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  disableRules:
  - name: ocp4-kubelet-enable-streaming-connections
    rationale: test
  - name: ocp4-kubelet-enable-server-cert-rotation
    rationale: test
  - name: ocp4-idp-is-configured
    rationale: test
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-noextend-disablemixmany-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-kubelet-enable-streaming-connections
    rationale: test
  - name: ocp4-kubelet-enable-server-cert-rotation
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  - name: ocp4-idp-is-configured
    rationale: test
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-disableonly-rules
  namespace: openshift-compliance
spec:
  description: Test
  disableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  extends: ocp4-cis
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-enable-only-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  extends: ocp4-cis
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-disablemix-rules
  namespace: openshift-compliance
spec:
  description: Test
  disableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  extends: ocp4-cis
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-disablemix-enableonly-rules
  namespace: openshift-compliance
spec:
  description: Test
  disableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  enableRules:
  - name: ocp4-kubelet-enable-streaming-connections
    rationale: test
  extends: ocp4-cis
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-enablemix-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  extends: ocp4-cis
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-enablemix-disableonly-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  disableRules:
  - name: ocp4-kubelet-enable-streaming-connections
    rationale: test
  extends: ocp4-cis
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-enablemix-disablemix-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  disableRules:
  - name: ocp4-kubelet-enable-streaming-connections
    rationale: test
  - name: ocp4-kubelet-enable-server-cert-rotation
    rationale: test
  - name: ocp4-idp-is-configured
    rationale: test
  extends: ocp4-cis
  title: My modified nist profile with a custom value
---
apiVersion: compliance.openshift.io/v1alpha1
kind: TailoredProfile
metadata:
  name: cis-infra-tp-disablemixmany-rules
  namespace: openshift-compliance
spec:
  description: Test
  enableRules:
  - name: ocp4-kubelet-anonymous-auth
    rationale: test
  - name: ocp4-kubelet-enable-streaming-connections
    rationale: test
  - name: ocp4-kubelet-enable-server-cert-rotation
    rationale: test
  - name: ocp4-api-server-insecure-port
    rationale: test
  - name: ocp4-api-server-tls-cert
    rationale: test
  - name: ocp4-idp-is-configured
    rationale: test
  extends: ocp4-cis
  title: My modified nist profile with a custom value
---

Expected Behavior:

oc get tp
NAME                                                STATE
cis-infra-tp-disablemix-enableonly-rules            READY
cis-infra-tp-disablemix-rules                       READY
cis-infra-tp-disablemixmany-rules                   READY
cis-infra-tp-disableonly-rules                      READY
cis-infra-tp-enable-only-rules                      READY
cis-infra-tp-enablemix-disablemix-rules             READY
cis-infra-tp-enablemix-disableonly-rules            READY
cis-infra-tp-enablemix-rules                        READY
cis-infra-tp-noextend-disablemix-enableonly-rules   ERROR
cis-infra-tp-noextend-disablemix-rules              ERROR
cis-infra-tp-noextend-disablemixmany-rules          READY
cis-infra-tp-noextend-disableonly-rules             ERROR
cis-infra-tp-noextend-enablemix-disablemix-rules    READY
cis-infra-tp-noextend-enablemix-disableonly-rules   READY
cis-infra-tp-noextend-enablemix-rules               READY
cis-infra-tp-noextend-enableonly-rules              READY

@xiaojiey
Copy link
Collaborator

xiaojiey commented Sep 12, 2023

/hold for test

@Vincent056 Vincent056 force-pushed the type_change branch 2 times, most recently from ff78432 to 66a2bc6 Compare September 12, 2023 14:07
@xiaojiey
Copy link
Collaborator

Didn't get expected result with commit 66a2bc6

$ oc get tp
NAME                                                STATE
cis-infra-tp-disablemix-enableonly-rules            ERROR
cis-infra-tp-disablemix-rules                       ERROR
cis-infra-tp-disablemixmany-rules                   ERROR
cis-infra-tp-disableonly-rules                      READY
cis-infra-tp-enable-only-rules                      READY
cis-infra-tp-enablemix-disablemix-rules             ERROR
cis-infra-tp-enablemix-disableonly-rules            ERROR
cis-infra-tp-enablemix-rules                        ERROR
cis-infra-tp-noextend-disablemix-enableonly-rules   ERROR
cis-infra-tp-noextend-disablemix-rules              ERROR
cis-infra-tp-noextend-disablemixmany-rules          ERROR
cis-infra-tp-noextend-disableonly-rules             ERROR
cis-infra-tp-noextend-enablemix-disablemix-rules    ERROR
cis-infra-tp-noextend-enablemix-disableonly-rules   ERROR
cis-infra-tp-noextend-enablemix-rules               ERROR
cis-infra-tp-noextend-enableonly-rules              READY

@Vincent056
Copy link
Author

Vincent056 commented Sep 12, 2023

cis-infra-tp-disablemix-enableonly-rules ERROR
cis-infra-tp-disablemix-rules ERROR
cis-infra-tp-disablemixmany-rules ERROR

I think you need to rerun the updated PB so the rule with get updated with correct annotation, it will be like a operator upgrade @xiaojiey

@Vincent056
Copy link
Author

cis-infra-tp-disablemix-enableonly-rules ERROR
cis-infra-tp-disablemix-rules ERROR
cis-infra-tp-disablemixmany-rules ERROR

I think you need to rerun the updated PB so the rule with get updated with correct annotation, it will be like a operator upgrade @xiaojiey

Just updated the e2e, I think it will cover some of the upgrade cases.

@Vincent056
Copy link
Author

/retest

@Vincent056 Vincent056 force-pushed the type_change branch 2 times, most recently from e8d273a to 8b7d445 Compare September 13, 2023 05:51
Copy link
Member

@yuumasato yuumasato left a comment

Choose a reason for hiding this comment

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

@Vincent056 These are the comments I have so far.

I'll continue reviewing tomorrow.

pkg/profileparser/profileparser.go Outdated Show resolved Hide resolved
Comment on lines 215 to 218
modPb.Spec.ContentImage = modifiedImage
if err := f.Client.Update(context.TODO(), modPb); err != nil {
t.Fatalf("failed to update ProfileBundle %s: %s", modPb.Name, err)
}
Copy link
Member

Choose a reason for hiding this comment

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

Is there a difference between the following?

  • deep copying modPb, creating it and updating .Spec.ContentImage
  • deep copying modPb, updating the .Spec.ContentImage and creating it

Copy link
Author

Choose a reason for hiding this comment

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

so what we are doing here is first to make a copy of original profile bundle cr instance and then fetch profile bundle CR, and change the content image of the original image, in the end we update the CR.

Copy link
Author

Choose a reason for hiding this comment

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

since the pb is already there, we are not creating a new one, but to make change to the existing one

@@ -2431,6 +2570,9 @@ func TestManualRulesTailoredProfile(t *testing.T) {
ObjectMeta: metav1.ObjectMeta{
Name: suiteName,
Namespace: f.OperatorNamespace,
Labels: map[string]string{
compv1alpha1.OutdatedReferenceValidationDisable: "true",
Copy link

Choose a reason for hiding this comment

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

How come we need to disable validation here?

Copy link
Author

Choose a reason for hiding this comment

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

that's a good catch, I will remove it. It was left from the last approach, where we manually mark migrated rules, now we will not have these issues.

Copy link
Member

Choose a reason for hiding this comment

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

This change is marked as as outdated, but still seems to be there at:
https://github.com/ComplianceAsCode/compliance-operator/pull/401/files#diff-a5334e69e88b595448bc22c081212911d6b0f04c2e91752ac2ef1ef7cb68c9edR2664
Is is expected to be there?

@xiaojiey
Copy link
Collaborator

xiaojiey commented Nov 16, 2023

compliance.openshift.io/prune-outdated-references

Adding more test results:

  1. after upgrade:
$ oc get rules -n openshift-compliance -o json | jq -r '.items[] | select(.metadata.annotations."compliance.openshift.io/rule-last-check-type" == "Platform" or .metadata.annotations."compliance.openshift.io/rule-last-check-type" == "Node") | .metadata.name'
ocp4-kubelet-anonymous-auth
ocp4-kubelet-authorization-mode
ocp4-kubelet-configure-client-ca
ocp4-kubelet-configure-event-creation
ocp4-kubelet-configure-tls-cipher-suites
ocp4-kubelet-enable-cert-rotation
ocp4-kubelet-enable-client-cert-rotation
ocp4-kubelet-enable-iptables-util-chains
ocp4-kubelet-enable-server-cert-rotation
ocp4-kubelet-enable-streaming-connections
ocp4-kubelet-eviction-thresholds-set-hard-imagefs-available
ocp4-kubelet-eviction-thresholds-set-hard-imagefs-inodesfree
ocp4-kubelet-eviction-thresholds-set-hard-memory-available
ocp4-kubelet-eviction-thresholds-set-hard-nodefs-available
ocp4-kubelet-eviction-thresholds-set-hard-nodefs-inodesfree
ocp4-kubelet-eviction-thresholds-set-soft-imagefs-available
ocp4-kubelet-eviction-thresholds-set-soft-imagefs-inodesfree
ocp4-kubelet-eviction-thresholds-set-soft-memory-available
ocp4-kubelet-eviction-thresholds-set-soft-nodefs-available
ocp4-kubelet-eviction-thresholds-set-soft-nodefs-inodesfree
ocp4-kubelet-read-only-port-secured
  1. Check tp status after adding compliance.openshift.io/prune-outdated-references: "true" for each tailoredprofile:
$ oc get tp
NAME                                                STATE
cis-infra-tp-disablemix-enableonly-rules            READY
cis-infra-tp-disablemix-rules                       READY
cis-infra-tp-disablemixmany-rules                   READY
cis-infra-tp-disableonly-rules                      READY
cis-infra-tp-enable-only-rules                      READY
cis-infra-tp-enablemix-disablemix-rules             READY
cis-infra-tp-enablemix-disableonly-rules            READY
cis-infra-tp-enablemix-rules                        READY
cis-infra-tp-noextend-disablemix-enableonly-rules   ERROR
cis-infra-tp-noextend-disablemix-rules              ERROR
cis-infra-tp-noextend-disablemixmany-rules          READY
cis-infra-tp-noextend-disableonly-rules             ERROR
cis-infra-tp-noextend-enablemix-disablemix-rules    READY
cis-infra-tp-noextend-enablemix-disableonly-rules   READY
cis-infra-tp-noextend-enablemix-rules               READY
cis-infra-tp-noextend-enableonly-rules              ERROR
$ diff tp_before_prune.yaml  tp_after_prune.yaml  | grep -Ev "generation|resourceVersion"
7a8
>       compliance.openshift.io/prune-outdated-references: "true"
11c12
---
21c22
---
26,27d26
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
32,34d30
<     enableRules:
<     - name: ocp4-kubelet-enable-streaming-connections
<       rationale: test
43,44d38
<     warnings: |
<       The following rules are migrated and need to be migrated or removed from the TailoredProfile: ocp4-kubelet-anonymous-auth,ocp4-kubelet-enable-streaming-connections
49a44
>       compliance.openshift.io/prune-outdated-references: "true"
53c48
---
63c58
---
68,69d62
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
82,83d74
<     warnings: |
<       The following rules are migrated and need to be migrated or removed from the TailoredProfile: ocp4-kubelet-anonymous-auth
126a118
>       compliance.openshift.io/prune-outdated-references: "true"

My editor automatically picked up these changes when I was making some
modifications locally.

Pulling them in a separate commit.
We were using tpSingleNoPrune as a variable in the test, but the actual
tailored profile was using multiple rules. This commit updates the
variable to reflect that.
} else if isValidationRequired(instance) {
reqLogger.Info("Validating TailoredProfile")
pruneOutdated := false
if _, ok := ann[cmpv1alpha1.PruneOutdatedReferencesAnnotationKey]; ok {
Copy link

Choose a reason for hiding this comment

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

This only checks if the annotation exists, but in our tests we're setting this to true at times. Which should we be using?

Setting it to true feels more explicit to me, with the absence or false value being the default.

Copy link
Member

Choose a reason for hiding this comment

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

Here I think I'd follow the same pattern done for rescan= annotation.

Copy link
Author

Choose a reason for hiding this comment

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

I think this makes sense here

This migration/feature adds new annotations that help users manage their
TailoredProfiles. For example, they can set an annotation that
automatically prune outdated rule references from the TailoredProfile.

Previously, we were only checking the presence of these annotations on
the TailoredProfile. This meant users should invoke the behavior with an
empty string (""), or a truthy value ("true"), or even a falsy ("false)
value.

This commit explicitly checks the value of the annotation and makes sure
it's set to true before invoking the behavior.
We can improve the readability of the test, especially since rule change
from Platfrom to Node type, by having dedicated assertions for checking
that attribute.

This commit uses those assertions in the end-to-end test so it's easier
for readers to know when that type change happens.
We have a pretty good understanding of how to migrate rules from one
type (Node) to another (Platform), but initially we included some
thoughts on how to handle deprecated rules and variables.

However, up to this point, we don't have a way to flag deprecated rules
or variables in the content, which is what's needed to annotate them
accordingly.

Since this code is involving a separate case (deprecation), and the
current migration e2e tests pass without it, let's remove it so we can
come up with a dedicated approach for it later.

This cuts down on the overall patch size, making it more digestable for
reviewers, especially since it wasn't fully tested.
@rhmdnd
Copy link

rhmdnd commented Nov 22, 2023

@Vincent056

@yuumasato and I walked through the code and found a few things to adjust, but we can step through them together next week, too. I just wanted to get the updates we discussed proposed before the break.

Each is its own commit, which we can evaluate and consider incorporating if we all agree they're addressing legitimate concerns.

Overall, we cleaned up some of e2e test to include some additional assertions, added strict checks on the annotation, and reduced the overall patch size by removing untested code for deprecating variables and rules.

This code was unused and untested, and we don't have a consistent, or
agreed upon way for deprecating rules and variables in the content.

Let's remove this for now so that we don't make the patch more
complicated. We can always come back to this functionality later.
Copy link
Member

@yuumasato yuumasato left a comment

Choose a reason for hiding this comment

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

Looks good to me.
I have suggested some changes to the warning. As the word "migrated" may not mean much to users.

@yuumasato
Copy link
Member

/retest

@@ -2439,3 +2439,25 @@ func (f *Framework) AssertScanDoesNotContainCheck(scanName, checkName, namespace
}
return nil
}

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for adding this, I think those make sense

Improve warning message on rule type change, explain to user what they might need to do on those rules
@xiaojiey
Copy link
Collaborator

/label qe-approved
Verification pass with 4.15.0-0.nightly-2023-11-28-101923 + code in the PR:
Verification steps:

1. install compliance-operator.v1.1.0
2. apply tp
3. upgrade to compliance-operator.v1.2.0
4. Check the kubelet rule annotations and checkType:
$ oc get rule ocp4-kubelet-anonymous-auth -o=jsonpath={.metadata.annotations}
{"compliance.openshift.io/image-digest":"pb-ocp4f6cjw","compliance.openshift.io/profiles":"ocp4-pci-dss-node,ocp4-stig-node,ocp4-moderate-node,ocp4-cis-node,ocp4-high-node,ocp4-nerc-cip-node","compliance.openshift.io/rule":"kubelet-anonymous-auth","compliance.openshift.io/rule-last-check-type":"Platform","control.compliance.openshift.io/CIS-OCP":"4.2.2","control.compliance.openshift.io/NERC-CIP":"CIP-003-8 R6;CIP-004-6 R3;CIP-007-3 R6.1","control.compliance.openshift.io/NIST-800-53":"CM-6;CM-6(1)","policies.open-cluster-management.io/controls":"CIP-003-8 R6,CIP-004-6 R3,CIP-007-3 R6.1,CM-6,CM-6(1),4.2.2","policies.open-cluster-management.io/standards":"NERC-CIP,NIST-800-53,CIS-OCP"}
$ oc get rule ocp4-kubelet-anonymous-auth -o=jsonpath={.checkType}
Node
5. Check warnings:
$  oc get tp -o=jsonpath={.items[*].status.warnings}
The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth,ocp4-kubelet-enable-streaming-connections
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth,ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-enable-server-cert-rotation
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-enable-server-cert-rotation,ocp4-kubelet-anonymous-auth
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-anonymous-auth
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth,ocp4-kubelet-enable-streaming-connections
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth,ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-enable-server-cert-rotation
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-enable-server-cert-rotation,ocp4-kubelet-anonymous-auth
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-anonymous-auth
 The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth
6. Check the annotation compliance.openshift.io/prune-outdated-references: "true" for each tp. Check the tp change before and after:
$ diff tp_before_prune_1130.yaml tp_after_prune_1130.yaml | grep -Ev "generation|resourceVersion" | grep -E ">|<"
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-disablemix-enableonly-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"enableRules":[{"name":"ocp4-kubelet-enable-streaming-connections","rationale":"test"}],"extends":"ocp4-cis","title":"My modified nist profile with a custom value"}}
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     enableRules:
<     - name: ocp4-kubelet-enable-streaming-connections
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth,ocp4-kubelet-enable-streaming-connections
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-disablemix-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"extends":"ocp4-cis","title":"My modified nist profile with a custom value"}}
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-disablemixmany-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-kubelet-enable-streaming-connections","rationale":"test"},{"name":"ocp4-kubelet-enable-server-cert-rotation","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"},{"name":"ocp4-idp-is-configured","rationale":"test"}],"extends":"ocp4-cis","title":"My modified nist profile with a custom value"}}
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     - name: ocp4-kubelet-enable-streaming-connections
<       rationale: test
<     - name: ocp4-kubelet-enable-server-cert-rotation
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth,ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-enable-server-cert-rotation
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-disableonly-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"}],"extends":"ocp4-cis","title":"My modified nist profile with a custom value"}}
<     disableRules:
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-enable-only-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"}],"extends":"ocp4-cis","title":"My modified nist profile with a custom value"}}
<     enableRules:
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-enablemix-disablemix-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-enable-streaming-connections","rationale":"test"},{"name":"ocp4-kubelet-enable-server-cert-rotation","rationale":"test"},{"name":"ocp4-idp-is-configured","rationale":"test"}],"enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"extends":"ocp4-cis","title":"My modified nist profile with a custom value"}}
<     - name: ocp4-kubelet-enable-streaming-connections
<       rationale: test
<     - name: ocp4-kubelet-enable-server-cert-rotation
<       rationale: test
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-enable-server-cert-rotation,ocp4-kubelet-anonymous-auth
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-enablemix-disableonly-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-enable-streaming-connections","rationale":"test"}],"enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"extends":"ocp4-cis","title":"My modified nist profile with a custom value"}}
<     disableRules:
<     - name: ocp4-kubelet-enable-streaming-connections
<       rationale: test
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-anonymous-auth
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-enablemix-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"extends":"ocp4-cis","title":"My modified nist profile with a custom value"}}
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-noextend-disablemix-enableonly-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"enableRules":[{"name":"ocp4-kubelet-enable-streaming-connections","rationale":"test"}],"title":"My modified nist profile with a custom value"}}
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     enableRules:
<     - name: ocp4-kubelet-enable-streaming-connections
<       rationale: test
>     errorMessage: Custom TailoredProfile with no extends does not have any rules enabled
<     state: READY
>     state: ERROR
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-noextend-disablemix-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"title":"My modified nist profile with a custom value"}}
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-noextend-disablemixmany-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-kubelet-enable-streaming-connections","rationale":"test"},{"name":"ocp4-kubelet-enable-server-cert-rotation","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"},{"name":"ocp4-idp-is-configured","rationale":"test"}],"title":"My modified nist profile with a custom value"}}
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     - name: ocp4-kubelet-enable-streaming-connections
<       rationale: test
<     - name: ocp4-kubelet-enable-server-cert-rotation
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth,ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-enable-server-cert-rotation
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-noextend-disableonly-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"}],"title":"My modified nist profile with a custom value"}}
<       compliance.openshift.io/prune-outdated-references: "true"
>       compliance.openshift.io/prune-outdated-references: "true"
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-noextend-enablemix-disablemix-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-enable-streaming-connections","rationale":"test"},{"name":"ocp4-kubelet-enable-server-cert-rotation","rationale":"test"},{"name":"ocp4-idp-is-configured","rationale":"test"}],"enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"title":"My modified nist profile with a custom value"}}
<     - name: ocp4-kubelet-enable-streaming-connections
<       rationale: test
<     - name: ocp4-kubelet-enable-server-cert-rotation
<       rationale: test
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-enable-server-cert-rotation,ocp4-kubelet-anonymous-auth
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-noextend-enablemix-disableonly-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","disableRules":[{"name":"ocp4-kubelet-enable-streaming-connections","rationale":"test"}],"enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"title":"My modified nist profile with a custom value"}}
<     disableRules:
<     - name: ocp4-kubelet-enable-streaming-connections
<       rationale: test
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-enable-streaming-connections,ocp4-kubelet-anonymous-auth
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-noextend-enablemix-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"},{"name":"ocp4-api-server-insecure-port","rationale":"test"},{"name":"ocp4-api-server-tls-cert","rationale":"test"}],"title":"My modified nist profile with a custom value"}}
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
<     warnings: |
<       The following rules changed check type and need to be removed from the TailoredProfile. If these rules are important for you, add them to a TailoredProfile of matching check type: ocp4-kubelet-anonymous-auth
<         {"apiVersion":"compliance.openshift.io/v1alpha1","kind":"TailoredProfile","metadata":{"annotations":{},"name":"cis-infra-tp-noextend-enableonly-rules","namespace":"openshift-compliance"},"spec":{"description":"Test","enableRules":[{"name":"ocp4-kubelet-anonymous-auth","rationale":"test"}],"title":"My modified nist profile with a custom value"}}
<     enableRules:
<     - name: ocp4-kubelet-anonymous-auth
<       rationale: test
>     errorMessage: Custom TailoredProfile with no extends does not have any rules enabled
<     state: READY

@xiaojiey
Copy link
Collaborator

xiaojiey commented Dec 1, 2023

/unhold

Copy link

@rhmdnd rhmdnd left a comment

Choose a reason for hiding this comment

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

/lgtm
/px-approved

Applying PX approved since we walked through this approach with @mkumku

Copy link

openshift-ci bot commented Dec 1, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhmdnd, Vincent056

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

@openshift-merge-bot openshift-merge-bot bot merged commit 8cd35fa into ComplianceAsCode:master Dec 1, 2023
12 checks passed
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