Skip to content

feat(threats): allow editing threat titles, keep category rule-owned - #77

Merged
Hacks4Snacks merged 1 commit into
mainfrom
hacks4snacks/threattitle
Jul 27, 2026
Merged

feat(threats): allow editing threat titles, keep category rule-owned#77
Hacks4Snacks merged 1 commit into
mainfrom
hacks4snacks/threattitle

Conversation

@Hacks4Snacks

Copy link
Copy Markdown
Owner

feat(threats): allow editing threat titles, keep category rule-owned

What changed

tmforge threats --edit and the Studio threats panel can now set a threat's
title. --title works on any threat; --category is accepted only on manually
authored threats and is refused with an explanation on generated ones.

  • CLI: --title / --category on threats --edit
  • MCP: title / category params on edit_threat
  • Studio: title input; category select disabled on generated threats, with
    inline text saying why
  • Clearing a title on a generated threat restores the rule's original wording
  • Clearing a title on a manual threat is refused (nothing to fall back to)

Why

Rule wording is precise about a class of problem, not about your system.
Reviewers were rewording threats outside the tool and losing the edit on the
next run (THR-001).

Design note: title vs category

These sit on opposite sides of an ownership line, deliberately.

  • Title is judgement — author-owned. The rule still fires, the finding id is
    unchanged, and the edit is reversible.
  • Category is detection — rule-owned. Editing it on a generated threat is
    refused, not ignored, in the CLI, the authoring facade, and the UI alike.
    Silently dropping it would leave an author believing they had recorded
    something.

How to test

dotnet build dirs.proj -p:Platform=x64 -p:BuildStudio=false
dotnet test  test/dirs.proj -p:Platform=x64 -p:BuildStudio=false

Manual, against examples/webshop.tm7:

tmforge list threats  <model>                      # pick a generated threat id
tmforge threats <model> --edit <id> --title "Audit log can be tampered with"
tmforge threats <model> --write                    # title survives regeneration
tmforge convert <model> out.json && tmforge convert out.json rt.tm7
tmforge list threats rt.tm7                        # title survives round trip
tmforge threats <model> --edit <id> --category Tampering   # refused, exit 1
tmforge threats <model> --edit <id> --title ""     # restores the rule wording

Risk

GeneratedDefaultTitle is persisted per generated threat, which roughly doubles
per-threat title bytes (~5% file growth on a 76-threat model). Accepted for
parity with the existing priority path and because it is what makes an
externally-edited title survive.

@Hacks4Snacks Hacks4Snacks linked an issue Jul 27, 2026 that may be closed by this pull request
5 tasks
@Hacks4Snacks
Hacks4Snacks merged commit 6183998 into main Jul 27, 2026
10 checks passed
@Hacks4Snacks
Hacks4Snacks deleted the hacks4snacks/threattitle branch July 27, 2026 19:50
This was referenced Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[THR-001] Threat title/category editing

1 participant