Skip to content
Back to skills

Codeql

ASecurity

SAST for kio-qa-security: Semgrep scans and CodeQL taint tracking with merged SARIF. Use for security audits, pre-merge scans of risky diffs, or 'scan this repo for vulnerabilities'. The review process itself is in ../security-review.md.

  • 5 stars
  • 0 votes
  • 1 copy
  • 3 views
  • Added November 22, 2026
developmentgoshellbashdatabasesecurity

Works with

  • cli

Security analysis

A100/100

Pro scans all 20 files and shows the line behind each finding

Scanned November 23, 2026

npx -y skills add toanpham2111/kio-agent-system --skill codeql --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Codeql?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Codeql
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/toanpham2111-codeql/badge)](https://www.skillsdirectory.com/skills/toanpham2111-codeql)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: codeql-semgrep-review
description: "SAST for kio-qa-security: Semgrep scans and CodeQL taint tracking with merged SARIF. Use for security audits, pre-merge scans of risky diffs, or 'scan this repo for vulnerabilities'. The review process itself is in ../security-review.md."
metadata:
  author: Trail of Bits (CodeQL/Semgrep workflows, scripts, references)
  maintainer: Kio System
---

# 🛡️ Static Analysis (Semgrep + CodeQL)

> Adapted from Trail of Bits `skills` (static-analysis). This whole folder is licensed **CC BY-SA 4.0**; see [LICENSE](LICENSE). Kio changes are listed there.

`{baseDir}` below is this folder: `<kio-qa-security install dir>/references/codeql` (for example `~/.claude/skills/kio-qa-security/references/codeql`). Substitute it literally in every command.

## When to use what

| Need | Go to |
|---|---|
| Review a feature or PR before merge | [`../security-review.md`](../security-review.md) (two-stage review, 5-layer checklist, sign-off) |
| Fast pattern scan, many languages, no build | Semgrep: Follow "Step 1: Resolve Output Directory, Detect Languages and Pro Availability" in workflows/scan-workflow.md |
| Deep interprocedural taint tracking | CodeQL: [Database Discovery](#database-discovery), then Follow "Step 1: Detect Language and Configure" in workflows/build-database.md, then workflows/run-analysis.md |
| Model a custom framework's sources/sinks | workflows/create-data-extensions.md |
| Merge and triage results | `{baseDir}/scripts/merge_sarif.py`, references/sarif-processing.md |

Rule references: references/rulesets.md, references/ruleset-catalog.md (Trail of Bits, 0xdea, Decurity and community packs), references/scan-modes.md ("important only" vs "run all"), references/threat-models.md.

---

## Each Bash call is a fresh shell

Every fenced block in this skill and its workflows runs as **its own Bash invocation**. Nothing set in one block exists in the next:

- **Variables and arrays** (`OUTPUT_DIR`, `DB_NAME`, `CODEQL_LANG`, `FOUND_DBS`) must be set again, or re-derived, in the block that uses them. An array built in an earlier block is empty in a later one, and an empty `FOUND_DBS` reads as "no database".
- **Functions** from `source "{baseDir}/scripts/build_log.sh"` (`log_step`, `run_logged`, …) must be sourced again in each block; a missing function exits 127, which the build ladder reads as a failed method.
- **`PATH` changes** (for example adding CodeQL) do not carry over; check for `codeql` in the block that needs it.
- Read script output with command substitution (`OUT=$(script)`), not `done < <(script)`: a process substitution discards the exit status.

## Database Discovery

Before building a CodeQL database, look for existing ones. Discovery and selection share one block so the array never crosses a shell boundary:

```bash
OUTPUT_DIR="${OUTPUT_DIR:-.}"
if ! DB_LIST=$("{baseDir}/scripts/find_databases.sh" "$OUTPUT_DIR" .); then
  echo "ERROR: database discovery failed — see the message above" >&2
  exit 1
fi

FOUND_DBS=()
while IFS= read -r db; do
  [ -n "$db" ] || continue
  FOUND_DBS+=("$db")
done <<<"$DB_LIST"

echo "Found ${#FOUND_DBS[@]} CodeQL database(s):"
for db in "${FOUND_DBS[@]}"; do
  echo "  - $db"
done
```

- **0 found** → build one: Follow "Step 1: Detect Language and Configure" in workflows/build-database.md.
- **1 found** → set `DB_NAME` to it and run workflows/run-analysis.md.
- **Several** → ask the user which one, then set `DB_NAME` in the analysis block.

`find_databases.sh` exits 2 when `codeql` is not on this shell's `PATH`; report that instead of rebuilding.

---

## Semgrep quick start

```bash
# Never send telemetry from a client's code
semgrep scan --config auto --metrics=off --error --sarif --output semgrep-results.sarif
```

For curated packs, approval gates and parallel runs use workflows/scan-workflow.md; merge outputs with `{baseDir}/scripts/merge_sarif.py`.

Files in this skill

  • SKILL.md5.8 KB
  • references/build-fixes.md3.2 KB
  • references/code-reviewer.md5.5 KB
  • references/diagnostic-query-templates.md9.5 KB
  • references/extension-yaml-format.md7.4 KB
  • references/important-only-suite.md5.1 KB
  • references/language-details.md5.7 KB
  • references/macos-arm64e-workaround.md7.3 KB
  • references/performance-tuning.md2.8 KB
  • references/quality-assessment.md7.8 KB
  • references/ruleset-catalog.md2.1 KB
  • references/rulesets.md7.5 KB
  • references/run-all-suite.md5.4 KB
  • references/sarif-processing.md3 KB
  • references/scan-modes.md8.5 KB
  • references/threat-models.md2.7 KB
  • scripts/build_log.sh2.1 KB
  • scripts/check_db_quality.py14.7 KB
  • scripts/find_databases.sh2.5 KB
  • scripts/generate_suite.sh3.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.