Auto-download CodeQL query packs before analysis#38
Auto-download CodeQL query packs before analysis#38AndrewMohawk wants to merge 1 commit intogadievron:mainfrom
Conversation
Fixes "Query pack cannot be found" errors by automatically downloading required query packs before running analysis. Changes: - Add _ensure_pack_downloaded() method to QueryRunner - Automatically downloads packs like codeql/javascript-queries - Caches downloaded packs to avoid redundant downloads - Extracts pack name from suite reference (e.g., codeql/javascript-queries:...) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
| # Ensure query pack is downloaded (extract pack name from suite reference) | ||
| if ":" in suite_name: | ||
| pack_name = suite_name.split(":")[0] | ||
| self._ensure_pack_downloaded(pack_name) |
There was a problem hiding this comment.
I guess we need to add an if statement here to ascertain if the pack was actually downloaded, if not fail and alert and not just continue
danielcuthbert
left a comment
There was a problem hiding this comment.
this is a good first stab and yes, we do need to download the suites and packs. Currently they should live in engine/codeql/suites but that is empty. This PR calls run_suite() when the workflow is already underway, and if it fails to download, will still run. What I think is a better approach is we check to see if packs exist before database creation and analysis, if not pull them down and validate and then go from there.
we could add this into packages/codeql/querty_runner.py
During testing, I set CODEQL_QUERIES env var and that was wrong
so if we could move this earlier in the workflow, that would be better imho
Summary
_ensure_pack_downloaded()method to QueryRunnerProblem
When running CodeQL analysis, the query packs need to be downloaded first:
Solution
Automatically download query packs before analysis by extracting the pack name from the suite reference and calling
codeql pack download.Test plan
🤖 Generated with Claude Code