mitre-attack / mitreattack-python

A python module for working with ATT&CK
https://mitreattack-python.readthedocs.io/
Apache License 2.0
447 stars 103 forks source link

[Bug] Generating an SVG fails due to updates to the Pillow library #140

Closed jaimeatwork closed 1 year ago

jaimeatwork commented 1 year ago

Expected Behavior

The ToSVG class should be able to be used to generate an SVG of the MITRE ATT&CK Matrix with a correctly formatted layer.

Actual Behavior

An error occurs and the SVG is not generated.

AttributeError: 'FreeTypeFont' object has no attribute 'getsize'

See https://github.com/tensorflow/models/issues/11040#issuecomment-1631442757 for more context. https://pypi.org/project/Pillow/10.0.0/#history

Steps to Reproduce the Problem

  1. Install the latest version of this library

  2. Run the following code, you'll need to provide a valid layer file.

    from mitreattack.navlayers import Layer, SVGConfig, ToSvg layer = Layer() layer.from_dict(data) y = SVGConfig(width=8.5, height=11, headerHeight=1, unit="in", showSubtechniques="expanded", font="serif", tableBorderColor="#6B7279", showHeader=True, legendDocked=True, legendX=0, legendY=0, legendWidth=2, legendHeight=1, showLegend=True, showFilters=True, showAbout=True, showDomain=True, border=0.104) t = ToSvg(domain=data['domain'], source='local', resource='enterprise-attack.json', config=y) t.to_svg(layerInit=layer, filepath='attackcoverage.svg') # render the layer to an SVG file

  3. Observe the error

Possible Solution

Pin the version of Pillow to 9.5.0.