codeql
Skill1 starsChanged 9 months agoMITView on GitHub
Run CodeQL static analysis for security vulnerability detection, taint tracking, and data flow analysis. Use when asked to analyze code with CodeQL, create CodeQL databases, write custom QL queries, perform security audits, or set up CodeQL in CI/CD pipelines.
- Installs packages
We split this skill into the rules it gives an agent
2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 11 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 23
No build capability for compiled languages
- Distinctive: line 44
Do NOT use this skill for:
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CodeQL Static Analysis
When to Use CodeQL
Ideal scenarios:
- Source code access with ability to build (for compiled languages)
- Open-source projects or GitHub Advanced Security license
- Need for interprocedural data flow and taint tracking
- Finding complex vulnerabilities requiring AST/CFG analysis
- Comprehensive security audits where analysis time is not critical
Consider Semgrep instead when:
- No build capability for compiled languages
- Licensing constraints
- Need fast, lightweight pattern matching
- Simple, single-file analysis is sufficient
Why Interprocedural Analysis Matters
Simple grep/pattern tools only see one function at a time. Real vulnerabilities often span multiple functions:
HTTP Handler → Input Parser → Business Logic → Database Query
↓ ↓ ↓ ↓
source transforms passes sink (SQL)CodeQL tracks data flow across all these steps. A tainted input in the handler can be traced through 5+ function calls to find where it reaches a dangerous sink.
Pattern-based tools miss this because they can't connect request.param in file A to db.execute(query) in file B.
When NOT to Use
Do NOT use this skill for:
- Projects that cannot be built (CodeQL requires successful compilation for compiled languages)
- Quick pattern searches (use Semgrep or grep for speed)
- Non-security code quality checks (use linters instead)
- Projects without source code access
Environment Check
# Check if CodeQL is installed
command -v codeql >/dev/null 2>&1 && echo "CodeQL: installed" || echo "CodeQL: NOT installed (run install steps below)"Installation
CodeQL CLI
# macOS/Linux (Homebrew)
brew install --cask codeql
# Update
brew upgrade codeqlManual: Download bundle from https://github.com/github/codeql-action/releases
Trail of Bits Queries (Optional)
Install public ToB security queries for additional coverage:
# Download ToB query packs
codeql pack download trailofbits/cpp-queries trailofbits/go-queries
# Verify installation
codeql resolve qlpacks | grep trailofbitsCore Workflow
1. Create Database
codeql database create codeql.db --language=<LANG> [--command='<BUILD>'] --source-root=.| Language | --language= | Build Required |
| Python | python | No |
| JavaScript/TypeScript | javascript | No |
| Go | go | No |
| Ruby | ruby | No |
| Rust | rust | Yes (--command='cargo build') |
| Java/Kotlin | java | Yes (--command='./gradlew build') |
| C/C++ | cpp | Yes (--command='make -j8') |
| C# | csharp | Yes (--command='dotnet build') |
| Swift | swift | Yes (macOS only) |
2. Run Analysis
# List available query packs
codeql resolve qlpacksRun security queries:
# SARIF output (recommended)
codeql database analyze codeql.db \
--format=sarif-latest \
--output=results.sarif \
-- codeql/python-queries:codeql-suites/python-security-extended.qls
# CSV output
codeql database analyze codeql.db \
--format=csv \
--output=results.csv \
-- codeql/javascript-queriesWith Trail of Bits queries (if installed):
codeql database analyze codeql.db \
--format=sarif-latest \
--output=results.sarif \
-- trailofbits/go-queriesWriting Custom Queries
Query Structure
CodeQL uses SQL-like syntax: from Type x where P(x) select f(x)
Basic Template
/**
* @name Find SQL injection vulnerabilities
* @description Identifies potential SQL injection from user input
* @kind path-problem
* @problem.severity error
* @security-severity 9.0
* @precision high
* @id py/sql-injection
* @tags security
* external/cwe/cwe-089
*/
import python
import semmle.python.dataflow.new.DataFlow
import semmle.python.dataflow.new.TaintTracking
module SqlInjectionConfig implements DataFlow::ConfigSig {
predicate isSource(DataFlow::Node source) {
// Define taint sources (user input)
exists(source)
}
predicate isSink(DataFlow::Node sink) {
// Define dangerous sinks (SQL execution)
exists(sink)
}
}
module SqlInjectionFlow = TaintTracking::Global<SqlInjectionConfig>;
from SqlInjectionFlow::PathNode source, SqlInjectionFlow::PathNode sink
where SqlInjectionFlow::flowPath(source, sink)
select sink.getNode(), source, sink, "SQL injection from $@.", source.getNode(), "user input"Query Metadata
| Field | Description | Values |
@kind | Query type | problem, path-problem |
@problem.severity | Issue severity | error, warning, recommendation |
@security-severity | CVSS score | 0.0 - 10.0 |
@precision | Confidence | very-high, high, medium, low |
Key Language Features
// Predicates
predicate isUserInput(DataFlow::Node node) {
exists(Call c | c.getFunc().(Attribute).getName() = "get" and node.asExpr() = c)
}
// Transitive closure: + (one or more), * (zero or more)
node.getASuccessor+()
// Quantification
exists(Variable v | v.getName() = "password")
forall(Call c | c.getTarget().hasName("dangerous") | hasCheck(c))Creating Query Packs
codeql pack init myorg/security-queriesStructure:
myorg-security-queries/
├── qlpack.yml
├── src/
│ └── SqlInjection.ql
└── test/
└── SqlInjectionTest.expectedqlpack.yml:
name: myorg/security-queries
version: 1.0.0
dependencies:
codeql/python-all: "*"CI/CD Integration (GitHub Actions)
name: CodeQL Analysis
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: '0 0 * * 1' # Weekly
jobs:
analyze:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
matrix:
language: ['python', 'javascript']
steps:
- uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: security-extended,security-and-quality
# Add custom queries/packs:
# queries: security-extended,./codeql/custom-queries
# packs: trailofbits/python-queries
- uses: github/codeql-action/autobuild@v3
- uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"Testing Queries
codeql test run test/Test file format:
def vulnerable():
user_input = request.args.get("q") # Source
cursor.execute("SELECT * FROM users WHERE id = " + user_input) # Alert: sql-injection
def safe():
user_input = request.args.get("q")
cursor.execute("SELECT * FROM users WHERE id = ?", (user_input,)) # OKTroubleshooting
| Issue | Solution |
| Database creation fails | Clean build environment, verify build command works independently |
| Slow analysis | Use --threads, narrow query scope, check query complexity |
| Missing results | Check file exclusions, verify source files were parsed |
| Out of memory | Set CODEQL_RAM=48000 environment variable (48GB) |
| CMake source path issues | Adjust --source-root to point to actual source location |
Rationalizations to Reject
| Shortcut | Why It's Wrong |
| "No findings means the code is secure" | CodeQL only finds patterns it has queries for; novel vulnerabilities won't be detected |
| "This code path looks safe" | Complex data flow can hide vulnerabilities across 5+ function calls; trace the full path |
| "Small change, low risk" | Small changes can introduce critical bugs; run full analysis on every change |
| "Tests pass so it's safe" | Tests prove behavior, not absence of vulnerabilities; they test expected paths, not attacker paths |
| "The query didn't flag it" | Default query suites don't cover everything; check if custom queries are needed for your domain |
Resources
- Docs: https://codeql.github.com/docs/
- Query Help: https://codeql.github.com/codeql-query-help/
- Security Lab: https://securitylab.github.com/
- Trail of Bits Queries: https://github.com/trailofbits/codeql-queries
- VSCode Extension: "CodeQL" for query development
Other versions12 projects use a version of this.
Word for word · 1
- Samueladewole/claude-skills★ 0100% same
Edited · 0
None found.
Wrote their own version · 11
- github/awesome-copilot★ 41ksame name
- elastic/kibana★ 21ksame name
- waybarrios/opencode-power-pack★ 547same name
- ulises-jeremias/agent-toolkit★ 19same name
- Cogni-AI-OU/cogni-ai-agent-skills★ 4same name
- Adhamxon/claude-code-skills★ 2same name
- Lu1sDV/skillsmd★ 2same name
- romaintoso78/claude-skills★ 1same name
- davidanthonyn/claude-skills★ 0same name
- ReaperOAK/ForgeOS★ 0same name
1 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository125 other files it gives its agents.
- skills/vercel-composition-patterns/AGENTS.mdAGENTS.md
- skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- skills/vercel-react-native-skills/AGENTS.mdAGENTS.md
- address-sanitizerSkill
- aflppSkill
- algorand-vulnerability-scannerSkill
- algorithmic-artSkill
- ask-questions-if-underspecifiedSkill
- atherisSkill
- audit-context-buildingSkill
- audit-prep-assistantSkill
- autonomous-skillSkill
- aws-skillsSkill
- better-authSkill
- brainstormingSkill
- brand-guidelinesSkill
- burpsuite-project-parserSkill
- cairo-vulnerability-scannerSkill
- canvas-designSkill
- cargo-fuzzSkill
- changelog-generatorSkill
- claude-in-chrome-troubleshootingSkill
- cloudflare-skillsSkill
- code-maturity-assessorSkill
- codex-skillSkill
- constant-time-analysisSkill
- constant-time-testingSkill
- cosmos-vulnerability-scannerSkill
- coverage-analysisSkill
- d3js-visualizationSkill
- db-resetSkill
- deep-researchSkill
- deploySkill
- dev-startSkill
- differential-reviewSkill
- dispatching-parallel-agentsSkill
- doc-coauthoringSkill
- doc-generateSkill
- documentationSkill
- docxSkill
- dwarf-expertSkill
- entry-point-analyzerSkill
- env-checkSkill
- executing-plansSkill
- expo-skillsSkill
- finishing-a-development-branchSkill
- firebase-apk-scannerSkill
- fix-reviewSkill
- frontend-designSkill
- fuzzing-dictionarySkill
- fuzzing-obstaclesSkill
- git-automationSkill
- google-design-mdSkill
- guidelines-advisorSkill
- harness-writingSkill
- health-checkSkill
- huggingface-skillsSkill
- insecure-defaultsSkill
- internal-commsSkill
- interpreting-culture-indexSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

