-
Notifications
You must be signed in to change notification settings - Fork 37
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
config: Allow configuration of capabilities #423
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f646ea9
config: Allow configuration of capabilities
charlieegan3 cebcec1
Support loading caps from file
charlieegan3 eeda01e
Correct struct tag formatting
charlieegan3 1fff993
Pass caps into regoArgs
charlieegan3 5d79a7b
Revert "Pass caps into regoArgs"
charlieegan3 d292b58
Add defaulting to OPA caps when source missing
charlieegan3 56c6e30
gci-ed
charlieegan3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"builtins": [ | ||
{ | ||
"name": "wow", | ||
"description": "Increases wow in Rego rule", | ||
"categories": [ | ||
"special" | ||
], | ||
"decl": { | ||
"args": [ | ||
{ | ||
"name": "x", | ||
"type": "number" | ||
} | ||
], | ||
"result": { | ||
"description": "the wowness level for input `x`", | ||
"name": "y", | ||
"type": "number" | ||
}, | ||
"type": "function" | ||
} | ||
} | ||
], | ||
"future_keywords": [ | ||
"contains", | ||
"every", | ||
"if", | ||
"in" | ||
], | ||
"wasm_abi_versions": null, | ||
"features": [ | ||
"rule_head_ref_string_prefixes" | ||
] | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no capabilities have been provided, should we default to latest from OPA here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've had a go a finishing this off a little more in 1fff993
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Thanks 😃 Looks good to me.
The one thing I'm not sure about is passing the capabilities from the config to Rego's eval args. Would that not have the linter (i.e. Regal) itself be limited to whatever capabilities the target policy has? I mean, even if we're linting a Rego file with e.g. a pre-
contains
OPA version, surely we should be able to use contains in Regal's linter policy?I think the way we'll want to use the capabilities at least initially, is basically as a datasource for what built-in functions we might encounter in the policy we're linting, and have linter rules be able to declare their dependencies... like how we should skip the custom-has-key-construct if
object.keys
is not in the capabilities, and so on.But if we eval with the provided capabilities, it would mean we can't use
object.keys
, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, I see. I think I got the wrong end of the stick! I can take this part out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've taken out the changes in 5d79a7b and then added the defaulting back in d292b58
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!