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

Commit e79f711

Browse files
author
clittle
committed
Quick patches
1 parent 5118d12 commit e79f711

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

layers/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ This folder contains modules and scripts for working with ATT&CK Navigator layer
3030
| [matrix_gen](exporters/matrix_gen.py) | Provides a means by which to generate a matrix from raw data, either from the ATT&CK TAXII server or from a local STIX Bundle. |
3131
| [svg_templates](exporters/svg_templates.py) | Provides a means by which to convert a layer file into a marked up svg file. |
3232
| [svg_objects](exporters/svg_objects.py) | Provides raw templates and supporting functionality for generating svg objects. |
33-
##### Command LIne Tools
33+
##### Command Line Tools
3434
| script | description |
3535
|:-------|:------------|
36-
| [cmdline.py](cmdline.py) | A commandline utility to export Layer files to excel or svg formats using the exporter tools. Run with `-h` for usage. |
36+
| [layerExporter_cli.py](layerExporter_cli.py) | A commandline utility to export Layer files to excel or svg formats using the exporter tools. Run with `-h` for usage. |
3737

3838
## Layer
3939
The Layer class provides format validation and read/write capabilities to aid in working with ATT&CK Navigator Layers in python. It is the primary interface through which other Layer-related classes defined in the core module should be used. The Layer class API and a usage example are below.
@@ -177,7 +177,7 @@ 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)
181181
```
182182
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.
183183

@@ -191,14 +191,14 @@ The to_svg method exports the layer file referenced as `layer`, as an excel file
191191
#### Example Usage
192192
```python
193193
from layers import Layer
194-
from layers import ToSVG
194+
from layers import ToSvg
195195

196196
lay = Layer()
197197
lay.from_file("path/to/layer/file.json")
198198
# Using taxii server for template
199-
t = ToSVG(domain=lay.layer.domain, source='taxii')
199+
t = ToSvg(domain=lay.layer.domain, source='taxii')
200200
t.to_svg(layer=lay, filepath="demo.svg")
201201
#Using local stix data for template
202-
t2 = ToSVG(domain='mobile', source='local', local='path/to/local/stix.json')
202+
t2 = ToSvg(domain='mobile', source='local', local='path/to/local/stix.json')
203203
t2.to_svg(layer=lay, filepath="demo2.svg")
204204
```
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
from core import Layer
55

66
if __name__ == '__main__':
7-
parser = argparse.ArgumentParser(description='Export an Att&ck layer as a svg image or excel file')
7+
parser = argparse.ArgumentParser(description='Export an ATT&CK Navigator layer as a svg image or excel file')
88
parser.add_argument('-m', '--mode', choices=['svg', 'excel'], required=True, help='The form to export the layers in')
99
parser.add_argument('input', nargs='+', help='Path(s) to the file to export')
1010
parser.add_argument('-s','--source', choices=['taxii', 'local'], default='taxii', help='What source to utilize when building the matrix')
1111
parser.add_argument('--local', help='Path to the local resource if --source=local', default=None)
12-
parser.add_argument('-o','--output', nargs='+', help='Path(s) to the exported svg file', required=True)
12+
parser.add_argument('-o','--output', nargs='+', help='Path(s) to the exported svg/xlsx file', required=True)
1313
args = parser.parse_args()
1414
if len(args.output) != len(args.input):
1515
print('Mismatched number of output filepaths to input file paths. Exiting...')
@@ -24,9 +24,15 @@
2424
print('Unable to load {}. Skipping...'.format(entry))
2525
continue
2626
if args.mode=='excel':
27+
if not args.output[i].endwith('.xlsx'):
28+
print('[ERROR] Unable to export {} as type: excel to {}'.format(entry, args.output[i]))
29+
continue
2730
exy = ToExcel(domain=lay.layer.domain, source=args.source, local=args.local)
2831
exy.to_xlsx(lay, filepath=args.output[i])
2932
else:
33+
if not args.output[i].endwith('.svg'):
34+
print('[ERROR] Unable to export {} as type: svg to {}'.format(entry, args.output[i]))
35+
continue
3036
svy = ToSvg(domain=lay.layer.domain, source=args.source, local=args.local)
3137
svy.to_svg(lay, filepath=args.output[i])
3238
print('{}/{} - Finished processing {}'.format(i + 1, len(args.input), entry))

0 commit comments

Comments
 (0)