Fix broken k8s_object_rules tests.#302
Merged
Merged
Conversation
Contributor
|
This pull request does not have a backport label. Could you fix it @yashtewari? 🙏
|
fd13092 to
70bc263
Compare
7d518cd to
61623c0
Compare
oren-zohar
requested changes
Jul 28, 2022
Collaborator
There was a problem hiding this comment.
Inserting a per-testcase UUID into the K8S object's metadata that is being tested allows for much simpler resource-matching than the recursion logic in the dict_contains utility.
🚀 🚀 🚀 🚀
Looks good, one comment
oren-zohar
reviewed
Jul 28, 2022
Comment on lines
+75
to
+78
| test_resource_id = str(uuid.uuid4()) | ||
| labels = resource_body['metadata'].get('labels', {}) | ||
| labels['test_resource_id'] = test_resource_id | ||
| resource_body['metadata']['labels'] = labels |
Collaborator
There was a problem hiding this comment.
Suggested change
| test_resource_id = str(uuid.uuid4()) | |
| labels = resource_body['metadata'].get('labels', {}) | |
| labels['test_resource_id'] = test_resource_id | |
| resource_body['metadata']['labels'] = labels | |
| metadata.setdefault('labels', {}) | |
| test_resource_id = str(uuid.uuid4()) | |
| metadata['labels']['test_resource_id'] = test_resource_id |
oren-zohar
requested changes
Jul 28, 2022
61623c0 to
8741308
Compare
oren-zohar
approved these changes
Jul 28, 2022
Cloudbeat CI 🤖Allure Report: http://csp-allure-reports.s3.amazonaws.com/allure_reports/cloudbeat/prs/302/index.html |
gurevichdmitry
approved these changes
Jul 28, 2022
gurevichdmitry
left a comment
Collaborator
There was a problem hiding this comment.
LGTM, great work!
mergify Bot
pushed a commit
that referenced
this pull request
Aug 26, 2022
Most of the problems occur in resource-matching logic that tries to find the right ES event to compare the expected evaluation against, which is harder to do for K8S resources than other resource types. Inserting a per-testcase UUID into the K8S object's metadata that is being tested allows for much simpler resource-matching than the recursion logic in the `dict_contains` utility. (cherry picked from commit 678e826)
DaveSys911
pushed a commit
that referenced
this pull request
Sep 5, 2022
Fix broken k8s_object_rules tests. (#302) Most of the problems occur in resource-matching logic that tries to find the right ES event to compare the expected evaluation against, which is harder to do for K8S resources than other resource types. Inserting a per-testcase UUID into the K8S object's metadata that is being tested allows for much simpler resource-matching than the recursion logic in the `dict_contains` utility. (cherry picked from commit 678e826) Co-authored-by: Yash Tewari <yashtewari1996@gmail.com> Co-authored-by: David Natachanny <david.natachanny@elastic.co>
orouz
pushed a commit
to orouz/cloudbeat
that referenced
this pull request
Sep 16, 2023
orestisfl
pushed a commit
to orestisfl/cloudbeat
that referenced
this pull request
Oct 11, 2023
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Most of the problems occur in resource-matching logic that tries to find the right ES event to compare the expected evaluation against, which is harder to do for K8S resources than other resource types.
Inserting a per-testcase UUID into the K8S object's metadata that is being tested allows for much simpler resource-matching than the recursion logic in the
dict_containsutility.Resolves: https://github.com/elastic/security-team/issues/4312