Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ All notable changes to this project are documented here, following

## [Unreleased]

## [0.3.3] - 2026-11-04

### Fixed

- **CodeQL keeps its compiled queries between runs.** Its cache defaulted to
`~/.codeql`, which is `/tmp` in the image and discarded with the container,
so every run compiled the whole query suite again. `--common-caches` now
points at `/cache/codeql-common` on the cache volume. Measured on trentina
(same image, same limits as the hook): analysis 132s cold, 46s warm; the
whole check 166s to 92s. Compiling had been 1m32s to 3m13s of every push.

## [0.3.2] - 2026-11-04

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ LABEL description="Every CrunchTools Python SDLC check in one image: ruff, mypy,
LABEL org.opencontainers.image.source="https://github.com/crunchtools/python-sdlc"
LABEL org.opencontainers.image.description="Every CrunchTools Python SDLC check in one image."
LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later"
LABEL version="0.3.2"
LABEL version="0.3.3"

# What the image carries, readable without starting anything. `sdlc versions`
# prints these and a consuming repo's CI pins them.
Expand Down
2 changes: 1 addition & 1 deletion IMAGE_TAG
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.2
0.3.3
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ default_install_hook_types: [pre-commit, pre-push]

repos:
- repo: https://github.com/crunchtools/python-sdlc
rev: v0.3.2
rev: v0.3.3
hooks:
- id: sdlc-commit
- id: sdlc-push
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

[project]
name = "python-sdlc"
version = "0.3.2"
version = "0.3.3"
description = "One container image and one script for every CrunchTools Python SDLC check"
requires-python = ">=3.14"
license = "AGPL-3.0-or-later"
Expand Down
11 changes: 11 additions & 0 deletions sdlc
Original file line number Diff line number Diff line change
Expand Up @@ -894,13 +894,22 @@ def t_codeql(s: dict) -> int:
if config != default_config and not (REPO / config).is_file():
cannot(f"codeql config {config} does not exist")
db = CACHE / "codeql" / project_name()
# Compiled query plans, kept between runs. CodeQL's default is ~/.codeql,
# which is /tmp in this image and gone when the container exits, so every
# run compiled all of security-extended again: 1m32s-3m13s of trentina's
# analysis, against 46s for the whole analysis on a warm cache. Shared by
# every repo on the volume, which is the point -- the standard packs are the
# same bytes everywhere -- and keyed by CodeQL on each query's own hash, so
# a changed query recompiles and nothing stale is reused.
caches = CACHE / "codeql-common"
sarif = Path("/tmp/codeql-results.sarif")
shutil.rmtree(db, ignore_errors=True)
# An unwritable cache is a 2, not a traceback and not a 1. The same bug in
# `validate` surfaced as a PermissionError stack trace with an exit status
# that claimed a finding.
try:
db.parent.mkdir(parents=True, exist_ok=True)
caches.mkdir(parents=True, exist_ok=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LOW (General Review): The new cache-directory creation is covered by an error handler that reports only a failure to create the database directory. If creating caches fails, the message points to the wrong path and obscures the actual cause.

Suggestion: Report which directory creation failed, or use a generic message that includes both db.parent and caches.

Evidence:

caches.mkdir(parents=True, exist_ok=True)
    except OSError as exc:
        cannot(f"cannot create the CodeQL database directory {db.parent}: {exc}")

except OSError as exc:
cannot(f"cannot create the CodeQL database directory {db.parent}: {exc}")

Expand All @@ -912,6 +921,7 @@ def t_codeql(s: dict) -> int:
"--language=python",
"--source-root=.",
"--overwrite",
f"--common-caches={caches}",
]
analyze = [
"codeql",
Expand All @@ -921,6 +931,7 @@ def t_codeql(s: dict) -> int:
"--format=sarif-latest",
f"--output={sarif}",
f"--threads={os.environ.get('SDLC_JOBS', '0')}",
f"--common-caches={caches}",
]

# `--codescanning-config` is NOT a CLI flag in 2.27.4, on either subcommand.
Expand Down
Loading