fix: Fix example dockerfile rego policy (#2460)

This commit is contained in:
Liam Galvin
2022-07-05 15:46:27 +01:00
committed by GitHub
parent e778ac3e21
commit e77cfd6487
2 changed files with 5 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ __rego_metadata__ := {
__rego_input__ := {"selector": [{"type": "dockerfile"}]}
deny[res] {
add := input.stages[_][_]
add := input.Stages[_].Commands[_]
add.Cmd == "add"
startswith(add.Value[0], "http://")

View File

@@ -1,21 +1,21 @@
package user.dockerfile.ID002
test_http_denied {
r := deny with input as {"stages": {"alpine:3.13": [
r := deny with input as {"Stages": [{"Name": "alpine:3.31", "Commands": [
{"Cmd": "from", "Value": ["alpine:3.13"]},
{"Cmd": "add", "Value": ["http://example.com/big.tar.xz", "/usr/src/things/"]},
{"Cmd": "run", "Value": ["tar -xJf /usr/src/things/big.tar.xz -C /usr/src/things"]},
]}}
]}]}
count(r) == 1
r[_] == "HTTP not allowed: 'http://example.com/big.tar.xz'"
}
test_http_allowed {
r := deny with input as {"stages": {"alpine:3.13": [
r := deny with input as {"Stages": [{"Name": "alpine:3.31", "Commands": [
{"Cmd": "from", "Value": ["alpine:3.13"]},
{"Cmd": "add", "Value": ["https://example.com/big.tar.xz", "/usr/src/things/"]},
]}}
]}]}
count(r) == 0
}