mitreattack-python icon indicating copy to clipboard operation
mitreattack-python copied to clipboard

[Request] tacticBackground support for SVGConfig

Open xg5-simon opened this issue 2 years ago • 2 comments

Is your feature request related to a problem?

Add tacticBackground and showTacticBackground as parameter options when using SVGConfig

Describe the solution you'd like

Add tacticBackground and showTacticBackground as a supported parameter options when using SVGConfig to export a layer as an SVG.

xg5-simon avatar Oct 17 '22 04:10 xg5-simon

These values are defined in the layer json. Though they seem to be ignored / not implemented in the SVG conversion. Defining these in the layer json and using the ATT&CK Nav to export to SVG works as expected.

"showTacticRowBackground": true,
"tacticRowBackground": "#205b8f"

Example export using the script: export_from_script

Example export using ATT&CK Nav: export_from_navigator

Adding code and JSON layer file to recreate the issue.

lay = Layer()
lay.from_file("example_layer.json")
svgconf = SVGConfig(width=12, height=12, headerHeight=1, unit="in", showSubtechniques="expanded",
                    font="sans-serif", tableBorderColor="#6B7279", showHeader=False, legendDocked=True,
                    legendX=0, legendY=0, legendWidth=2, legendHeight=1, showLegend=False, showFilters=False,
                    showAbout=False, showDomain=False, border=0.104)
t = ToSvg(domain=lay.layer.domain, source='taxii', config=svgconf)
t.to_svg(layerInit=lay, filepath="../reports/mitreheatmap.svg")

JSON Layer: example_layer.zip

CyberDefend3r avatar Jun 28 '23 18:06 CyberDefend3r

Looks like the reason is that there are no cells created under the Tactic text. https://github.com/mitre-attack/mitreattack-python/blob/f454936762dde3535d16f66460802d54a46afc09/mitreattack/navlayers/exporters/svg_templates.py#L439

Could implement another method similar to _block to create the necessary objects for the tactic row... maybe? https://github.com/mitre-attack/mitreattack-python/blob/f454936762dde3535d16f66460802d54a46afc09/mitreattack/navlayers/exporters/svg_objects.py#L464

CyberDefend3r avatar Jun 28 '23 22:06 CyberDefend3r