-
Notifications
You must be signed in to change notification settings - Fork 16
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
[New Rule] Api server first automated rule (1.2.2) #11
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
0d8c8e7
Add test data generator
oren-zohar 40f3602
Readme
oren-zohar 453782a
Readme
oren-zohar d4aa802
API Server First rule
oren-zohar 94fb697
First automated rule under API server (1.2.2)
oren-zohar bcc7a46
More meta!
oren-zohar 83cfb71
Merge Main into current
oren-zohar 4f1168d
Merge branch 'main' into api-server-first-rule
oren-zohar a85e7ca
Merge branch 'main' into folder-rules-impl
oren-zohar 46048a9
main changes
oren-zohar 5e879b9
cr changes
oren-zohar 1748483
Merge branch 'main' into api-server-first-rule
oren-zohar 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
This file contains 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,26 @@ | ||
package compliance.cis_k8s.rules.cis_1_2_2 | ||
|
||
import data.compliance.cis_k8s | ||
import data.compliance.lib.common | ||
import data.compliance.lib.data_adapter | ||
|
||
# Ensure that the --basic-auth-file argument is not set (Automated) | ||
finding = result { | ||
command_args := data_adapter.command_args | ||
rule_evaluation := common.array_contains(command_args, "--basic-auth-file") == false | ||
|
||
# set result | ||
result := { | ||
"evaluation": common.calculate_result(rule_evaluation), | ||
"evidence": {"command_args": command_args}, | ||
} | ||
} | ||
|
||
metadata = { | ||
"name": "Ensure that the --basic-auth-file argument is not set", | ||
"description": "Basic authentication uses plaintext credentials for authentication. Currently, the basic authentication credentials last indefinitely, and the password cannot be changed without restarting the API server. The basic authentication is currently supported for convenience. Hence, basic authentication should not be used.", | ||
"impact": "You will have to configure and use alternate authentication mechanisms such as tokens and certificates. Username and password for basic authentication could no longer be used.", | ||
"tags": array.concat(cis_k8s.default_tags, ["CIS 1.2.2", "API Server"]), | ||
"benchmark": cis_k8s.benchmark_name, | ||
"remediation": "Follow the documentation and configure alternate mechanisms for authentication. Then, edit the API server pod specification file /etc/kubernetes/manifests/kube-apiserver.yaml on the master node and remove the --basic-auth-file=<filename> parameter.", | ||
} |
This file contains 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,18 @@ | ||
package compliance.cis_k8s.rules.cis_1_2_2 | ||
|
||
import data.cis_k8s.test_data | ||
import data.lib.test | ||
|
||
test_violation { | ||
test.assert_fail(finding) with input as rule_input("api_server", "--basic-auth-file") | ||
} | ||
|
||
test_pass { | ||
test.assert_pass(finding) with input as rule_input("api_server", "") | ||
} | ||
|
||
test_not_evaluated { | ||
not finding with input as rule_input("some_process", "") | ||
} | ||
|
||
rule_input(process_type, argument) = test_data.api_server_input(process_type, [argument]) |
This file contains 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 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 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
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.
if you don't mind - change the file name to test_utils.rego same goes with package
(leave that refactor to the backlog)
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.
I'll do it in a separate PR after all other rules are merged