Skip to content

ci(repo): the threat-model check, required on every pull request (#244) - #492

Open
eribertocz wants to merge 3 commits into
mainfrom
ci/244-threat-model-check
Open

eribertocz wants to merge 3 commits into
mainfrom
ci/244-threat-model-check

Conversation

@eribertocz

@eribertocz eribertocz commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Closes #244 (PR 2 of 2: the threat-model check; PR 1 #487 merged the model).

Files and purposes

File Change Purpose
.github/workflows/scripts/threat_model.py new The threat-model check (R1–R7), standard library only, fail closed.
.github/workflows/scripts/test_threat_model.py new Its tests: a valid model passes; each of R1–R7 fails with its code, file and line; the repository model passes in under 5 s.
.github/workflows/threat-model.yml new Scoped workflow (changes, model, threat-model aggregate), whole on main.
tools/ci/checks.toml 3 entries appended Registers the three jobs; threat-model is required.
tools/repo/main-ruleset.json 1 context appended threat-model as a required status check.
.github/workflows/ci-alerts.yml, .github/workflows/scripts/ci_alerts.toml 1 trigger and 1 watch appended A failure on main raises the CI alert.
docs/process/engineering.md §8, one row Lists the check.

Shared governance files touched, for coordination with #486: tools/ci/checks.toml, tools/repo/main-ruleset.json, ci-alerts.yml and ci_alerts.toml. All are append-only.

Case matrix

# Case Expected Test
1 The model is valid exit 0 test_a_valid_model_passes
2 Every allowed form of Rule and Verification is used exit 0 test_every_allowed_form_passes
R1 A path, package or contract is missing from the inventory THREAT_MODEL_STALE test_r1_…
R2 An inventory item no longer exists THREAT_MODEL_STALE, with the line test_r2_…
R3 An item names a surface that has no section THREAT_MODEL_INVALID test_r3_…
R4 A surface is missing a STRIDE category THREAT_MODEL_INVALID, with the section line test_r4_…
R5 An empty Rule or Verification, an unknown category, or a duplicate ID THREAT_MODEL_INVALID test_r5_…
R6 A Rule names a heading, ADR or law that does not exist, or is of no allowed form THREAT_MODEL_INVALID test_r6_…
R7 A Verification path is missing, a roadmap ID is unknown, a reason is empty, or the value is of no allowed form THREAT_MODEL_INVALID test_r7_…
R7b n/a: is used on a category that has another row THREAT_MODEL_INVALID test_r7_n_a_…
P The repository model passes in under 5 s exit 0, < 5 s test_the_repository_model_passes_in_under_five_seconds

The tests were written first and failed before the check existed. They now pass: 22 tests (independent Reviewer: APPROVE after 3 passes), and the governance-script suite (125 tests) is OK. The check passes on main in about 0.1 s.

The Owner must do one thing

Update the GitHub ruleset from tools/repo/main-ruleset.json so that threat-model becomes required. Until then, the protection check reports the difference.

Size

About 730 counted lines; it is not split because the check and its tests form one unit. About 280 lines are the check and about 330 are its 22 tests, which prove R1–R7 plus the parser and path guards; a check without its tests cannot land. The rest is workflow and registration wiring, each piece of which is required for the check to run as required.

Laws touched

  • Law 3 (security by design): a new surface without analysis fails CI.
  • A6: the check fails closed when it cannot read a file.

Risk tier

A, because it touches CI workflows. The paths are governed, so the PR is labeled owner-merge.


Generated by Claude Code

threat_model.py (standard library) refuses a stale inventory (R1, R2), a
surface without a section or a STRIDE category (R3, R4), and a row with an
empty, unknown, duplicate, missing or malformed field (R5-R7); scoped
workflow with changes/aggregate, required context, CI alert watch.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MFyANPkiUZYq6rvGD2sFLf
@eribertocz eribertocz added owner-merge Touches governed paths; only the Owner merges type:ci Continuous integration module:repo status:in-review Pull request awaiting verification risk:A labels Nov 15, 2026 — with Claude
Claude Code and others added 2 commits November 15, 2026 09:08
… cannot read (#244)

Reviewer findings 1-5: the OpenAPI reader keeps comments, inline values and
colons in paths and refuses an unreadable key; unmatched table lines, a second
section and a repeated inventory item are refused; a Verification is a test
file or a scenario path inside the repository; tests assert code, line and
reason; references are read once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MFyANPkiUZYq6rvGD2sFLf
)

Re-review: a '..' segment no longer passes the allowed prefixes; the prefix is
tested on the resolved path, and a test directory or a model without an
inventory block is refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MFyANPkiUZYq6rvGD2sFLf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:repo owner-merge Touches governed paths; only the Owner merges risk:A status:in-review Pull request awaiting verification type:ci Continuous integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security(repo): threat model for every new attack surface

1 participant