forked from Checkmarx/kics
-
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.
Feat(Query): Privileged Containers Enabled for Docker Compose (Checkm…
…arx#5029) * query privileged containers dCompose * query privileged containers dCompose * query privileged containers dCompose 2 * query privileged containers dCompose * validates samples, changed query to match them
- Loading branch information
1 parent
492fe36
commit ee1cd11
Showing
7 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
assets/queries/dockerCompose/privileged_containers_enabled/metadata.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,10 @@ | ||
{ | ||
"id": "ae5b6871-7f45-42e0-bb4c-ab300c4d2026", | ||
"queryName": "Privileged Containers Enabled", | ||
"severity": "HIGH", | ||
"category": "Resource Management", | ||
"descriptionText": "Privileged containers should be used with extreme caution, they have all of the capabilities that the linux kernel offers for docker.", | ||
"descriptionUrl": "https://docs.docker.com/compose/compose-file/compose-file-v3/#domainname-hostname-ipc-mac_address-privileged-read_only-shm_size-stdin_open-tty-user-working_dir", | ||
"platform": "DockerCompose", | ||
"descriptionID": "029f6145" | ||
} |
19 changes: 19 additions & 0 deletions
19
assets/queries/dockerCompose/privileged_containers_enabled/query.rego
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,19 @@ | ||
package Cx | ||
|
||
import data.generic.common as common_lib | ||
|
||
CxPolicy[result] { | ||
resource := input.document[i] | ||
service_parameters := resource.services[name] | ||
privileged := service_parameters.privileged | ||
privileged == true | ||
|
||
result := { | ||
"documentId": sprintf("%s", [resource.id]), | ||
"searchKey": sprintf("services.%s.privileged",[name]), | ||
"issueType": "IncorrectValue", | ||
"keyExpectedValue": "Docker compose file to have 'privileged' attribute set to false or not set", | ||
"keyActualValue": "Docker compose file has 'privileged' attribute as true", | ||
"searchLine": common_lib.build_search_line(["services", name, "privileged"], []), | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
assets/queries/dockerCompose/privileged_containers_enabled/test/negative1.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,9 @@ | ||
version: "3.9" | ||
|
||
services: | ||
webapp: | ||
build: | ||
context: ./dir | ||
dockerfile: Dockerfile-alternate | ||
args: | ||
buildno: 1 |
13 changes: 13 additions & 0 deletions
13
assets/queries/dockerCompose/privileged_containers_enabled/test/negative2.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,13 @@ | ||
version: "3.9" | ||
|
||
services: | ||
webapp: | ||
build: | ||
context: ./dir | ||
dockerfile: Dockerfile-alternate | ||
args: | ||
buildno: 1 | ||
ports: | ||
- "8080:8080" | ||
- "3000:3000" | ||
privileged: false |
10 changes: 10 additions & 0 deletions
10
assets/queries/dockerCompose/privileged_containers_enabled/test/positive1.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,10 @@ | ||
version: "3.9" | ||
|
||
services: | ||
webapp: | ||
build: | ||
context: ./dir | ||
dockerfile: Dockerfile-alternate | ||
args: | ||
buildno: 1 | ||
privileged: true |
15 changes: 15 additions & 0 deletions
15
assets/queries/dockerCompose/privileged_containers_enabled/test/positive2.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,15 @@ | ||
version: "3.9" | ||
|
||
services: | ||
webapp: | ||
build: | ||
context: ./dir | ||
dockerfile: Dockerfile-alternate | ||
args: | ||
buildno: 1 | ||
ports: | ||
- "8080:8080" | ||
- "3000:3000" | ||
privileged: true | ||
cap_drop: | ||
- all |
14 changes: 14 additions & 0 deletions
14
...ts/queries/dockerCompose/privileged_containers_enabled/test/positive_expected_result.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,14 @@ | ||
[ | ||
{ | ||
"queryName": "Privileged Containers Enabled", | ||
"severity": "HIGH", | ||
"line": 10, | ||
"filename": "positive1.yaml" | ||
}, | ||
{ | ||
"queryName": "Privileged Containers Enabled", | ||
"severity": "HIGH", | ||
"line": 13, | ||
"filename": "positive2.yaml" | ||
} | ||
] |