-
Notifications
You must be signed in to change notification settings - Fork 507
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 #3 from Avanti19/avanti_docker_policies
Avanti docker policies for run instruction
- Loading branch information
Showing
9 changed files
with
109 additions
and
1 deletion.
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
17 changes: 17 additions & 0 deletions
17
pkg/policies/opa/rego/docker/docker_run/AC_DOCKER_0002.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,17 @@ | ||
{ | ||
"name": "runUsingApt", | ||
"file": "runUsingApt.rego", | ||
"policy_type": "docker", | ||
"resource_type": "run", | ||
"template_args": { | ||
"prefix": "", | ||
"suffix": "", | ||
"name": "runUsingApt" | ||
}, | ||
"severity": "MEDIUM", | ||
"description": "Ensure apt is not used with RUN command for Docker file", | ||
"reference_id": "AC_DOCKER_0001", | ||
"category": "Infrastructure Security", | ||
"id": "AC_DOCKER_0002", | ||
"version": 1 | ||
} |
17 changes: 17 additions & 0 deletions
17
pkg/policies/opa/rego/docker/docker_run/AC_DOCKER_0003.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,17 @@ | ||
{ | ||
"name": "runUsingDnfUpdate", | ||
"file": "runUsingDnfUpdate.rego", | ||
"policy_type": "docker", | ||
"resource_type": "run", | ||
"template_args": { | ||
"prefix": "", | ||
"suffix": "", | ||
"name": "runUsingDnfUpdate" | ||
}, | ||
"severity": "MEDIUM", | ||
"description": "Ensure dnf Update is not used for Docker file", | ||
"reference_id": "AC_DOCKER_0003", | ||
"category": "Infrastructure Security", | ||
"id": "AC_DOCKER_0003", | ||
"version": 1 | ||
} |
17 changes: 17 additions & 0 deletions
17
pkg/policies/opa/rego/docker/docker_run/AC_DOCKER_0004.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,17 @@ | ||
{ | ||
"name": "yumInstallAllowInput", | ||
"file": "yumInstallAllowInput.rego", | ||
"policy_type": "docker", | ||
"resource_type": "run", | ||
"template_args": { | ||
"prefix": "", | ||
"suffix": "", | ||
"name": "yumInstallAllowInput" | ||
}, | ||
"severity": "MEDIUM", | ||
"description": "Ensure yum install allow manual input with RUN command for Docker file", | ||
"reference_id": "AC_DOCKER_0004", | ||
"category": "Infrastructure Security", | ||
"id": "AC_DOCKER_0004", | ||
"version": 1 | ||
} |
17 changes: 17 additions & 0 deletions
17
pkg/policies/opa/rego/docker/docker_run/AC_DOCKER_0005.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,17 @@ | ||
{ | ||
"name": "lastUserRoot", | ||
"file": "lastUserRoot.rego", | ||
"policy_type": "docker", | ||
"resource_type": "run", | ||
"template_args": { | ||
"prefix": "", | ||
"suffix": "", | ||
"name": "lastUserRoot" | ||
}, | ||
"severity": "MEDIUM", | ||
"description": "Ensure root with RUN command is not used for Docker file", | ||
"reference_id": "AC_DOCKER_0005", | ||
"category": "Infrastructure Security", | ||
"id": "AC_DOCKER_0005", | ||
"version": 1 | ||
} |
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,6 @@ | ||
package accurics | ||
|
||
{{.prefix}}{{.name}}{{.suffix}}[cmd.id]{ | ||
cmd := input.user[count(input.user) - 1] | ||
cmd.config == "root" | ||
} |
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,7 @@ | ||
package accurics | ||
|
||
{{.prefix}}{{.name}}{{.suffix}}[cmd.id]{ | ||
cmd := input.run[_] | ||
config := cmd.config | ||
contains(config, "apt") | ||
} |
8 changes: 8 additions & 0 deletions
8
pkg/policies/opa/rego/docker/docker_run/runUsingDnfUpdate.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,8 @@ | ||
package accurics | ||
|
||
{{.prefix}}{{.name}}{{.suffix}}[cmd.id]{ | ||
cmd := input.run[_] | ||
config := cmd.config | ||
commands = ["dnf update", "dnf upgrade", "dnf upgrade-minimal"] | ||
contains(config, commands[_]) | ||
} |
18 changes: 18 additions & 0 deletions
18
pkg/policies/opa/rego/docker/docker_run/yumInstallAllowInput.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,18 @@ | ||
package accurics | ||
|
||
{{.prefix}}{{.name}}{{.suffix}}[cmd.id]{ | ||
cmd := input.run[_] | ||
config := cmd.config | ||
checkYumInstall(config) | ||
not checkManualInput(config) | ||
} | ||
|
||
checkYumInstall(config) { | ||
re_match(`yum (-(-)?[a-zA-Z]+ *)*(group|local)?install`, config) | ||
} | ||
|
||
checkManualInput(config) { | ||
commands := ["-y", "yes", "--assumeyes"] | ||
checkCmd := commands[_] | ||
contains(config, checkCmd) | ||
} |