Skip to content

Commit

Permalink
Feat(Query): Default Seccomp Profile Disabled for docker compose (Che…
Browse files Browse the repository at this point in the history
…ckmarx#5154)

* query seccomp disabled

* Update positive1.yaml

* Update positive2.yaml

* Update positive_expected_result.json

* validated samples

* updated P E R

* Changed as requested

* uncommented

* updated P E R

* changed as requested
  • Loading branch information
cxAndreFelicidade authored Apr 12, 2022
1 parent 52d6d76 commit 51b9e1e
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"id": "404fde2c-bc4b-4371-9747-7054132ac953",
"queryName": "Default Seccomp Profile Disabled",
"severity": "MEDIUM",
"category": "Resource Management",
"descriptionText": "Seccomp offers a whitelist of common system calls, blocking all others. Having less kernel exposed to an app then increases security.",
"descriptionUrl": "https://docs.docker.com/compose/compose-file/compose-file-v3/#security_opt",
"platform": "DockerCompose",
"descriptionID": "3702d7fb"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package Cx

import data.generic.common as common_lib

CxPolicy[result] {
resource := input.document[i]
service_parameters := resource.services[name]
sec_opt_array := service_parameters.security_opt
sec_opt := sec_opt_array[a]
contains(sec_opt,"seccomp:unconfined")

result := {
"documentId": sprintf("%s", [resource.id]),
"searchKey": sprintf("services.%s.security_opt",[name]),
"issueType": "IncorrectValue",
"keyExpectedValue": "Seccomp default profile to not be disabled.",
"keyActualValue": "Seccomp default profile is disabled.",
"searchLine": common_lib.build_search_line(["services", name, "security_opt", a], []),
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: "3.9"

services:
webapp:
build:
context: ./
dockerfile: Dockerfile-alternate
args:
buildno: 1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: "3.8"

services:
demo:
image: not/a/real/image
cap_add:
- SYS_PTRACE
volumes:
- type: volume
source: not-a-real-source-docker
target: /var/lib/docker
security_opt:
- label:seccomp:unconfined

volumes:
not-a-real-source-docker:
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: "3.9"

networks:
backend:

services:
example:
build: .
security_opt:
- seccomp:unconfined
networks:
- backend
ports:
- "5002:5002"
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"queryName": "Default Seccomp Profile Disabled",
"severity": "MEDIUM",
"line": 13,
"filename": "positive1.yaml"
},
{
"queryName": "Default Seccomp Profile Disabled",
"severity": "MEDIUM",
"line": 10,
"filename": "positive2.yaml"
}
]

0 comments on commit 51b9e1e

Please sign in to comment.