forked from elastic/cloudbeat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[new rule] Master Node Configuration File permissions rules (#2)
Master Node Configuration File permissions rules
- Loading branch information
1 parent
828ddbd
commit d051b2d
Showing
21 changed files
with
323 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
package compliance.lib.data_adapter | ||
|
||
is_osquery { | ||
input.osquery | ||
input.osquery | ||
} | ||
|
||
is_file { | ||
is_osquery | ||
input.osquery.filename | ||
is_osquery | ||
input.osquery.filename | ||
} | ||
|
||
filename = file_name { | ||
is_file | ||
file_name = input.osquery.filename | ||
is_file | ||
file_name = input.osquery.filename | ||
} | ||
|
||
filemode = file_mode { | ||
is_file | ||
file_mode = input.osquery.mode | ||
is_file | ||
file_mode = input.osquery.mode | ||
} | ||
|
||
owner_user_id = uid { | ||
is_file | ||
uid = input.osquery.uid | ||
is_file | ||
uid = input.osquery.uid | ||
} | ||
|
||
owner_group_id = gid { | ||
is_file | ||
gid = input.osquery.gid | ||
is_file | ||
gid = input.osquery.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package lib.test | ||
|
||
rule_pass(finding) { | ||
finding.evaluation == "passed" | ||
finding.evaluation == "passed" | ||
} | ||
|
||
rule_violation(finding) { | ||
finding.evaluation == "violation" | ||
finding.evaluation == "violation" | ||
} |
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
package compliance.cis.rules.cis_1_1_1 | ||
|
||
import data.compliance.cis_k8s | ||
import data.compliance.lib.common | ||
import data.compliance.lib.data_adapter | ||
import data.compliance.lib.common | ||
import data.compliance.cis_k8s | ||
|
||
# Ensure that the API server pod specification file permissions are set to 644 or more restrictive | ||
finding = result { | ||
data_adapter.filename == "kube-apiserver.yaml" | ||
filemode := data_adapter.filemode | ||
rule_evaluation := common.file_permission_match(filemode, 6, 4, 4) | ||
data_adapter.filename == "kube-apiserver.yaml" | ||
filemode := data_adapter.filemode | ||
rule_evaluation := common.file_permission_match(filemode, 6, 4, 4) | ||
|
||
# set result | ||
result := { | ||
"evaluation": common.calculate_result(rule_evaluation), | ||
"evidence": {"filemode": filemode}, | ||
"rule_name": "Ensure that the API server pod specification file permissions are set to 644 or more restrictive", | ||
"tags": array.concat(cis_k8s.default_tags, ["CIS 1.1.1"]), | ||
} | ||
} | ||
# set result | ||
result := { | ||
"evaluation" : common.calculate_result(rule_evaluation), | ||
"evidence" : { "filemode" : filemode }, | ||
"rule_name" : "Ensure that the API server pod specification file permissions are set to 644 or more restrictive", | ||
"tags" : array.concat(cis_k8s.default_tags, ["CIS 1.1.1"]) | ||
} | ||
} |
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,20 @@ | ||
package compliance.cis.rules.cis_1_1_13 | ||
|
||
import data.compliance.lib.data_adapter | ||
import data.compliance.lib.common | ||
import data.compliance.cis_k8s | ||
|
||
# Ensure that the admin.conf file permissions are set to 644 or more restrictive | ||
finding = result { | ||
data_adapter.filename == "admin.conf" | ||
filemode := data_adapter.filemode | ||
rule_evaluation := common.file_permission_match(filemode, 6, 4, 4) | ||
|
||
# set result | ||
result := { | ||
"evaluation" : common.calculate_result(rule_evaluation), | ||
"evidence" : { "filemode" : filemode }, | ||
"rule_name" : "Ensure that the admin.conf file permissions are set to 644 or more restrictive", | ||
"tags" : array.concat(cis_k8s.default_tags, ["CIS 1.1.13"]) | ||
} | ||
} |
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,21 @@ | ||
package compliance.cis.rules.cis_1_1_13 | ||
|
||
import data.lib.test | ||
|
||
test_violation { | ||
test.rule_violation(finding) with input as rule_input("0700") | ||
} | ||
|
||
test_pass { | ||
test.rule_pass(finding) with input as rule_input("0644") | ||
} | ||
|
||
rule_input(filemode) = { | ||
"osquery": { | ||
"mode": filemode, | ||
"path": "/hostfs/etc/kubernetes/manifests/kube-apiserver.yaml", | ||
"uid": "root", | ||
"filename": "admin.conf", | ||
"gid": "root" | ||
} | ||
} |
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,20 @@ | ||
package compliance.cis.rules.cis_1_1_15 | ||
|
||
import data.compliance.lib.data_adapter | ||
import data.compliance.lib.common | ||
import data.compliance.cis_k8s | ||
|
||
# Ensure that the scheduler.conf file permissions are set to 644 or more restrictive (Automated) | ||
finding = result { | ||
data_adapter.filename == "scheduler.conf" | ||
filemode := data_adapter.filemode | ||
rule_evaluation := common.file_permission_match(filemode, 6, 4, 4) | ||
|
||
# set result | ||
result := { | ||
"evaluation" : common.calculate_result(rule_evaluation), | ||
"evidence" : { "filemode" : filemode }, | ||
"rule_name" : "Ensure that the scheduler.conf file permissions are set to 644 or more restrictive", | ||
"tags" : array.concat(cis_k8s.default_tags, ["CIS 1.1.15"]) | ||
} | ||
} |
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,21 @@ | ||
package compliance.cis.rules.cis_1_1_15 | ||
|
||
import data.lib.test | ||
|
||
test_violation { | ||
test.rule_violation(finding) with input as rule_input("0700") | ||
} | ||
|
||
test_pass { | ||
test.rule_pass(finding) with input as rule_input("0644") | ||
} | ||
|
||
rule_input(filemode) = { | ||
"osquery": { | ||
"mode": filemode, | ||
"path": "/hostfs/etc/kubernetes/manifests/kube-apiserver.yaml", | ||
"uid": "root", | ||
"filename": "scheduler.conf", | ||
"gid": "root" | ||
} | ||
} |
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,20 @@ | ||
package compliance.cis.rules.cis_1_1_17 | ||
|
||
import data.compliance.lib.data_adapter | ||
import data.compliance.lib.common | ||
import data.compliance.cis_k8s | ||
|
||
# Ensure that the controller-manager.conf file permissions are set to 644 or more restrictive (Automated) | ||
finding = result { | ||
data_adapter.filename == "controller-manager.conf" | ||
filemode := data_adapter.filemode | ||
rule_evaluation := common.file_permission_match(filemode, 6, 4, 4) | ||
|
||
# set result | ||
result := { | ||
"evaluation" : common.calculate_result(rule_evaluation), | ||
"evidence" : { "filemode" : filemode }, | ||
"rule_name" : "Ensure that the controller-manager.conf file permissions are set to 644 or more restrictive", | ||
"tags" : array.concat(cis_k8s.default_tags, ["CIS 1.1.17"]) | ||
} | ||
} |
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,21 @@ | ||
package compliance.cis.rules.cis_1_1_17 | ||
|
||
import data.lib.test | ||
|
||
test_violation { | ||
test.rule_violation(finding) with input as rule_input("0700") | ||
} | ||
|
||
test_pass { | ||
test.rule_pass(finding) with input as rule_input("0644") | ||
} | ||
|
||
rule_input(filemode) = { | ||
"osquery": { | ||
"mode": filemode, | ||
"path": "/hostfs/etc/kubernetes/manifests/kube-apiserver.yaml", | ||
"uid": "root", | ||
"filename": "controller-manager.conf", | ||
"gid": "root" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package compliance.cis.rules.cis_1_1_2 | ||
|
||
import data.compliance.cis_k8s | ||
import data.compliance.lib.common | ||
import data.compliance.lib.data_adapter | ||
import data.compliance.lib.common | ||
import data.compliance.cis_k8s | ||
|
||
|
||
# Ensure that the API server pod specification file ownership is set to root:root | ||
finding = result { | ||
data_adapter.filename == "kube-apiserver.yaml" | ||
uid = data_adapter.owner_user_id | ||
gid = data_adapter.owner_group_id | ||
rule_evaluation := common.file_ownership_match(uid, gid, "root", "root") | ||
data_adapter.filename == "kube-apiserver.yaml" | ||
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}, | ||
"rule_name": "Ensure that the API server pod specification file ownership is set to root:root", | ||
"tags": array.concat(cis_k8s.default_tags, ["CIS 1.1.2"]), | ||
} | ||
} | ||
# set result | ||
result := { | ||
"evaluation" : common.calculate_result(rule_evaluation), | ||
"evidence" : {"uid" : uid, "gid" : gid}, | ||
"rule_name" : "Ensure that the API server pod specification file ownership is set to root:root", | ||
"tags" : array.concat(cis_k8s.default_tags, ["CIS 1.1.2"]) | ||
} | ||
} |
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,20 @@ | ||
package compliance.cis.rules.cis_1_1_3 | ||
|
||
import data.compliance.lib.data_adapter | ||
import data.compliance.lib.common | ||
import data.compliance.cis_k8s | ||
|
||
# Ensure that the API server pod specification file permissions are set to 644 or more restrictive | ||
finding = result { | ||
data_adapter.filename == "kube-controller-manager.yaml" | ||
filemode := data_adapter.filemode | ||
rule_evaluation := common.file_permission_match(filemode, 6, 4, 4) | ||
|
||
# set result | ||
result := { | ||
"evaluation" : common.calculate_result(rule_evaluation), | ||
"evidence" : { "filemode" : filemode }, | ||
"rule_name" : "Ensure that the controller manager pod specification file permissions are set to 644 or more restrictive", | ||
"tags" : array.concat(cis_k8s.default_tags, ["CIS 1.1.3"]) | ||
} | ||
} |
Oops, something went wrong.