-
Notifications
You must be signed in to change notification settings - Fork 48
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 #614 from kubescape/fix-C-0016
improve remediation - return fix path in every case
- Loading branch information
Showing
4 changed files
with
154 additions
and
155 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
96 changes: 50 additions & 46 deletions
96
rules/rule-allow-privilege-escalation/test/cronjob/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 |
---|---|---|
@@ -1,52 +1,56 @@ | ||
[{ | ||
"alertMessage": "container :mysql in CronJob: hello allow privilege escalation", | ||
"reviewPaths": [], | ||
"failedPaths": [], | ||
"fixPaths": [{ | ||
"path": "spec.jobTemplate.spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation", | ||
"value": "false" | ||
}, | ||
[ | ||
{ | ||
"path": "spec.jobTemplate.spec.template.spec.containers[0].securityContext.privileged", | ||
"value": "false" | ||
} | ||
], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [{ | ||
"apiVersion": "batch/v1beta1", | ||
"kind": "CronJob", | ||
"metadata": { | ||
"name": "hello" | ||
"alertMessage": "container :mysql in CronJob: hello allow privilege escalation", | ||
"fixPaths": [ | ||
{ | ||
"path": "spec.jobTemplate.spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation", | ||
"value": "false" | ||
}, | ||
{ | ||
"path": "spec.jobTemplate.spec.template.spec.containers[0].securityContext.privileged", | ||
"value": "false" | ||
} | ||
}] | ||
} | ||
}, { | ||
"alertMessage": "container :php in CronJob: hello allow privilege escalation", | ||
"reviewPaths": [], | ||
"failedPaths": [], | ||
"fixPaths": [{ | ||
"path": "spec.jobTemplate.spec.template.spec.containers[1].securityContext.allowPrivilegeEscalation", | ||
"value": "false" | ||
], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [ | ||
{ | ||
"apiVersion": "batch/v1beta1", | ||
"kind": "CronJob", | ||
"metadata": { | ||
"name": "hello" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"path": "spec.jobTemplate.spec.template.spec.containers[1].securityContext.privileged", | ||
"value": "false" | ||
} | ||
|
||
], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [{ | ||
"apiVersion": "batch/v1beta1", | ||
"kind": "CronJob", | ||
"metadata": { | ||
"name": "hello" | ||
"alertMessage": "container :php in CronJob: hello allow privilege escalation", | ||
"fixPaths": [ | ||
{ | ||
"path": "spec.jobTemplate.spec.template.spec.containers[1].securityContext.allowPrivilegeEscalation", | ||
"value": "false" | ||
}, | ||
{ | ||
"path": "spec.jobTemplate.spec.template.spec.containers[1].securityContext.privileged", | ||
"value": "false" | ||
} | ||
}] | ||
], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [ | ||
{ | ||
"apiVersion": "batch/v1beta1", | ||
"kind": "CronJob", | ||
"metadata": { | ||
"name": "hello" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}] | ||
] |
49 changes: 30 additions & 19 deletions
49
rules/rule-allow-privilege-escalation/test/pod/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 |
---|---|---|
@@ -1,21 +1,32 @@ | ||
[{ | ||
"alertMessage": "container: test-container in pod: audit-pod allow privilege escalation", | ||
"reviewPaths": ["spec.containers[0].securityContext.allowPrivilegeEscalation"], | ||
"failedPaths": ["spec.containers[0].securityContext.allowPrivilegeEscalation"], | ||
"fixPaths": [], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [{ | ||
"apiVersion": "v1", | ||
"kind": "Pod", | ||
"metadata": { | ||
"labels": { | ||
"app": "audit-pod" | ||
}, | ||
"name": "audit-pod" | ||
[ | ||
{ | ||
"alertMessage": "container: test-container in pod: audit-pod allow privilege escalation", | ||
"fixPaths": [ | ||
{ | ||
"path": "spec.containers[0].securityContext.allowPrivilegeEscalation", | ||
"value": "false" | ||
}, | ||
{ | ||
"path": "spec.containers[0].securityContext.privileged", | ||
"value": "false" | ||
} | ||
}] | ||
], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [ | ||
{ | ||
"apiVersion": "v1", | ||
"kind": "Pod", | ||
"metadata": { | ||
"labels": { | ||
"app": "audit-pod" | ||
}, | ||
"name": "audit-pod" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}] | ||
] |
105 changes: 59 additions & 46 deletions
105
rules/rule-allow-privilege-escalation/test/workloads/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 |
---|---|---|
@@ -1,49 +1,62 @@ | ||
[{ | ||
"alertMessage": "container :mysql in Deployment: my-deployment allow privilege escalation", | ||
"reviewPaths": ["spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation"], | ||
"failedPaths": ["spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation"], | ||
"fixPaths": [], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [{ | ||
"apiVersion": "apps/v1", | ||
"kind": "Deployment", | ||
"metadata": { | ||
"labels": { | ||
"app": "goproxy" | ||
}, | ||
"name": "my-deployment" | ||
[ | ||
{ | ||
"alertMessage": "container :mysql in Deployment: my-deployment allow privilege escalation", | ||
"fixPaths": [ | ||
{ | ||
"path": "spec.template.spec.containers[0].securityContext.allowPrivilegeEscalation", | ||
"value": "false" | ||
}, | ||
{ | ||
"path": "spec.template.spec.containers[0].securityContext.privileged", | ||
"value": "false" | ||
} | ||
}] | ||
} | ||
}, { | ||
"alertMessage": "container :php in Deployment: my-deployment allow privilege escalation", | ||
"reviewPaths": [], | ||
"failedPaths": [], | ||
"fixPaths": [{ | ||
"path": "spec.template.spec.containers[1].securityContext.allowPrivilegeEscalation", | ||
"value": "false" | ||
|
||
}, | ||
{ | ||
"path": "spec.template.spec.containers[1].securityContext.privileged", | ||
"value": "false" | ||
}], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [{ | ||
"apiVersion": "apps/v1", | ||
"kind": "Deployment", | ||
"metadata": { | ||
"labels": { | ||
"app": "goproxy" | ||
}, | ||
"name": "my-deployment" | ||
], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [ | ||
{ | ||
"apiVersion": "apps/v1", | ||
"kind": "Deployment", | ||
"metadata": { | ||
"labels": { | ||
"app": "goproxy" | ||
}, | ||
"name": "my-deployment" | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"alertMessage": "container :php in Deployment: my-deployment allow privilege escalation", | ||
"fixPaths": [ | ||
{ | ||
"path": "spec.template.spec.containers[1].securityContext.allowPrivilegeEscalation", | ||
"value": "false" | ||
}, | ||
{ | ||
"path": "spec.template.spec.containers[1].securityContext.privileged", | ||
"value": "false" | ||
} | ||
}] | ||
], | ||
"ruleStatus": "", | ||
"packagename": "armo_builtins", | ||
"alertScore": 7, | ||
"alertObject": { | ||
"k8sApiObjects": [ | ||
{ | ||
"apiVersion": "apps/v1", | ||
"kind": "Deployment", | ||
"metadata": { | ||
"labels": { | ||
"app": "goproxy" | ||
}, | ||
"name": "my-deployment" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}] | ||
] |