-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Policies] [new rule] File ownerships (#5)
- Loading branch information
1 parent
0f750de
commit 6ab6bc2
Showing
35 changed files
with
482 additions
and
73 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package compliance.cis_k8s.rules.cis_1_1_14 | ||
|
||
import data.compliance.cis_k8s | ||
import data.compliance.lib.common | ||
import data.compliance.lib.data_adapter | ||
|
||
# Ensure that the admin.conf file ownership is set to root:root (Automated) | ||
finding = result { | ||
data_adapter.filename == "admin.conf" | ||
uid = data_adapter.owner_user_id | ||
gid = data_adapter.owner_group_id | ||
rule_evaluation := common.file_ownership_match(uid, gid, "root", "root") | ||
|
||
# set result | ||
result := { | ||
"evaluation": common.calculate_result(rule_evaluation), | ||
"evidence": {"uid": uid, "gid": gid}, | ||
} | ||
} | ||
|
||
metadata = { | ||
"name": "Ensure that the API server pod specification file ownership is set to root:root", | ||
"description": "The admin.conf file contains the admin credentials for the cluster. You should set its file ownership to maintain the integrity of the file. The file should be owned by root:root.", | ||
"impact": "None", | ||
"tags": array.concat(cis_k8s.default_tags, ["CIS 1.1.14", "Master Node Configuration"]), | ||
"benchmark": cis_k8s.benchmark_name, | ||
"remediation": "chown root:root /etc/kubernetes/admin.conf", | ||
} |
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,23 @@ | ||
package compliance.cis_k8s.rules.cis_1_1_14 | ||
|
||
import data.cis_k8s.test_data | ||
import data.lib.test | ||
|
||
test_violation { | ||
test.assert_fail(finding) with input as rule_input("admin.conf", "root", "user") | ||
test.assert_fail(finding) with input as rule_input("admin.conf", "user", "root") | ||
test.assert_fail(finding) with input as rule_input("admin.conf", "user", "user") | ||
} | ||
|
||
test_pass { | ||
test.assert_pass(finding) with input as rule_input("admin.conf", "root", "root") | ||
} | ||
|
||
test_not_evaluated { | ||
not finding with input as rule_input("file.txt", "root", "root") | ||
} | ||
|
||
rule_input(filename, uid, gid) = filesystem_input { | ||
filemode := "0644" | ||
filesystem_input = test_data.filesystem_input(filename, filemode, uid, gid) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package compliance.cis_k8s.rules.cis_1_1_16 | ||
|
||
import data.compliance.cis_k8s | ||
import data.compliance.lib.common | ||
import data.compliance.lib.data_adapter | ||
|
||
# Ensure that the scheduler.conf file ownership is set to root:root (Automated) | ||
finding = result { | ||
data_adapter.filename == "scheduler.conf" | ||
uid = data_adapter.owner_user_id | ||
gid = data_adapter.owner_group_id | ||
rule_evaluation := common.file_ownership_match(uid, gid, "root", "root") | ||
|
||
# set result | ||
result := { | ||
"evaluation": common.calculate_result(rule_evaluation), | ||
"evidence": {"uid": uid, "gid": gid}, | ||
} | ||
} | ||
|
||
metadata = { | ||
"name": "Ensure that the scheduler.conf file ownership is set to root:root", | ||
"description": "The scheduler.conf file is the kubeconfig file for the Scheduler. You should set its file ownership to maintain the integrity of the file. The file should be owned by root:root.", | ||
"impact": "None", | ||
"tags": array.concat(cis_k8s.default_tags, ["CIS 1.1.16", "Master Node Configuration"]), | ||
"benchmark": cis_k8s.benchmark_name, | ||
"remediation": "chown root:root /etc/kubernetes/scheduler.conf", | ||
} |
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,23 @@ | ||
package compliance.cis_k8s.rules.cis_1_1_16 | ||
|
||
import data.cis_k8s.test_data | ||
import data.lib.test | ||
|
||
test_violation { | ||
test.assert_fail(finding) with input as rule_input("scheduler.conf", "root", "user") | ||
test.assert_fail(finding) with input as rule_input("scheduler.conf", "user", "root") | ||
test.assert_fail(finding) with input as rule_input("scheduler.conf", "user", "user") | ||
} | ||
|
||
test_pass { | ||
test.assert_pass(finding) with input as rule_input("scheduler.conf", "root", "root") | ||
} | ||
|
||
test_not_evaluated { | ||
not finding with input as rule_input("file.txt", "root", "root") | ||
} | ||
|
||
rule_input(filename, uid, gid) = filesystem_input { | ||
filemode := "0644" | ||
filesystem_input = test_data.filesystem_input(filename, filemode, uid, gid) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package compliance.cis_k8s.rules.cis_1_1_18 | ||
|
||
import data.compliance.cis_k8s | ||
import data.compliance.lib.common | ||
import data.compliance.lib.data_adapter | ||
|
||
# Ensure that the controller-manager.conf file ownership is set to root:root (Automated) | ||
finding = result { | ||
data_adapter.filename == "controller-manager.conf" | ||
uid = data_adapter.owner_user_id | ||
gid = data_adapter.owner_group_id | ||
rule_evaluation := common.file_ownership_match(uid, gid, "root", "root") | ||
|
||
# set result | ||
result := { | ||
"evaluation": common.calculate_result(rule_evaluation), | ||
"evidence": {"uid": uid, "gid": gid}, | ||
} | ||
} | ||
|
||
metadata = { | ||
"name": "Ensure that the controller-manager.conf file ownership is set to root:root", | ||
"description": "The controller-manager.conf file is the kubeconfig file for the Controller Manager. You should set its file ownership to maintain the integrity of the file. The file should be owned by root:root.", | ||
"impact": "None", | ||
"tags": array.concat(cis_k8s.default_tags, ["CIS 1.1.18", "Master Node Configuration"]), | ||
"benchmark": cis_k8s.benchmark_name, | ||
"remediation": "chown root:root /etc/kubernetes/controller-manager.conf", | ||
} |
Oops, something went wrong.