Repository navigation
feat(skills): add OWASP Threat Dragon export to security planning - #3159
Open
Will Velida (willvelida) wants to merge 8 commits into
Open
Will Velida (willvelida) wants to merge 8 commits into
Will Velida (willvelida) wants to merge 8 commits into
Conversation
- add Threat Dragon v2.6.2 generator and validator with vendored schema - wire Security Planner and Reviewer via a confirm-before-final instruction - add optional spec fields, reference, tests, and evals - keep vendored schema and golden fixtures safe from CRLF conversion 🐉 - Generated by Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔀 - Generated by Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…onflicts 🔀 - Generated by Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3159 +/- ##
==========================================
+ Coverage 85.01% 85.47% +0.45%
==========================================
Files 189 111 -78
Lines 37947 20884 -17063
Branches 264 63 -201
==========================================
- Hits 32260 17850 -14410
+ Misses 5605 3023 -2582
+ Partials 82 11 -71
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
- keep external Jest fixtures out of local Node discovery - shorten eval grader names and preserve lineage - remove unreachable error handler and add regressions 🛠️ - Generated by Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- declare mixed licences and inventory the vendored schema - load the confirmation contract for direct skill use - cover the direct-use gate with a conformance stimulus 📋 - Generated by Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- regenerate reference counts from the merged catalog - preserve upstream registry changes and Threat Dragon coverage 🔀 - Generated by Copilot Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Will Velida (willvelida)
marked this pull request as ready for review
November 10, 2026 22:44
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Adds OWASP Threat Dragon v2.6.2 export to the
security-planningskill as a sibling of the existing TM7 (Microsoft Threat Modeling Tool) export. The same YAML threat-model spec that produces a.tm7file can now produce a Threat Dragon JSON model that opens directly in Threat Dragon. The design mirrors how the Security Planner already handles MTMT/TM7.Generator and validator
generate_threat_dragon.pyreusesload_spec,resolve_profile, andbuild_tm7_payloadfromgenerate_tm7.py, the same waygenerate_markdown.pydoes. Spec validation, trust-zone hierarchy, threat target resolution, and the deterministic layout come from TM7, so each representation becomes one Threat Dragon diagram drawn like its TM7 surface.validate_threat_dragon.pychecks any model against a vendored, hash-pinned copy of the upstream v2.6.2 schema and the graph rules, with no new runtime dependency. Output is validated in a sibling temp file before an atomic replace. Exit codes follow the TM7 scripts: 0, 1 (invalid model), 2.trust_boundary_lineelement. Withthreat_generation_enabled: true, abuse-case threats are left out (they have no STRIDE type), and duplicate generated threats are emitted once.Spec, agents, and instruction
owner,out_of_scope,bidirectional,public_network,encrypted,severity,likelihood,impact,risk) plus a namespacedexport_options.threat_dragonblock. TM7 ignores them; a test proves TM7 output is byte-identical with them present.threat-dragon-generation-workflow.instructions.md, mirroring the TM7 authorship-confirmation contract: a generated model stays unconfirmed, is not recorded as a phase artifact, and is not handed off until the user explicitly confirms. The TM7 instruction is unchanged.## Threat Dragon Generation Workflowsection beside their TM7 section. There is no new prompt or standalone agent.Docs, security model, and evals
references/threat-dragon-generation.md. Updates toSKILL.md, the skillREADME.md,SECURITY.md(new parse surface, controls, and a Low residual-risk row), the repository security-model registry row, the threat-models README, and the generated reference page.instructions.eval.yamlandskill-behavior.eval.yaml..gitattributeskeeps the hash-pinned vendored schema byte-exact and the Threat Dragon golden fixtures LF on Windows checkouts. Without it, the hash and golden tests fail undercore.autocrlf=true..cspell/general-technical.txtgainsantv,dasharray,interactor, andthreatmodel.Related Issue(s)
Type of Change
Select all that apply:
Code & Documentation:
Infrastructure & Configuration:
AI Artifacts:
hve-builderand addressed all actionable findings.github/instructions/*.instructions.md).github/prompts/*.prompt.md).github/agents/*.agent.md).github/skills/*/SKILL.md).github/hooks/*/*.json)evals/)Other:
.ps1,.sh,.py)Sample Prompts (for AI Artifact Contributions)
User Request:
"Generate an OWASP Threat Dragon model for this security plan."
Execution Flow:
references/threat-dragon-generation.mdand halts if it is missing.ownerorbidirectionalrather than inventing values.generate_threat_dragon.py, which validates the model before writing it.Output Artifacts:
A Threat Dragon v2.6.2 JSON model, written to a caller-chosen path (default
out.threat-dragon.json) and not committed. Abbreviated example:{ "version": "2.6.2", "summary": { "title": "Threat Dragon fixture commerce", "owner": "Platform security", "id": "f84c7e8c-…" }, "detail": { "diagrams": [ { "id": 0, "title": "Commerce context", "diagramType": "STRIDE", "version": "2.6.2", "cells": ["…"] } ], "diagramTop": 2, "threatTop": 3 } }Success Indicators:
validate_threat_dragon.py <model.json>exits 0.HVE-Core contextblock.For detailed contribution requirements, see:
Testing
Commands run locally on Windows, with results:
pytest(fullsecurity-planningsuite, via the skill's uv environment): 616 passed, 2 skipped (the opt-in loader test and a Windows TMT probe).THREAT_DRAGON_LOADER=1 pytest tests/test_threat_dragon_loader.py): passed. It runs the golden model through real Threat Dragon v2.6.2 code at commit8c0edb2: v2 detection, upstream schema check, theTHREATMODEL_SELECTEDmutation, and labels, strokes, and markers read back through Threat Dragon's X6 shapes.ruff check .andruff format --checkon the skill: passed.npm run validate:skills,lint:frontmatter,lint:ai-artifacts,lint:md,lint:json,lint:yaml,lint:artifact-portability,lint:asset-docs,lint:eval-grader-lineage,lint:links,validate:copyright: passed.npm run plugin:sync(no change;plugin.jsonalready current) andnpm run plugin:validate: passed.npm run docs:generateproduced the new reference page and index updates.Format-MarkdownTables.ps1 -Check): passed.cspellon changed files: no new findings. Remaining hits are on pre-existing lines.git diff --check: clean apart from the vendored upstream schema and licence, which are kept byte-identical (schema git blobc8fab1c8…matches upstream).core.autocrlf=truekeeps the vendored schema SHA-256 and the golden fixture's LF endings intact.docs/planning/threat-models/hve-core-comprehensive.yamland opened them in Threat Dragon v2.6.2 desktop. Labels, red open-threat outlines, dashed out-of-scope services, and the owner field render as expected.hve-builderreviewer pass on the instruction and agent sections returned no findings, and an RPI review finding (abuse-case threats with threat generation enabled) was fixed and covered by a test.Validation history and latest update for published head
7c633523(2026-11-09):uv run --no-sync pytest -q -rsfrom the security-planning skill root: 616 passed, 2 skipped before the CI repairs. The skips were the opt-in native loader and an unavailable Windows directory-link operation.uv run --no-sync pytest tests/test_generate_threat_dragon.py tests/test_validate_threat_dragon.py tests/test_threat_dragon_loader.py -q -rs: 41 passed, 1 opt-in native-loader test skipped after the CI repairs. The native loader and manual desktop checks reported above were not rerun during these repairs.uv run --no-sync ruff check .anduv run --no-sync ruff format --check .from the skill root: passed after the repairs.pwsh -File scripts/evals/Test-EvalSpec.ps1 -Root evals/behavior-conformance -OutputPath logs/pr-3159-eval-spec-validation.json: both complete eval specs passed; no failures.npm run lint:md-links -- -ChangedFilesOnly -BaseBranch upstream/main: passed. Internal links were checked repository-wide; external URLs were checked only in changed Markdown files.npm run validate:local: attempted, not passed. ShellCheck 0.11.0 is now installed, and validation progressed through workflow, JSON, and link-language checks. The full external-link check reported website access challenges on unchanged files; the strict aggregate remains incomplete. No internal-link failures were reported.npm run validate:docs: passed after documentation dependencies were restored. ESLint, label-registry consistency, TypeScript, all 15 Jest suites / 132 tests, 13 Mermaid tests, and accessibility metadata checks for 65 Mermaid diagrams passed. An initial child-process timeout did not recur after an isolated test and full-suite retry.npm run spell-check -- --no-progress: passed, 868 files checked and zero issues. Two ignored, untracked legacy extension README outputs were moved to a verified local backup; no tracked files, dictionaries, or ignore rules were changed.npm run lint:models,npm run lint:asset-docs,npm run lint:extension-artifact-naming,npm run lint:cold-start, andnpm run lint:eval-grader-lineage: passed. Asset documentation validation reported 34 existing placeholder warnings and no errors.hve-builderreview covered the changed agents, instruction, skill, bundled reference, and CI repairs. Two subsequent findings were resolved in7c633523: mixed-licence attribution and explicit confirmation-contract loading for direct skill invocation. The scoped closure review passed, with frontmatter, skill structure, packaging, generated docs, eval schemas, grader lineage, and static grader checks passing. The HVE Builder and AI-artifact verification checkboxes below remain for human confirmation.generate_threat_dragon.pyand checked withvalidate_threat_dragon.py; both commands exited 0, and the JSON matched the golden fixture byte-for-byte. The user explicitly confirmed the specification and output for the local test.Hosted checks for
7c633523: 145 passed and 9 skipped, with no failing or pending checks at the time of this update. GitHub now reports conflicts against the current base branch; the PR remains a draft and requires review. Model-backed eval lanes were not run locally. Repository-widenpm run test:pyandnpm run lint:pywere not completed; the skill-scoped results above are not full-repository passes.Checklist
Required Checks
AI Artifact Contributions
hve-builderreview mode to review contributionhve-builderreviewRequired Local Checks
The following local-safe validation commands must pass before merging:
npm run validate:localnpm run validate:docsnpm run spell-checknpm run lint:md-linksSecurity Considerations
No runtime dependency is added: the validator implements the schema keywords it needs in-module. The vendored schema is Apache-2.0 and ships with its licence, a third-party notice, and a provenance record (upstream commit, git blob SHA, SHA-256, and size). The generator and validator make no network calls. Reads are size-bounded, and writes go through a validated temp file and an atomic replace. The opt-in loader test is the only code that reaches the network; it clones the pinned Threat Dragon commit and runs
npm ciin a temporary directory, and only when explicitly enabled.Additional Notes
.tm7files.security-planninggenerators (generate_tm7.py,generate_markdown.py) they import from.trust_boundary_lineelements fail closed today. Mapping them to Threat Dragon'strust-boundary-curveneeds line geometry TM7 does not produce.