fix: globalVariable upsertData illogic causes false negative in detection#64
Merged
jietian-sts merged 1 commit intoantgroup:mainfrom Aug 13, 2025
Merged
Conversation
Contributor
|
Important Installation incomplete: to start using Gemini Code Assist, please ask the organization owner(s) to visit the Gemini Code Assist Admin Console and sign the Terms of Services. |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR resolves a JSON double-encoding issue by parsing the global variable data string before calling opaRepository.upsertData, ensuring valid JSON objects are stored and eliminating malformed data and false detection negatives. Sequence diagram for global variable upsertData JSON handlingsequenceDiagram
participant RuleScanContext
participant RuleAgg
participant GlobalVariable
participant OpaRepository
RuleScanContext->>RuleAgg: getGlobalVariables()
loop for each GlobalVariable
RuleScanContext->>GlobalVariable: getPath()
RuleScanContext->>GlobalVariable: getData()
RuleScanContext->>RuleScanContext: JSON.parse(globalVariable.getData())
RuleScanContext->>OpaRepository: upsertData(path, parsedData)
end
Class diagram for RuleScanContext and OpaRepository interactionclassDiagram
class RuleScanContext {
- opaRepository: OpaRepository
load(ruleAgg: RuleAgg)
}
class OpaRepository {
upsertData(path: String, data: Object)
createOrUpdatePolicy(regoPath: String, regoPolicy: String)
}
class GlobalVariable {
getPath(): String
getData(): String
}
class RuleAgg {
getRegoPath(): String
getRegoPolicy(): String
getGlobalVariables(): List~GlobalVariable~
}
RuleScanContext --> OpaRepository
RuleScanContext --> RuleAgg
RuleAgg --> GlobalVariable
GlobalVariable <.. RuleScanContext : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey @Center-Sun - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Collaborator
|
lgtm |
jietian-sts
approved these changes
Aug 13, 2025
jietian-sts
approved these changes
Aug 13, 2025
jietian-sts
approved these changes
Aug 13, 2025
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.
Thank you for your contribution to CloudRec!
What About:
java)go)opa)Description:
This PR fixes a JSON double-encoding issue in the RuleScanContext where global variable data was being incorrectly serialized, causing data corruption. And cause detection failure for rules that rely on global variables during scanByRule and scanByGroup operations
Issue Details
{"key": "value"}"{\"key\": \"value\"}""\"{\\\"key\\\": \\\"value\\\"}\""(double-escaped)Summary by Sourcery
Bug Fixes: