Skip to content

Commit

Permalink
Fix Input Dockerfile validation
Browse files Browse the repository at this point in the history
Signed-off-by: santoshkal <[email protected]>
  • Loading branch information
santoshkal committed Nov 27, 2023
1 parent dbf62df commit 068714d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/bin
coverage.out
input.yaml
input.json
input.json
dockerfile.json
2 changes: 1 addition & 1 deletion pkg/validate/dockerfile_val/validateinputfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func ValidateInput(yamlContent string, regoPolicyPath string) error {

// Create Rego for query and evaluation
regoQuery := rego.New(
rego.Query("data."+pkg), // Using hardcoded query as before
rego.Query("data."+pkg),
rego.Module(regoPolicyPath, string(regoContent)),
rego.Input(inputMap),
)
Expand Down
4 changes: 2 additions & 2 deletions templates/defaultpolicies/rego/inputfile_policies.rego
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ default check_base_image = false
default check_multi_stage = false

check_base_image{
cmd := input.Dockerfile[_].Instructions[_].from[_]
cmd := input.dockerfile[_].instructions[_].from[_]
contains(cmd, "cgr.dev/chainguard")
}


check_multi_stage{
cmd := input.Dockerfile[_].Stage
cmd := input.dockerfile[_].stage
cmd > 0
}

Expand Down

0 comments on commit 068714d

Please sign in to comment.