Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rego): improve commands parsing #113

Merged
merged 4 commits into from
May 14, 2024
Merged

Conversation

nikpivkin
Copy link
Contributor

@nikpivkin nikpivkin commented Apr 18, 2024

Fixes aquasecurity/trivy#6516

Fixed DS017 check, now commands are parsed correctly.

Added a new function sh.parse_commands that takes a string representation of a sequence of commands and returns a list of lists of command parts.
For example:

./opa eval 'sh.parse_commands("apt update; apt install -y nginx")' -f pretty
[
  [
    "apt",
    "update"
  ],
  [
    "apt",
    "install",
    "-y",
    "nginx"
  ]
]

We have a lot of checks where we parse commands using regular expressions, which can be unreliable.. Later we can move on to using this function.

@nikpivkin
Copy link
Contributor Author

@simar7 Will be ready to merge after aquasecurity/trivy#6502 for backwards compatibility in users who don't update Trivy.

@simar7 simar7 added this pull request to the merge queue May 14, 2024
Merged via the queue into aquasecurity:main with commit 93bcb2f May 14, 2024
5 checks passed
@nikpivkin nikpivkin deleted the cmds-parse branch May 28, 2024 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix(misconf): split docker commands by semicolon
2 participants