CodeQL CLI
$ codeql Official Low RiskGitHub's official CodeQL CLI compiles codebases into relational AST/dataflow databases (database create) and runs QL security or structural queries (database analyze, query run). Findings export cleanly as SARIF JSON (--format=sarif-latest) or decoded JSON (bqrs decode --format=json).
brew install codeql Local codeql database create and analyze --format=sarif-latest run heavy multi-minute static analysis directly on local builds.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Outputs structured SARIF JSON (--format=sarif-latest) and bqrs decode --format=json headlessly, though multi-step DB creation and query packs add workflow complexity.
- Supports
--format=sarif-latest,bqrs decode --format=json,--threads, and--ram - Requires building a database before querying
Local analysis does not mutate source files (database create writes to an isolated DB directory); github upload-results requires explicit invocation and GITHUB_TOKEN.
- Source tree remains untouched during DB creation and analysis
--overwritedeletes and replaces an existing DB directory
Large release bundle with embedded JVM via brew install codeql or GitHub releases; compiled languages (C/C++/Java/Go) require replicating full build commands.
- Heavy binary distribution + build-tracer requirement for compiled languages
Unmatched interprocedural taint-tracking and semantic dataflow analysis far beyond regex or single-file AST tools.
- Whole-program call-graph and dataflow queries
Official GitHub security analysis engine with frequent releases and curated standard query packs.
- Official GitHub product (
github/codeql)
Extensive GitHub Docs CLI reference, QL language guide, and --help command tree.
- Comprehensive official CodeQL CLI reference
Security, Auth & Guardrails
No credentials needed for local analysis; codeql github upload-results uses GITHUB_TOKEN or --github-auth-stdin.
Free for OSI open-source repos and academic research; commercial private-repo automation requires GitHub Advanced Security.
# CodeQL CLI Agent Rules - Always export analysis with `--format=sarif-latest` or `bqrs decode --format=json` instead of parsing terminal tables. - Check CodeQL licensing before running automated CI scans on private commercial repositories; avoid `--overwrite` unless rebuilding a stale DB.
Agent-Ready Command Recipes
Safe Read-Only Queries
codeql database analyze ./codeql-db --format=sarif-latest --output=results.sarif codeql/javascript-queries
Runs a standard CodeQL query pack against ./codeql-db and writes JSON-structured SARIF results.
codeql bqrs decode --format=json --output=results.json -- results.bqrs
Converts binary .bqrs results from codeql query run into structured JSON.
Controlled Writes & Previews
codeql database create ./codeql-db --language=python --source-root=.
Creates a local relational AST/dataflow database in ./codeql-db without modifying source files.
Strengths for Agents
- + Full interprocedural AST and taint-flow analysis exported in standard SARIF JSON.
- +
bqrs decode --format=jsonturns custom QL queries into clean JSON payloads.
Caveats & Pitfalls
- ! Commercial automation on closed-source repositories requires a GitHub Advanced Security license.
- ! Database creation for compiled languages is slow and requires a clean build command (
--command).