Implementation of Design Queries in Rego#68
Merged
Nfsaavedra merged 12 commits intosr-lab:interactive_repairfrom Jan 29, 2026
Merged
Implementation of Design Queries in Rego#68Nfsaavedra merged 12 commits intosr-lab:interactive_repairfrom
Nfsaavedra merged 12 commits intosr-lab:interactive_repairfrom
Conversation
Note: the files for the previous implementation were left as is since there were no tests for this smell
racoelhosilva
commented
Jan 29, 2026
|
|
||
| import data.glitch_lib | ||
|
|
||
| # Some changes were made to the data config to make the tests pass |
| } | ||
| checker(node) { | ||
| attr := node.attributes[_] | ||
| regex.match("(&&|;|\\|)", attr.value) |
Contributor
There was a problem hiding this comment.
If you want to check the value of an attribute, you would need something like attr.value.value.
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.
Implementation of Design Queries in Rego
Description
This pull request contains the implementation of some Design analysis into the new Rego engine. The overall structure is similar to the one previously developed here for security smells.
Additionally, a memory free operation was now enforced upon generating Rego results. The OPA package was also updated to the latest version and there was a new Rego Python release.
Implemented Queries
The following queries and errors were adapted based on the existing Python logic:
design_avoid_commentsdesign_imperative_abstractiondesign_long_resourcedesign_misplaced_attributedesign_multifaceted_abstractionimplementation_too_many_variablesMissing Queries
Currently, not all of the existing Design queries were converted due to the following reasons:
design_duplicate_block,implementation_improper_alignmentandimplementation_long_statement.implementation_unguarded_variableanddesign_unnecessary_abstraction.Rego Wrapper Changes
The Go package for OPA was also bumped from version 0.70.0 to 1.12.3 and the corresponding release was created. With this, some investigation was done into converting the queries to Rego v1 syntax. This is still open for discussion but, for now, the queries still use Rego v0. Finally, another change was also added to this PR, to enforce freeing the memory created for the Rego output.
Testing
All tests related to these changes are passing and working as expected.
Notes
imperative_abstraction.pyshould not be necessary anymore since the query was converted to Rego. However, since there are not specific tests for this query, it was kept and a comment was added. A file similar to the IR was manually created and used during development for testing purposes.opa fmt --rego-v1and doing some small changes to the wrapper. This subject should be discussed soon.