Skip to content
This repository was archived by the owner on Dec 11, 2023. It is now read-only.

Commit 76cf166

Browse files
author
clittle
committed
Finished overhaul of spacing and measurement approach
Created configuration system Upgraded commandline tool
1 parent e79f711 commit 76cf166

9 files changed

Lines changed: 594 additions & 191 deletions

File tree

layers/README.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This folder contains modules and scripts for working with ATT&CK Navigator layer
2222
| script | description |
2323
|:-------|:------------|
2424
| [to_excel](exporters/to_excel.py) | Provides a means by which to export an ATT&CK Layer to an excel file. A further breakdown can be found in the corresponding [section](#to_excel.py) below. |
25-
| [to_svg](exporters/to_svg.py) | Provides a means by which to export an ATT&CK layer to an svg image file. A further breakdown can be found in the corresponding [section](#to_svg.py) below. |
25+
| [to_svg](exporters/to_svg.py) | Provides a means by which to export an ATT&CK layer to an svg image file. A further breakdown can be found in the corresponding [section](#to_svg.py) below. This file also contains the `SVGConfig` object that can be used to configure the SVG export.|
2626
##### Utility Modules
2727
| script | description |
2828
|:-------|:------------|
@@ -177,9 +177,38 @@ tells the exporter what data source to use when building the output matrix. Vali
177177

178178
##### ToSVG()
179179
```python
180-
x = ToSvg(domain='enterprise', source='taxii', local=None)
180+
x = ToSvg(domain='enterprise', source='taxii', local=None, config=None)
181181
```
182-
The ToSVG constructor, just like the ToExcel constructor, takes domain, server, and local arguments during instantiation. The domain can be either `enterprise` or `mobile`, and can be pulled directly from a layer file as `layer.domain`. The source argument tells the matrix generation tool which data source to use when building the matrix. `taxii` indicates that the tool should utilize the `cti-taxii` server when building the matrix, while the `local` option indicates that it should use a local bundle respectively. The local argument is only required if the source is set to `local`, in which case it should be a path to a local stix bundle.
182+
The ToSVG constructor, just like the ToExcel constructor, takes domain, server, and local arguments during instantiation. The domain can be either `enterprise` or `mobile`, and can be pulled directly from a layer file as `layer.domain`. The source argument tells the matrix generation tool which data source to use when building the matrix. `taxii` indicates that the tool should utilize the `cti-taxii` server when building the matrix, while the `local` option indicates that it should use a local bundle respectively. The local argument is only required if the source is set to `local`, in which case it should be a path to a local stix bundle. The `config` parameter is an optional SVGConfig object that can be used to configure the export as desired. If not provided, the configuration for the export will be set to default values.
183+
184+
##### SVGConfig()
185+
```python
186+
y = SVGConfig(width=8.5, height=11, headerHeight=1, unit="in", showSubtechniques="expanded",
187+
font="sans-serif", tableBorderColor="#6B7279", showHeader=True, legendDocked=True,
188+
legendX=0, legendY=0, legendWidth=2, legendHeight=1, showLegend=True, showFilters=True,
189+
showAbout=True, border=0.104)
190+
```
191+
The SVGConfig object is used to configure how an SVG export behaves. The defaults for each of the available values can be found in the declaration above, and a brief explanation for each field is included in the table below. The config object should be provided to the ToSvg object during instantiation, but if values need to be updated on the fly, the currently loaded configuration can be interacted with at `ToSvg().config`. The configuration can also be populated from a json file using the `.load_from_file(filename="path/to/file.json")` method, or stored to one using the `.save_to_file(filename="path/to/file.json)` method.
192+
193+
| attribute| description |
194+
|:-------|:------------|
195+
| width | Desired SVG width |
196+
| height | Desired SVG height |
197+
| headerHeight | Desired Header Block height |
198+
| unit | SVG measurement units (qualifies width, height, etc.) |
199+
| showSubtechniques | Display form for subtechniques - "all", "expanded" (decided by layer), or "none" |
200+
| font | What font style to use - "sans", "sans-serif", or "monospace" |
201+
| tableBorderColor | Hex color to use for the technique borders |
202+
| showHeader | Whether or not to show Header Blocks |
203+
| legendDocked | Whether or not the legend should be docked |
204+
| legendX | Where to place the legend on the x axis if not docked |
205+
| legendY | Where to place the legend on the y axis if not docked |
206+
| legendWidth | Width of the legend if not docked |
207+
| legendHeight | Height of the legend if not docked |
208+
| showLegend | Whether or not to show the legend |
209+
| showFilters | Whether or not to show the Filter Header Block |
210+
| showAbout | Whether or not to show the About Header Block |
211+
| border | What default border width to use |
183212

184213
##### .to_svg() Method
185214
```python
@@ -191,14 +220,18 @@ The to_svg method exports the layer file referenced as `layer`, as an excel file
191220
#### Example Usage
192221
```python
193222
from layers import Layer
194-
from layers import ToSvg
223+
from layers import ToSvg, SVGConfig
195224

196225
lay = Layer()
197226
lay.from_file("path/to/layer/file.json")
198227
# Using taxii server for template
199228
t = ToSvg(domain=lay.layer.domain, source='taxii')
200229
t.to_svg(layer=lay, filepath="demo.svg")
201230
#Using local stix data for template
202-
t2 = ToSvg(domain='mobile', source='local', local='path/to/local/stix.json')
231+
232+
conf = SVGConfig()
233+
conf.load_from_file(filename="path/to/poster/config.json")
234+
235+
t2 = ToSvg(domain='mobile', source='local', local='path/to/local/stix.json', config=conf)
203236
t2.to_svg(layer=lay, filepath="demo2.svg")
204237
```

layers/exporters/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .excel_templates import ExcelTemplates
22
from .matrix_gen import MatrixGen
33
from .to_excel import ToExcel
4-
from .to_svg import ToSvg
4+
from .to_svg import ToSvg, SVGConfig
55
from .svg_templates import SvgTemplates
350 KB
Binary file not shown.
311 KB
Binary file not shown.

layers/exporters/fonts/sans.ttf

83.2 KB
Binary file not shown.

0 commit comments

Comments
 (0)