Skip to content

Commit

Permalink
update rules
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Pivkin <[email protected]>
  • Loading branch information
nikpivkin committed Oct 10, 2024
1 parent 4064b52 commit 8708001
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions checks/docker/leaked_secrets.rego
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,23 @@ deny contains res if {
is_arg_or_env(instruction.Cmd)
some [name, def] in retrive_name_and_default(instruction)
def != ""
name in secret_file_envs
is_secret_file_env(name)
is_secret_file_copied(def)
res := result.new(
sprintf("Possible exposure of the copied secret env file %q in %s", [name, upper(instruction.Cmd)]),
instruction,
)
}

is_secret_file_env(name) if name in secret_file_envs

# check if a secret file is copied
deny contains res if {
some instruction in final_stage.Commands
instruction.Cmd == "copy"
count(instruction.Value) == 2
env := trim_prefix(instruction.Value[1], "$")
env in secret_file_envs
is_secret_file_env(env)
res := result.new(
sprintf("Possible exposure of secret file %q in COPY", [env]),
instruction,
Expand Down Expand Up @@ -138,8 +140,8 @@ is_secret(str) if {
}

is_secret(str) if {
not is_secret_env(str)
not str in secret_file_envs
not is_secret_env(str) # to avoid duplication of results
not is_secret_file_env(str) # files require checking that they have been copied
is_secret_key(str)
}

Expand Down

0 comments on commit 8708001

Please sign in to comment.