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

Commit 8aa718a

Browse files
author
clittle
committed
Updated readme, swapped MemoryStore for FileSystem
1 parent edc1e91 commit 8aa718a

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

layers/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,6 @@ lay.from_file("path/to/layer/file.json")
160160
t = ToExcel(domain=lay.layer.domain, source='taxii')
161161
t.to_xlsx(layer=lay, filepath="demo.xlsx")
162162
#Using local stix data for template
163-
t2 = ToExcel(domain='mobile', source='local', local='path/to/local/stix')
163+
t2 = ToExcel(domain='mobile', source='local', local='path/to/local/stix.json')
164164
t2.to_xlsx(layer=lay, filepath="demo2.xlsx")
165165
```

layers/exporters/matrix_gen.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
from stix2 import TAXIICollectionSource, Filter, FileSystemSource
1+
from stix2 import TAXIICollectionSource, Filter, MemoryStore
22
from taxii2client import Server, Collection
33

4+
5+
class DomainNotLoadedError(Exception):
6+
pass
7+
48
class MatrixEntry:
59
def __init__(self, id=None, name=None):
610
if id is not None:
@@ -94,8 +98,11 @@ def __init__(self, source='taxii', local=None):
9498
self.collections[collection.title.split(' ')[0].lower()] = TAXIICollectionSource(tc)
9599
elif source.lower() == 'local':
96100
if local is not None:
97-
self.collections['enterprise'] = FileSystemSource(local)
98-
self.collections['mobile'] = FileSystemSource(local)
101+
hd = MemoryStore()
102+
if 'mobile' in local.lower():
103+
self.collections['mobile'] = hd.load_from_file(local)
104+
else:
105+
self.collections['enterprise'] = hd.load_from_file(local)
99106
else:
100107
print('[MatrixGen] - "local" source specified, but path to local source not provided')
101108
raise ValueError
@@ -302,6 +309,8 @@ def _build_matrix(self, domain='enterprise'):
302309
303310
:param domain: The domain to build a matrix for
304311
"""
312+
if domain not in self.collections:
313+
raise DomainNotLoadedError
305314
self.matrix[domain] = []
306315
tacs = self._get_tactic_listing(domain)
307316
for tac in tacs:

0 commit comments

Comments
 (0)