Skip to content

Commit 3b58e25

Browse files
authored
Merge pull request #79 from thelok/patch-1
Update requirements.txt to include pydantic
2 parents a5ab118 + e8ec734 commit 3b58e25

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ The project is currently in a Production/Stable stage, which means that the curr
3939
- stix2 >= 2.1.0
4040
- taxii2-client >= 2.3.0
4141
- six >= 1.16.0
42+
- pydantic
4243

4344
### Installation
4445

attackcti/attack_api.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ def get_techniques_used_by_all_groups(self, stix_format: bool = True) -> List:
18361836
groups_use_techniques = self.parse_stix_objects(groups_use_techniques, GroupTechnique)
18371837
return groups_use_techniques
18381838

1839-
def get_software_used_by_group(self, stix_object: Any = None, stix_format: bool = True) -> List:
1839+
def get_software_used_by_group(self, stix_object: Any = None, stix_format: bool = True, batch_size=10) -> List:
18401840
"""
18411841
Retrieves techniques used by a specified group STIX object across all ATT&CK matrices.
18421842
@@ -1845,6 +1845,8 @@ def get_software_used_by_group(self, stix_object: Any = None, stix_format: bool
18451845
stix_format (bool, optional): If True, returns technique objects in their original STIX format. If False,
18461846
returns techniques as custom dictionaries parsed according to the Technique Pydantic model.
18471847
Default is True.
1848+
batch_size (int): The batch size to use when querying the TAXII datastore. Use a lower batch size if the
1849+
URI becomes too long and you get HTTP 414 errors.
18481850
18491851
Returns:
18501852
List: A list of software objects used by a specific group, either as raw STIX objects or as custom dictionaries following the
@@ -1857,11 +1859,17 @@ def get_software_used_by_group(self, stix_object: Any = None, stix_format: bool
18571859
software_relationships.append(relation)
18581860
if len(software_relationships) == 0:
18591861
return software_relationships
1860-
filter_objects = [
1861-
Filter('type', 'in', ['malware', 'tool']),
1862-
Filter('id', '=', [r.target_ref for r in software_relationships])
1863-
]
1864-
all_software = self.COMPOSITE_DS.query(filter_objects)
1862+
1863+
all_software = []
1864+
1865+
for software_relation_batch in [software_relationships[i:i+batch_size] for i in range(0, len(software_relationships), batch_size)]:
1866+
filter_objects = [
1867+
Filter('type', 'in', ['malware', 'tool']),
1868+
Filter('id', '=', [r.target_ref for r in software_relation_batch])
1869+
]
1870+
1871+
search_results = self.COMPOSITE_DS.query(filter_objects)
1872+
all_software.extend(search_results)
18651873

18661874
if not stix_format:
18671875
all_software = self.parse_stix_objects(all_software, Software)

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
stix2>=3.0.1
22
taxii2-client>=2.3.0
33
stix2-patterns>=1.3.2
4-
six>=1.16.0
4+
six>=1.16.0
5+
pydantic

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
long_description = f.read()
1313

1414
setup(
15-
name="attackcti",
15+
name="attackcti-thelok",
1616
version="0.4.1",
1717
author="Roberto Rodriguez",
1818
description="MITRE ATTACK CTI Python Libary",
@@ -45,4 +45,4 @@
4545
'Programming Language :: Python :: 3.8',
4646
'Programming Language :: Python :: 3.9'
4747
],
48-
)
48+
)

0 commit comments

Comments
 (0)