Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Longitudinal Analyses of SAST Tools: A CodeQL Case Study

Code and analysis pipeline for the paper "Longitudinal Analyses of SAST Tools: A CodeQL Case Study" (Jean-Charles Noirot Ferrand, Kyle Domico, Yohan Beugin, Patrick McDaniel — University of Wisconsin–Madison).

Paper: https://arxiv.org/abs/2605.07900

@misc{noirotferrand2026longitudinal,
  title        = {Longitudinal Analyses of SAST Tools: A CodeQL Case Study},
  author       = {Noirot Ferrand, Jean-Charles and Domico, Kyle and Beugin, Yohan and McDaniel, Patrick},
  year         = {2026},
  eprint       = {2605.07900},
  archivePrefix= {arXiv},
  primaryClass = {cs.CR}
}

The study runs 114 versions of CodeQL (v2.7.0–v2.25.2) over the CVEfixes dataset (3,993 CVEs across 1,622 repositories in six languages) and measures how detection effectiveness, actionability, and stability change across versions over time.

This repository contains:

  • src/longitudinal_codeql/ — the measurement framework used to generate the raw results (CodeQL execution over sampled Git commits).
  • conf/ — Hydra configurations for each data-generation run, driven by scripts/main.py.
  • scripts/codeql/ — the analysis and plotting pipeline that turns raw results into the paper's tables and figures.
  • docker/ — per-language container images used to build and analyze projects reproducibly.

Framework overview

longitudinal_codeql is a modular pipeline for measuring source code across states (commits):

Sources → Object Samplers → State Samplers → Pipeline (Measures) → Result Handlers → Output
  • Sources (sources/) fetch objects — here, Git repositories (GitSource, GitHubRepoSource) and tabular inputs (TabularSource).
  • Object samplers (samplers/objects/) choose which objects to analyze (URLSampler, TabularObjectSampler).
  • State samplers (samplers/states/commits/) choose the commits to examine (HashListSampler, SequenceSampler, UniformSampler).
  • Measures (measures/) compute values per state. The study uses the CodeQL measures (measures/sast/codeql.py) and Git measures (measures/git.py).
  • Handlers (pipeline/handlers.py) stream or checkpoint outputs; results are written as JSON and optionally Parquet (storage/).

Each experiment is a Hydra config in conf/; scripts/main.py instantiates and runs it.

Installation

Dev container (recommended)

The .devcontainer/ sets up Python and the project dependencies and mounts the repo at /workspace. Open the folder in VS Code and "Reopen in Container".

Without VS Code:

docker build -f .devcontainer/Dockerfile -t longitudinal-codeql-dev .
docker run -it --rm -v "$(pwd)":/workspace longitudinal-codeql-dev

pip

python -m pip install -e .            # framework only (data generation)
python -m pip install -e ".[full]"    # + storage (DuckDB/Parquet) and plotting, to run the analysis
python -m pip install -e ".[full,dev]"  # + test/lint tooling

Getting the data

The main experiment analyzes the CVEfixes dataset (Bhandari et al., 2021).

1. Obtain CVEfixes

  • Pre-built database (simplest): download the SQLite dump from Zenodo — DOI 10.5281/zenodo.4476563 (v1.0.8 covers CVEs through 2024-07-23). This gives you CVEfixes.db.
  • Build from scratch: follow the collection scripts and setup in the CVEfixes repository (INSTALL.md / REQUIREMENTS.md); this queries the NVD and GitHub and requires the API access described there.

CVEfixes code is MIT-licensed; the dataset is released under CC BY 4.0 — cite it if you use it (see Citation).

2. Produce data/cvefixes.json

conf/codeql/codeql_cvefixes.yaml reads data/cvefixes.json via TabularObjectSampler with group_by_url: false, so the file is a JSON array with one record per CVE fix commit. Required fields:

Field Meaning
repo owner/name on GitHub (the config prepends https://github.com/)
hash the fix commit SHA (the sampler also analyzes its parent, via offsets: [-1, 0])
cve_id e.g. CVE-2023-12345
published_date CVE publication date
programming_language one of cpp, go, java, javascript, python, ruby (used by the filters: in each run)
cwe_id, cwe_name CWE classification

Example record:

[
  {
    "repo": "owner/name",
    "hash": "0a1b2c3d4e5f...",
    "cve_id": "CVE-2023-12345",
    "published_date": "2023-05-01",
    "programming_language": "python",
    "cwe_id": "CWE-79",
    "cwe_name": "Improper Neutralization of Input During Web Page Generation"
  }
]

The following is a template for exporting that file from the CVEfixes SQLite database — check table/column names against your CVEfixes version, and decide how you attribute programming_language (the study filters CVEs by language):

# scripts (adapt to your CVEfixes schema): CVEfixes.db -> data/cvefixes.json
import sqlite3, pandas as pd

con = sqlite3.connect("CVEfixes.db")
df = pd.read_sql_query(
    """
    SELECT  r.repo_url                         AS repo_url,
            f.hash                             AS hash,
            c.cve_id                           AS cve_id,
            c.published_date                   AS published_date,
            r.repo_language                    AS programming_language,
            cc.cwe_id                          AS cwe_id,
            w.cwe_name                         AS cwe_name
    FROM fixes f
    JOIN cve  c  ON f.cve_id = c.cve_id
    JOIN repository r ON f.repo_url = r.repo_url
    LEFT JOIN cwe_classification cc ON c.cve_id = cc.cve_id
    LEFT JOIN cwe w  ON cc.cwe_id = w.cwe_id
    """,
    con,
)
# 'owner/name' — TabularObjectSampler prepends https://github.com/
df["repo"] = df["repo_url"].str.replace(r"^https?://github\.com/", "", regex=True)
df = df[["repo", "hash", "cve_id", "published_date", "programming_language", "cwe_id", "cwe_name"]]
df.to_json("data/cvefixes.json", orient="records", indent=2)

Keep the resulting data/ out of version control (it already is via .gitignore).

Reproducing the study

1. Generate raw results (CodeQL over CVEfixes)

Language-specific builds run inside the images in docker/. Example for Python:

docker build -f docker/Dockerfile.python -t cvefixes-python .
docker run -it --rm -v "$(pwd)":/workspace cvefixes-python \
  python scripts/main.py \
    --config-dir conf \
    --config-name codeql/codeql_cvefixes \
    language=python version=v2.14.0 start_index=0 end_index=100

This writes raw JSON to data/results/longitudinal-codeql/cvefixes/. The data-generation configs in conf/codeql/:

Config Produces
codeql_cvefixes.yaml CodeQL alerts per rule on CVEfixes vulnerable/fix commits (main experiment)
cvefixes_diff.yaml Changed files/lines of each CVE fix commit (locality / precision)
codeql_versions.yaml CodeQL CLI version tags and release dates
codeql_findings.yaml CodeQL findings per rule (general findings run)

2. Build the analysis database

python scripts/codeql/build_db.py \
  --results-dir data/results/longitudinal-codeql/cvefixes \
  --output data/cvefixes.duckdb

3. Run the analysis + plotting pipeline

python scripts/codeql/run_all.py            # prepare → analyse → plot (needs data/cvefixes.duckdb)
python scripts/codeql/run_all.py --build-db  # also (re)build the DB first
python scripts/codeql/run_all.py --only plot # re-run just the plotting stage
  • prepare.py — parse errors, define cohorts, enrich CVE dates, rule attribution.
  • analysis/*.py — soft precision (locality), alert fatigue, suite split, detection changes, lead time, rule modules.
  • plots/*.py — renders the paper figures into figures/codeql/.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages