fix(policy): add referenced script traversal#2312
Merged
migmartri merged 8 commits intoAug 8, 2025
Merged
Conversation
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
migmartri
reviewed
Aug 6, 2025
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
jiparis
approved these changes
Aug 6, 2025
| for _, file := range files { | ||
| if file.IsDir() { | ||
| // Loads referenced rego files from all YAML files in the policy | ||
| func loadReferencedRegoFiles(policy *PolicyToLint) error { |
Member
There was a problem hiding this comment.
very nit: the argument could be a receiver instead func (policy *PolicyToLint) loadReferenceRegoFiles() {
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
migmartri
approved these changes
Aug 6, 2025
migmartri
reviewed
Aug 6, 2025
| } | ||
|
|
||
| cmd.Flags().StringVarP(&policyPath, "policy", "p", ".", "Path to policy directory") | ||
| cmd.Flags().StringVarP(&policyPath, "policy", "p", "policy.yaml", "Path to policy file") |
Member
There was a problem hiding this comment.
should we do the same approach in eval?
Also, should we change init so the default created file is policy.yaml?
Member
There was a problem hiding this comment.
actually eval works like this it seems, it doesn't load a default though.
the init might need update too
Contributor
Author
There was a problem hiding this comment.
I thought about it, I'll update it in this PR, although some docs changes will be needed as well
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
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.
This PR changes the way policy file is linted.
policy.yamlfile, if not found linting fails. (before it would lint all valid *.yaml and *.rego files)Closes #2310