Skip to content

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 into
sodadata:v3from
hirenkumar-n-dholariya:patch-3
Open

fix(scan): add query references to check results to enable check-to-query linking in get_scan_results()#2658
hirenkumar-n-dholariya wants to merge 1 commit into
sodadata:v3from
hirenkumar-n-dholariya:patch-3

Conversation

@hirenkumar-n-dholariya
Copy link
Copy Markdown

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

  • No breaking change — adds a new field, removes nothing
  • Works for all check types via existing _get_all_related_queries()

References

@sonarqubecloud
Copy link
Copy Markdown

@hirenkumar-n-dholariya
Copy link
Copy Markdown
Author

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
changes based on feedback. Thank you!

@hirenkumar-n-dholariya
Copy link
Copy Markdown
Author

Hi @bmarinovic @Niels-b

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
changes at all.

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.

@hirenkumar-n-dholariya
Copy link
Copy Markdown
Author

Hi @bmarinovic @tomassatka @Niels-b
Hope you are doing well!

Could you please review PR #2658 and give your approval/feedback to proceed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant