Skip to content

fix(navlayers): expand subtechniques properly during SVG export - #255

Open
emrecoskunz wants to merge 1 commit into
mitre-attack:mainfrom
emrecoskunz:gemini/fix/mitreattack-169
Open

emrecoskunz wants to merge 1 commit into
mitre-attack:mainfrom
emrecoskunz:gemini/fix/mitreattack-169

Conversation

@emrecoskunz

Copy link
Copy Markdown

Fixes #169

Summary

Fixes subtechnique expansion during SVG export (ToSvg / SvgTemplates) where SVGConfig(showSubtechniques="all"), layout.expandedSubtechniques, and technique entries omitting enabled or tactic failed to render subtechniques in the exported SVG.

Root Causes Fixed

  1. Unset enabled treated as disabled (to_svg.py): Technique.enabled defaults to None (UNSETVALUE) when omitted from a layer JSON. to_svg.py checked if not entry.enabled: continue instead of if entry.enabled is False: continue, skipping subtechnique expansion whenever enabled was not explicitly set to true.
  2. Tactic-less entries never matched (svg_templates.py, svg_objects.py): to_svg.py encodes tactic-less entries as (techniqueID, False), but SvgTemplates.get_tactic(), _copy_scores(), and SVG_Technique.build() checked str(id) + str(tactic) against concatenated strings (e.g. "T1059False"), which never matched any tactic shortname. Matching now handles entry[1] is False or entry[1] == tactic_shortname consistently with MatrixGen._construct_panop().
  3. showSubtechniques="all" and layout.expandedSubtechniques (svg_templates.py, to_svg.py): SVGConfig(showSubtechniques="all") previously only iterated over techniques explicitly present in layer.techniques rather than expanding all non-disabled techniques in the matrix, and layout.expandedSubtechniques ("all" / "annotated") was ignored in "expanded" mode. Row-height counting in SvgTemplates.export() now uses the same expansion/exclusion logic as get_tactic() so expanded subtechniques scale cleanly.

Validation

  • Reproduced issue [Bug] showSubtechniques in SVGConfig does not show the sub techniques in the SVG #169 before the fix: SVGConfig(showSubtechniques="all"), unset enabled, missing tactic, and empty techniques all produced SVGs without subtechnique cells.
  • Added offline regression suite in tests/test_to_svg_subtechniques.py (6 tests covering "all", "expanded", "none", unset enabled, omitted vs. scoped tactic, hideDisabled, and layout.expandedSubtechniques "all" / "annotated").
  • Verified with Python 3.12:
    • pytest tests/test_to_svg_subtechniques.py tests/test_layers.py -v -> 14 passed, 1 skipped (test_config_load pre-existing skip)
    • ruff check and ruff format --check on all modified/added files -> 0 issues

@sonarqubecloud

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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.

[Bug] showSubtechniques in SVGConfig does not show the sub techniques in the SVG

1 participant