-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #581 from kubescape/improve-C-0012
C-0012 add allowed values and keys lists to reduce false positives
- Loading branch information
Showing
11 changed files
with
256 additions
and
7 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
31 changes: 31 additions & 0 deletions
31
rules/rule-credentials-configmap/test/test-allowed-values-keys/data.json
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,31 @@ | ||
{ | ||
"postureControlInputs": { | ||
"sensitiveKeyNames": [ | ||
"aws_access_key_id", | ||
"aws_secret_access_key", | ||
"azure_batchai_storage_account", | ||
"azure_batchai_storage_key", | ||
"azure_batch_account", | ||
"azure_batch_key", | ||
"secret", | ||
"key", | ||
"password", | ||
"pwd", | ||
"token", | ||
"jwt", | ||
"bearer", | ||
"credential" | ||
], | ||
"sensitiveValues": [ | ||
"BEGIN \\w+ PRIVATE KEY", | ||
"PRIVATE KEY", | ||
"eyJhbGciO", | ||
"JWT", | ||
"Bearer", | ||
"_key_", | ||
"_secret_" | ||
], | ||
"sensitiveKeyNamesAllowed": ["_FILE"], | ||
"sensitiveValuesAllowed": ["my/secret/file/path"] | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
rules/rule-credentials-configmap/test/test-allowed-values-keys/expected.json
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,35 @@ | ||
[{ | ||
"alertMessage": "this configmap has sensitive information: game-demo", | ||
"deletePaths": ["data[aws_access_key_id]"], | ||
"failedPaths": ["data[aws_access_key_id]"], | ||
"fixPaths": [], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 9, | ||
"alertObject": { | ||
"k8sApiObjects": [{ | ||
"apiVersion": "v1", | ||
"kind": "ConfigMap", | ||
"metadata": { | ||
"name": "game-demo" | ||
} | ||
}] | ||
} | ||
}, { | ||
"alertMessage": "this configmap has sensitive information: game-demo", | ||
"deletePaths": ["data[pwd]"], | ||
"failedPaths": ["data[pwd]"], | ||
"fixPaths": [], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 9, | ||
"alertObject": { | ||
"k8sApiObjects": [{ | ||
"apiVersion": "v1", | ||
"kind": "ConfigMap", | ||
"metadata": { | ||
"name": "game-demo" | ||
} | ||
}] | ||
} | ||
}] |
20 changes: 20 additions & 0 deletions
20
rules/rule-credentials-configmap/test/test-allowed-values-keys/input/configmap.yaml
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 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: game-demo | ||
data: | ||
# property-like keys; each key maps to a simple value | ||
player_initial_lives: "3" | ||
ui_properties_file_name: "user-interface.properties" | ||
aws_access_key_id: "XXXX" | ||
pwd: "hi" | ||
aws_access_key_id_file: "/etc/secret-volume/aws" | ||
aws_secret: "my/secret/file/path" | ||
# file-like keys | ||
game.properties: | | ||
enemy.types=aliens,monsters | ||
player.maximum-lives=5 | ||
user-interface.properties: | | ||
color.good=purple | ||
color.bad=yellow | ||
allow.textmode=true |
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
31 changes: 31 additions & 0 deletions
31
rules/rule-credentials-in-env-var/test/pod-allowed-values-keys/data.json
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,31 @@ | ||
{ | ||
"postureControlInputs": { | ||
"sensitiveKeyNames": [ | ||
"aws_access_key_id", | ||
"aws_secret_access_key", | ||
"azure_batchai_storage_account", | ||
"azure_batchai_storage_key", | ||
"azure_batch_account", | ||
"azure_batch_key", | ||
"secret", | ||
"key", | ||
"password", | ||
"pwd", | ||
"token", | ||
"jwt", | ||
"bearer", | ||
"credential" | ||
], | ||
"sensitiveValues": [ | ||
"BEGIN \\w+ PRIVATE KEY", | ||
"PRIVATE KEY", | ||
"eyJhbGciO", | ||
"JWT", | ||
"Bearer", | ||
"_key_", | ||
"_secret_" | ||
], | ||
"sensitiveKeyNamesAllowed": ["_FILE"], | ||
"sensitiveValuesAllowed": ["my/secret/file/path"] | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
rules/rule-credentials-in-env-var/test/pod-allowed-values-keys/expected.json
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,31 @@ | ||
[ | ||
{ | ||
"alertMessage": "Pod: audit-pod has sensitive information in environment variables", | ||
"deletePaths": [ | ||
"spec.containers[0].env[1].name", | ||
"spec.containers[0].env[1].value" | ||
], | ||
"failedPaths": [ | ||
"spec.containers[0].env[1].name", | ||
"spec.containers[0].env[1].value" | ||
], | ||
"fixPaths": [], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 9, | ||
"alertObject": { | ||
"k8sApiObjects": [ | ||
{ | ||
"apiVersion": "v1", | ||
"kind": "Pod", | ||
"metadata": { | ||
"labels": { | ||
"app": "audit-pod" | ||
}, | ||
"name": "audit-pod" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
] |
26 changes: 26 additions & 0 deletions
26
rules/rule-credentials-in-env-var/test/pod-allowed-values-keys/input/pod.yaml
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 @@ | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: audit-pod | ||
labels: | ||
app: audit-pod | ||
spec: | ||
containers: | ||
- name: test-container | ||
env : | ||
- name : random | ||
value : "Hello from the environment" | ||
- name: some-name | ||
value: my_key_value | ||
image: hashicorp/http-echo:0.2.3 | ||
securityContext: | ||
allowPrivilegeEscalation: true | ||
- name : test-container2 | ||
env : | ||
- name : random | ||
value : "Hello from the environment" | ||
- name: AWS_TOKEN_FILE | ||
value: /etc/secret-volume/aws | ||
- name: my_password | ||
value: my/secret/file/path | ||
image : hashicorp/http-echo:0.2.3 |