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

[Infra] test data generator #6

Merged
merged 4 commits into from
Nov 17, 2021
Merged

[Infra] test data generator #6

merged 4 commits into from
Nov 17, 2021

Conversation

oren-zohar
Copy link
Collaborator

Add test data generator
General repo struct refactor

General repo struct refactor
@oren-zohar oren-zohar self-assigned this Nov 15, 2021
@oren-zohar oren-zohar requested a review from kfirpeled November 15, 2021 13:19
Split common test function from k8s test data function file
@oren-zohar oren-zohar removed their assignment Nov 15, 2021
│ ├── rules/cis
│ │ ├── cis_1_1_1 # rule package
│ ├── cis_k8s/rules
│ | ├── cis_k8s.rego # Handles all Kubernetes CIS rules evalutations
Copy link
Collaborator

Choose a reason for hiding this comment

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

move it outside the rules

test_pass {
test.rule_pass(finding) with input as rule_input("0644")
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

add test when it shouldn't be evaluated - meaning filename is different than kube-apiserver.yaml

import data.lib.test

test_violation {
test.rule_violation(finding) with input as rule_input("0700")
Copy link
Collaborator

Choose a reason for hiding this comment

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

refactor test.assert_violation and test.assert_passed

test.rule_violation(finding) with input as rule_input("0700")
}

test_pass {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add another test for more restrictive file mode (instead of the exact value) to the common.rego with common_test.rego

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like to add for testing assertion that we have minimal schema validations

# test data generater
filesystem_input(filename, mode, uid, gid) = {
"type": "filesystem",
"path": "file/path",
Copy link
Collaborator

Choose a reason for hiding this comment

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

add the filename into the end of the example path

@kfirpeled kfirpeled merged commit 5a0225c into main Nov 17, 2021
@kfirpeled kfirpeled deleted the test_data_generator branch November 17, 2021 15:33
orestisfl pushed a commit to orestisfl/csp-security-policies that referenced this pull request Oct 12, 2023
elastic#6


---NOTE---
This is an imported commit, it was initially committed to the
csp-security-policies repo which was then merged into cloudbeat. See:
elastic/cloudbeat#1405
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants