mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-12 15:50:15 -08:00
fix: Fix example dockerfile rego policy (#2460)
This commit is contained in:
@@ -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://")
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user