-
Notifications
You must be signed in to change notification settings - Fork 697
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-2400: exclusion of the namespace for resource-requests-quota-per-project
#12344
Conversation
resource-requests-quota-per-project
resource-requests-quota-per-project
applications/openshift/general/resource_requests_quota_per_project/rule.yml
Outdated
Show resolved
Hide resolved
applications/openshift/general/resource_requests_quota_per_project/rule.yml
Show resolved
Hide resolved
applications/openshift/general/resource_requests_quota_per_project/rule.yml
Outdated
Show resolved
Hide resolved
applications/openshift/general/resource_requests_quota_per_project/rule.yml
Outdated
Show resolved
Hide resolved
/test 4.15-e2e-aws-ocp4-moderate |
resource-requests-quota-per-project
resource-requests-quota-per-project
🤖 A k8s content image for this PR is available at: Click here to see how to deploy itIf you alread have Compliance Operator deployed: Otherwise deploy the content and operator together by checking out ComplianceAsCode/compliance-operator and: |
/test 4.15-e2e-aws-ocp4-stig |
1 similar comment
/test 4.15-e2e-aws-ocp4-stig |
deployments.apps "compliance-operator" not found |
/test 4.15-e2e-aws-ocp4-stig |
/test 4.15-e2e-aws-ocp4-stig |
@Vincent056 Did I missed anything? Why the variable does not work? Thanks.
|
let me test that |
/hold for test |
This datastream diff is auto generated by the check Click here to see the full diffNew content has different text for rule 'xccdf_org.ssgproject.content_rule_resource_requests_quota_per_project'.
--- xccdf_org.ssgproject.content_rule_resource_requests_quota_per_project
+++ xccdf_org.ssgproject.content_rule_resource_requests_quota_per_project
@@ -31,15 +31,15 @@
Therefore, you need to use a tool that can query the OCP API, retrieve the following:
/api/v1/resourcequotas
API endpoint, filter with with the jq utility using the following filter
- [.items[] | select((.metadata.namespace | startswith("openshift") | not) and (.metadata.namespace | startswith("kube-") | not) and .metadata.namespace != "default") | .metadata.namespace] | unique
+ [.items[] | select((.metadata.namespace | startswith("openshift") | not) and (.metadata.namespace | startswith("kube-") | not) and .metadata.namespace != "default" and .metadata.namespace != "rhacs-operator" and ({{if ne .var_resource_requests_quota_per_project_exempt_regex "None"}}.metadata.namespace | test("{{.var_resource_requests_quota_per_project_exempt_regex}}") | not{{else}}true{{end}})) | .metadata.namespace] | unique
and persist it to the local
- /api/v1/resourcequotas#2e6fd6a1fa7945ee6d06434fd05e4c27822d577045b3d3a4ca5809580cd57f50
+ /api/v1/resourcequotas#4326a181a1e3e8a8e02ffb58e7d3ca9e62ed0e144a5277b1f7551fdbcfeca0a8
file.
/api/v1/namespaces
API endpoint, filter with with the jq utility using the following filter
- [.items[] | select((.metadata.name | startswith("openshift") | not) and (.metadata.name | startswith("kube-") | not) and .metadata.name != "default")]
+ [.items[] | select((.metadata.name | startswith("openshift") | not) and (.metadata.name | startswith("kube-") | not) and .metadata.name != "default" and .metadata.name != "rhacs-operator" and ({{if ne .var_resource_requests_quota_per_project_exempt_regex "None"}}.metadata.name | test("{{.var_resource_requests_quota_per_project_exempt_regex}}") | not{{else}}true{{end}}))]
and persist it to the local
- /api/v1/namespaces#34d4beecc95c65d815d9d48fd4fdcb0c521631852ad088ef74e36d012b0e1e0d
+ /api/v1/namespaces#3ae63defe5cbb61225edb84d8e19f601be933d063305c1ea1e0381297c6258d6
file.
[reference]:
OVAL for rule 'xccdf_org.ssgproject.content_rule_resource_requests_quota_per_project' differs.
--- oval:ssg-resource_requests_quota_per_project:def:1
+++ oval:ssg-resource_requests_quota_per_project:def:1
@@ -1,4 +1,8 @@
criteria AND
criterion oval:ssg-test_file_for_resource_requests_quota_per_project:tst:1
criterion oval:ssg-test_file_for_resource_requests_quotas_filtered_namespaces:tst:1
+criteria OR
criterion oval:ssg-test_elements_count_for_resource_requests_quota_per_project:tst:1
+criteria AND
+criterion oval:ssg-test_resource_requests_quota_per_project:tst:1
+criterion oval:ssg-test_resource_requests_quotas_filtered_namespaces:tst:1
OCIL for rule 'xccdf_org.ssgproject.content_rule_resource_requests_quota_per_project' differs.
--- ocil:ssg-resource_requests_quota_per_project_ocil:questionnaire:1
+++ ocil:ssg-resource_requests_quota_per_project_ocil:questionnaire:1
@@ -1,10 +1,10 @@
Verify that the every non-control plane namespace has an appropriate ResourceQuota.
To get all the non-control plane namespaces, you can do the
-following command $ oc get namespaces -o json | jq '[.items[] | select((.metadata.name | startswith("openshift") | not) and (.metadata.name | startswith("kube-") | not) and .metadata.name != "default") | .metadata.name ]'
+following command $ oc get namespaces -o json | jq '[.items[] | select((.metadata.name | startswith("openshift") | not) and (.metadata.name | startswith("kube-") | not) and .metadata.name != "default" and .metadata.name != "rhacs-operator" and ({{if ne .var_resource_requests_quota_per_project_exempt_regex "None"}}.metadata.name | test("{{.var_resource_requests_quota_per_project_exempt_regex}}") | not{{else}}true{{end}})) | .metadata.name]'
To get all the non-control plane namespaces with a ResourceQuota, you can do the
-following command $ oc get --all-namespaces resourcequota -o json | jq '[.items[] | select((.metadata.namespace | startswith("openshift") | not) and (.metadata.namespace | startswith("kube-") | not) and .metadata.namespace != "default") | .metadata.namespace] | unique'
+following command $ oc get --all-namespaces resourcequota -o json | jq '[.items[] | select((.metadata.namespace | startswith("openshift") | not) and (.metadata.namespace | startswith("kube-") | not) and .metadata.namespace != "default" and .metadata.namespace != "rhacs-operator" and ({{if ne .var_resource_requests_quota_per_project_exempt_regex "None"}}.metadata.namespace | test("{{.var_resource_requests_quota_per_project_exempt_regex}}") | not{{else}}true{{end}})) | .metadata.namespace] | unique'
Make sure that the namespaces displayed in the commands of the commands match.
Is it the case that Resource requests and limits is not set per project? |
Verification pass with content image ghcr.io/complianceascode/k8scontent:12344:
|
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.
/lgtm
/unhold |
/test 4.15-e2e-aws-ocp4-stig |
@Vincent056 The assertion files for STIG need to be updated as well.
|
/test 4.15-e2e-aws-ocp4-stig |
the second failed was triggered by https://github.com/ComplianceAsCode/content/blob/b04eec41b6aa4f8059e5514886285262285c3d5d/applications/openshift/networking/configure_network_policies_namespaces/tests/ocp4/e2e-remediation.sh |
…quota-per-project Excluded RHACS from the default namespace check. We don't want to releax our rule too much for optional operator, as it might incress security risk, instead user should use tailoredprofile to set the exclusion regex. Added a new variable 'var_resource_requests_quota_per_project_exempt_regex'
This is to fix the e2e failures of resource_requests_quota_per_project caused by manual remediation of antoher rule/
/test 4.15-e2e-aws-ocp4-stig |
Code Climate has analyzed commit 6b62c35 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.5% (0.0% change). View more on Code Climate. |
@Vincent056: The following test failed, say
Full PR test history. Your PR dashboard. 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-sigs/prow repository. I understand the commands that are listed here. |
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.
/lgtm
We have excluded RHACS from the default namespace check. We don't want to relax our rule too much for the optional operators, as it might increase security risk, instead, the user should use a
tailoredprofile
to set the exclusion regex.Added a new variable
var_resource_requests_quota_per_project_exempt_regex
CMP-2400