-
Notifications
You must be signed in to change notification settings - Fork 756
CMP-3580: Implement checks for unsupported API server configs #13969
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
applications/openshift/api-server/api_server_kube_no_unsupported_config_overrides/rule.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| title: Ensure No Unsupported Configuration Overrides are Used | ||
|
|
||
| platform: not ocp4-on-hypershift-hosted | ||
|
|
||
| description: |- | ||
| Kubernetes API servers should not use unsupported configuration overrides that | ||
| can potentially compromise the security and stability of the cluster. This | ||
| rule checks that no unsupported configuration overrides are present in the | ||
| cluster API server configurations. | ||
|
|
||
| rationale: |- | ||
| Unsupported configuration overrides can introduce security vulnerabilities, | ||
| performance issues, and unexpected behaviors in the cluster. They bypass the | ||
| standard configuration mechanisms and can potentially weaken the cluster's | ||
| security posture or introduce instability. | ||
|
|
||
| severity: medium | ||
|
|
||
| identifiers: | ||
| cce@ocp4: CCE-89304-0 | ||
|
|
||
| references: | ||
| cis@ocp4: 1.2.31 | ||
|
|
||
| {{% set jqfilter = '[.items[] | select(.spec.unsupportedConfigOverrides != null and .spec.unsupportedConfigOverrides != {}) | .metadata.name]' %}} | ||
|
|
||
| ocil_clause: 'Unsupported Kubernetes API server configuration overrides are detected' | ||
|
|
||
| ocil: |- | ||
| Run the following commands to check for unsupported configuration overrides: | ||
| <pre>$ oc get kubeapiserver/cluster -o jsonpath='{.spec.unsupportedConfigOverrides}'</pre> | ||
| Verify that these commands return an empty object or no output. | ||
|
|
||
| warnings: | ||
| - general: |- | ||
| {{{ openshift_filtered_cluster_setting({'/apis/operator.openshift.io/v1/kubeapiservers': jqfilter}) | indent(4) }}} | ||
|
|
||
| template: | ||
| name: yamlfile_value | ||
| vars: | ||
| ocp_data: "true" | ||
| filepath: {{{ openshift_filtered_path('/apis/operator.openshift.io/v1/kubeapiservers', jqfilter) }}} | ||
| yamlpath: "[:]" | ||
| check_existence: "none_exist" | ||
| entity_check: "all" | ||
| values: | ||
| - value: "(.*?)" | ||
| operation: "pattern match" |
48 changes: 48 additions & 0 deletions
48
applications/openshift/api-server/api_server_no_unsupported_config_overrides/rule.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| title: Ensure No Unsupported Configuration Overrides are Used | ||
|
|
||
| platform: not ocp4-on-hypershift-hosted | ||
|
|
||
| description: |- | ||
| OpenShift API servers should not use unsupported configuration overrides that | ||
| can potentially compromise the security and stability of the cluster. This | ||
| rule checks that no unsupported configuration overrides are present in the | ||
| cluster API server configurations. | ||
|
|
||
| rationale: |- | ||
| Unsupported configuration overrides can introduce security vulnerabilities, | ||
| performance issues, and unexpected behaviors in the cluster. They bypass the | ||
| standard configuration mechanisms and can potentially weaken the cluster's | ||
| security posture or introduce instability. | ||
|
|
||
| severity: medium | ||
|
|
||
| identifiers: | ||
| cce@ocp4: CCE-89950-0 | ||
|
|
||
| references: | ||
| cis@ocp4: 1.2.31 | ||
|
|
||
| {{% set jqfilter = '[.items[] | select(.spec.unsupportedConfigOverrides != null and .spec.unsupportedConfigOverrides != {}) | .metadata.name]' %}} | ||
|
|
||
| ocil_clause: 'Unsupported OpenShift API server configuration overrides are detected' | ||
|
|
||
| ocil: |- | ||
| Run the following commands to check for unsupported configuration overrides: | ||
| <pre>$ oc get openshiftapiserver/cluster -o jsonpath='{.spec.unsupportedConfigOverrides}'</pre> | ||
| Verify that these commands return an empty object or no output. | ||
|
|
||
| warnings: | ||
| - general: |- | ||
| {{{ openshift_filtered_cluster_setting({'/apis/operator.openshift.io/v1/openshiftapiservers': jqfilter}) | indent(4) }}} | ||
|
|
||
| template: | ||
| name: yamlfile_value | ||
| vars: | ||
| ocp_data: "true" | ||
| filepath: {{{ openshift_filtered_path('/apis/operator.openshift.io/v1/openshiftapiservers', jqfilter) }}} | ||
| yamlpath: "[:]" | ||
| check_existence: "none_exist" | ||
| entity_check: "all" | ||
| values: | ||
| - value: "(.*?)" | ||
| operation: "pattern match" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange - these didn't get picked up in the OCP4 cis testing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding in the platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule still didn't show up in the test's artifacts.
Could it be that it is still not using the PR sources to build? Although I see the following in the logs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rule is getting build and put in the datastream, but it still doesn't seem to run in CI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like we're passing the content image from the PR correctly - https://github.com/openshift/release/blob/master/ci-operator/config/ComplianceAsCode/content/ComplianceAsCode-content-master__4.18.yaml#L225
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rhmdnd
componentdoesn't seem to be used anywhere. Regardless,--content-image=$CONTENT_IMAGEseems correct.From the logs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks good to me, @rhmdnd
But would you like to use this PR as testing grounds to understand why it doesn't show up in the tests?