Skip to content

Commit

Permalink
fix: dockerfile sample (#93)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly authored Oct 10, 2023
1 parent 804ffbe commit 0eca531
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
6 changes: 6 additions & 0 deletions pkg/commands/scan/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ func Test_Execute(t *testing.T) {
policies: []string{"../../../testdata/escaped/policy.yaml"},
out: "../../../testdata/escaped/out.txt",
wantErr: false,
}, {
name: "dockerfile",
payload: "../../../testdata/dockerfile/input.json",
policies: []string{"../../../testdata/dockerfile/policy-check-external.yaml"},
out: "../../../testdata/dockerfile/out.txt",
wantErr: false,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
6 changes: 6 additions & 0 deletions testdata/dockerfile/out.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Loading policies ...
Loading payload ...
Pre processing ...
Running ( evaluating 1 resource against 1 policy ) ...
- check-dockerfile / no-external / FAILED: HTTP calls are not allowed; curl / wget are not allowed
Done
20 changes: 9 additions & 11 deletions testdata/dockerfile/policy-check-external.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ metadata:
name: check-dockerfile
spec:
rules:
- name: no-http
- name: no-external
validate:
message: "HTTP calls are not allowed"
assert:
all:
- ~.(Stages[].Commands[].Args[].Value):
(contains(@, 'https://') || contains(@, 'http://')): false
- name: no-curl-wget
validate:
message: "curl / wget are not allowed"
assert:
all:
- ~.(Stages[].Commands[].CmdLine[]):
(contains(@, 'wget') || contains(@, 'curl')): false
- message: "HTTP calls are not allowed"
check:
~.(Stages[].Commands[].Args[].Value):
(contains(@, 'https://') || contains(@, 'http://')): false
- message: "curl / wget are not allowed"
check:
~.(Stages[].Commands[].CmdLine[]):
(contains(@, 'wget') || contains(@, 'curl')): false

0 comments on commit 0eca531

Please sign in to comment.