unit tests for 'Dockerfile' OPA policies #110
Replies: 2 comments 9 replies
-
Are you looking to write unit tests based on what you posted above? Or you're trying to understand how to write a configuration test for a Dockerfile? Assuming the goal is to validate your Dockerfile configuration, this article shows some really good examples: https://medium.com/miro-engineering/a-practical-guide-to-writing-secure-dockerfiles-bf561224dd80 |
Beta Was this translation helpful? Give feedback.
-
Hi @peteroneilljr - is it possible to write unit tests for the library .rego file. Observed that this file is actually affecting our overall Code Coverage. Is there a way to write test cases for the below code? Thanks! Example (code not covered): } users[x] { copy_commands[x] { |
Beta Was this translation helpful? Give feedback.
-
Hi,
Looking for some help in writing unit tests for the Dockerfile OPA policies in order to increase the code coverage as much as can. I'm new to rego language, hence this ask. It would be great if someone can help me get started with...Thanks!
Unit tests for Dockerfile instructions such as
entrypoints[x] {
lower(input[i].Cmd) == lower("entrypoint")
x := input[i]
}
exposed_ports[x] {
lower(input[i].Cmd) == lower("expose")
x := input[i]
}
users
copy_commands
add_commands
is_root_user
valid_port
command_array
get_ports ...etc.,
Beta Was this translation helpful? Give feedback.
All reactions