fix(scan): add query references to check results to enable check-to-query linking in get_scan_results()#2658
Open
hirenkumar-n-dholariya wants to merge 1 commit intosodadata:v3from
Open
Conversation
|
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.



Problem
scan.get_scan_results() returns checks[] and queries[] with no way to link them together. Users storing results in a relational database cannot determine which SQL was executed for a specific check.
Root Cause
Check.get_dict() never included query information in its output, even though the Check class already tracks related queries internally via _get_all_related_queries().
Fix
Add a "queries" field to get_dict() output: "queries": [query.query_name for query in self._get_all_related_queries()]
This exposes the query names so users can cross-reference: check["queries"] -> matches queries[]["name"]
Result
Users can now link checks to their SQL queries:
results = scan.get_scan_results()
query_map = {q["name"]: q for q in results["queries"]}
for check in results["checks"]:
for query_name in check.get("queries", []):
sql = query_map[query_name]["sql"]
Impact
References