Skip to content

Commit

Permalink
fix rule and rulename
Browse files Browse the repository at this point in the history
Signed-off-by: YiscahLevySilas1 <[email protected]>
  • Loading branch information
YiscahLevySilas1 committed Jul 17, 2023
1 parent 3782b3d commit 1b28a4e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controls/C-0261-satokenmounted.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
"description": "Potential attacker may gain access to a workload and steal its ServiceAccount token. Therefore, it is recommended to disable automatic mapping of the ServiceAccount tokens in ServiceAccount configuration. Enable it only for workloads that need to use them and ensure that this ServiceAccount is not bound to an unnecessary ClusterRoleBinding or RoleBinding.",
"remediation": "Disable automatic mounting of service account tokens to pods at the workload level, by specifying automountServiceAccountToken: false. Enable it only for workloads that need to use them and ensure that this ServiceAccount doesn't have unnecessary permissions",
"rulesNames": ["automount-service-account"],
"rulesNames": ["serviceaccount-token-mount"],
"test": "test if ServiceAccount token is mounted on workload and it has at least one binding.",
"controlID": "C-0261",
"baseScore": 7.0
Expand Down
6 changes: 3 additions & 3 deletions rules/serviceaccount-token-mount/raw.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ deny[msga] {
msga := {
"alertMessage": sprintf("%v: %v in the following namespace: %v mounts service account tokens by default", [wl.kind, wl.metadata.name, wl.metadata.namespace]),
"packagename": "armo_builtins",
"alertScore": 7,
"alertScore": 9,
"fixPaths": fixed_path,
"failedPaths": failed_path,
"alertObject": {
Expand Down Expand Up @@ -55,15 +55,15 @@ is_sa_auto_mounted(spec, beggining_of_path, wl_namespace) = [failed_path, fix_pa
not spec.automountServiceAccountToken == false
not spec.automountServiceAccountToken == true

fix_path = { "path": sprintf("%v.automountServiceAccountToken", [concat(".", containers_path)]), "value": "false"}
fix_path = { "path": sprintf("%v.automountServiceAccountToken", [concat(".", beggining_of_path)]), "value": "false"}
failed_path = ""
}

is_sa_auto_mounted(spec, beggining_of_path, wl_namespace) = [failed_path, fix_path] {
# automountServiceAccountToken set to true in pod spec
spec.automountServiceAccountToken == true

failed_path = sprintf("%v.automountServiceAccountToken", [concat(".", containers_path)])
failed_path = sprintf("%v.automountServiceAccountToken", [concat(".", beggining_of_path)])
fix_path = ""
}

Expand Down
2 changes: 1 addition & 1 deletion rules/serviceaccount-token-mount/rule.metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "automount-service-account",
"name": "serviceaccount-token-mount",
"attributes": {
"armoBuiltin": true
},
Expand Down

0 comments on commit 1b28a4e

Please sign in to comment.