Last active
June 29, 2021 03:43
-
-
Save macox/b2dc351f09c6664bc24544195561db56 to your computer and use it in GitHub Desktop.
OPA exceptions - data driven
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
dockerfile: | |
policies: | |
- name: warn_latest_tag | |
enabled: true |
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
package main | |
import data.dockerfile | |
# read disabled policies from data file and set as exceptions | |
exception[disabledPolicies] { | |
disabledPolicies := [p | p = substring(dockerfile.policies[i].name, indexof(dockerfile.policies[i].name,"_") +1 ,-1); dockerfile.policies[i].enabled == false] | |
} | |
# images do not use latest tag | |
warn_latest_tag[msg] { | |
input[i].Cmd == "from" | |
split_image := split(input[i].Value[0], ":") | |
lower(split_image[1]) == "latest" | |
msg = sprintf("Do not use latest tag with image: %s", [input[i].Value[0]]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment