fix(checks): handle file: and multi: in AVD-DS-005#60
Merged
simar7 merged 1 commit intoaquasecurity:mainfrom Feb 7, 2024
Merged
fix(checks): handle file: and multi: in AVD-DS-005#60simar7 merged 1 commit intoaquasecurity:mainfrom
file: and multi: in AVD-DS-005#60simar7 merged 1 commit intoaquasecurity:mainfrom
Conversation
Contributor
Author
|
@simar7 can you please help me progress this MR? I'm very eager to eliminate this false positive. |
Member
|
@nikpivkin could you take a look? |
nikpivkin
reviewed
Feb 6, 2024
Comment on lines
+28
to
+30
| cnt := count(copy.Value) | ||
| not (cnt == 3 && startswith(add.Value[0], "file:") || startswith(add.Value[0], "multi:") && add.Value[1] == "in") | ||
|
|
Contributor
There was a problem hiding this comment.
I don't have permissions to make changes to this branch.
Rego does not have the && and || operators. All expressions in a rule are evaluated sequentially, which is equivalent to conjunction.
Here is the implementation of your expression in Rego:
Suggested change
| cnt := count(copy.Value) | |
| not (cnt == 3 && startswith(add.Value[0], "file:") || startswith(add.Value[0], "multi:") && add.Value[1] == "in") | |
| not is_command_with_hash(add.Value, "file:") | |
| not is_command_with_hash(add.Value, "multi:") |
is_command_with_hash(cmd, prefix) {
count(cmd) == 3
startswith(cmd[0], prefix)
cmd[1] == "in"
}
You can also merge main into your branch to run tests.
Contributor
Contributor
Author
There was a problem hiding this comment.
Thank you for providing the ability to run tests, that's very helpful!
I've updated this MR with your suggestion.
The reverse engineered `Dockerfile` of an image doesn't exactly match the original `Dockerfile`. For example, it doesn't have the original source files names. Instead, it uses `file:<hash> in`: `ADD file:8b8864b3e02a33a579dc216fd51b28a6047bc8eeaa03045b258980fe0cf7fcb3 in /__cacert_entrypoint.sh` Such commands should not trigger AVD-DS-005.
cf10630 to
be21df0
Compare
nikpivkin
approved these changes
Feb 7, 2024
simar7
approved these changes
Feb 7, 2024
Merged
6 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reverse engineered
Dockerfileof an image doesn't exactly match the originalDockerfile. For example, it doesn't have the original source files names. Instead, it usesfile:<hash> in:ADD file:8b8864b3e02a33a579dc216fd51b28a6047bc8eeaa03045b258980fe0cf7fcb3 in /__cacert_entrypoint.shSuch commands should not trigger AVD-DS-005.