mirror of
https://github.com/shankar0123/certctl.git
synced 2026-06-07 19:11:30 +00:00
ccda277c18
Two CodeQL runs (commitsd8026d5+4bb7a74) since the initial Option A landing both completed with conclusion=success but failed to dismiss alert #23 (go/request-forgery on scep_probe.go:232). Root cause: the local pack never loaded. The bug was in codeql-config.yml — `packs: { go: ['./'] }` looked plausible (the path is relative to the config file's directory) but the `packs:` field requires pack NAMES, not paths. Discovery of unpublished local packs goes through the codeql-action `init` step's `additional-packs:` input, not through `packs:`. Verified pattern by reading github/vscode-codeql's working .github/codeql/ setup. The supported chain: workflow init step passes additional-packs: <parent-dir> ↓ CodeQL CLI registers each pack under the parent ↓ codeql-config.yml names the pack in `packs: go: [name]` ↓ CodeQL CLI resolves the name → pack on disk ↓ pack's qlpack.yml declares extensionTargets: codeql/go-all ↓ data extension YAML auto-loads, applies the barrier rows Restructure to match this chain: Before After -------- ----- .github/codeql/qlpack.yml .github/codeql/codeql-config.yml .github/codeql/models/ .github/codeql/certctl-models/ request-forgery-sanitizers.model.yml qlpack.yml .github/codeql/codeql-config.yml models/ request-forgery-sanitizers.model.yml The new `.github/codeql/certctl-models/` is the pack directory, named to match `name: shankar0123/certctl-models` in qlpack.yml. Its parent `.github/codeql/` is what additional-packs points at. The action discovers the pack by walking the parent dir, sees the qlpack.yml, registers the name, and `packs:` lookup succeeds. Three concrete changes: - Pack moves from .github/codeql/{qlpack.yml, models/} into the sibling subdirectory .github/codeql/certctl-models/. - codeql-config.yml's packs: directive now uses the pack NAME (`shankar0123/certctl-models`) instead of the broken `./` path. - codeql.yml's Initialize CodeQL step gains `additional-packs: .github/codeql` so the CLI's resolver knows where to find unpublished packs. Belt-and-suspenders correctness fix: the model row's `subtypes` column now uses `False` (Python-style capitalized) instead of `false` to match every shipped CodeQL Go .model.yml convention. SnakeYAML accepts lowercase too — this is a hedge against any strict-format tooling in the path. Why this matters: alert #23 is rated Critical with CWE-918 + CWE-180. The runtime defense is correct (validate-then-pin via ValidateSafeURL + SafeHTTPDialContext), but the analyzer doesn't know it. With the pack actually loading this time, the next CodeQL run will see the barrier and dismiss the alert at source. Same fix implicitly applies to the webhook notifier's outbound client.Do (the second site that uses ValidateSafeURL). Operator: push and watch the next CodeQL run dismiss alert #23. If it doesn't, the next iteration will be on the YAML row's column shape — most likely a one-line tweak, not another redesign.
56 lines
2.9 KiB
YAML
56 lines
2.9 KiB
YAML
# certctl CodeQL model pack — extends the standard Go queries with project-
|
|
# specific data-flow knowledge (sanitizers, sinks, summaries).
|
|
#
|
|
# Why this exists: CodeQL's standard `go/request-forgery` query is a syntactic
|
|
# taint-tracking rule. It traces operator-supplied URLs into HTTP egress sinks
|
|
# (`http.Client.Do`) and reports — but it has no built-in knowledge of
|
|
# certctl's `internal/validation.ValidateSafeURL` SSRF guard. The validator
|
|
# IS a sanitizer (rejects loopback, link-local incl. cloud metadata
|
|
# 169.254.169.254, multicast, broadcast, unspecified, IPv6 link-local;
|
|
# rejects DNS names whose A/AAAA records resolve into any of those ranges)
|
|
# but CodeQL doesn't know that, so the analyzer reports a finding the
|
|
# runtime defense already mitigates.
|
|
#
|
|
# This pack uses Models-as-Data (MaD) extensions to declare the validator as
|
|
# a barrier for the request-forgery query. After this pack is loaded:
|
|
# - The alert at internal/service/scep_probe.go:232 (CodeQL #23) is
|
|
# dismissed at source, not via per-line `// codeql[...]` suppression.
|
|
# - The same model applies to the second site of this shape — webhook
|
|
# notifier's outbound `client.Do` (internal/connector/notifier/webhook/
|
|
# webhook.go) — without per-line annotations.
|
|
# - Future code that flows operator URLs through ValidateSafeURL gets the
|
|
# same treatment automatically.
|
|
#
|
|
# Pack-loading mechanism (post-correction in commit fix-up):
|
|
# - This pack lives at .github/codeql/certctl-models/. Its NAME is the
|
|
# `name:` field below.
|
|
# - .github/workflows/codeql.yml's Initialize CodeQL step passes
|
|
# `additional-packs: .github/codeql` to the action — that's the parent
|
|
# directory the CodeQL CLI's resolver searches for unpublished packs.
|
|
# - .github/codeql/codeql-config.yml then references this pack by NAME
|
|
# in `packs: { go: [shankar0123/certctl-models] }`. The CLI looks the
|
|
# name up against the additional-packs path, finds this qlpack.yml,
|
|
# loads the pack and its data extensions.
|
|
#
|
|
# An earlier draft (commit d8026d5) tried `packs: { go: ['./'] }` in
|
|
# codeql-config.yml, which is the wrong syntax — that field expects pack
|
|
# names, not paths. The pack silently never loaded; alert #23 stayed open
|
|
# across two CodeQL runs (d8026d5 + 4bb7a74). Pack-name + additional-packs
|
|
# is the supported path; verified against the github/vscode-codeql working
|
|
# example.
|
|
#
|
|
# MaD `barrierModel` extension was added for Go in CodeQL 2.25.2 (2026-04-21).
|
|
# `github/codeql-action@v3` (pinned in .github/workflows/codeql.yml) pulls a
|
|
# CLI version >= 2.25.2 by default. If a future analysis fails with
|
|
# "unknown extensible predicate barrierModel", the action's CLI version has
|
|
# regressed below 2.25.2 — pin a newer action version rather than reverting
|
|
# this pack.
|
|
|
|
name: shankar0123/certctl-models
|
|
version: 0.0.1
|
|
library: true
|
|
extensionTargets:
|
|
codeql/go-all: '*'
|
|
dataExtensions:
|
|
- models/*.model.yml
|