fix(scan): add query references to check results to enable check-to-query linking in get_scan_results()#2658
Conversation
|
|
Hi @Niels-b @bmarinovic @tomassatka I have submitted this fix for issue #2475 where get_scan_results() returns checks[] and queries[] with no way to link them together. The fix adds a "queries" field to Check.get_dict() output using the already existing _get_all_related_queries() method, so users can cross-reference checks with their SQL queries like: check["queries"] -> matches queries[]["name"] No breaking change - adds a new field only. Could someone please review when you get a chance? Happy to make any |
|
I hope you're doing well! I wanted to gently follow up on this PR which addresses the check-to-query linking request in issue #2475. The fix is a single line addition to Check.get_dict() using the already existing _get_all_related_queries() method - no breaking I completely understand you have a lot on your plate; whenever you get a moment, your quick review comment/approval on the approach would be greatly appreciated! Sincerely appreciate your time and approval on this PR. |
|
Hi @bmarinovic @tomassatka @Niels-b Could you please review PR #2658 and give your approval/feedback to proceed. |



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