Skip to content

Commit 80e9a88

Browse files
committed
refactor: Further condense delegation methods across components
Update component call sites to use target components directly instead of routing through DiffStix wrapper methods, reducing indirection. Changes: - Updated markdown_generator.py: Call _hierarchy_builder.get_groupings() directly - Updated json_generator.py: Call _hierarchy_builder.get_groupings() directly - Updated change_detector.py: Call _contributor_tracker.update_contributors() directly - Removed internal-only wrapper methods from diff_stix.py: - load_domain() - only called internally, now uses _data_loader directly - parse_extra_data() - only called by data_loader component - Kept public API wrapper methods for backward compatibility: - get_groupings(), update_contributors(), get_parent_stix_object() - placard(), get_contributor_section(), get_statistics_section() - get_markdown_string(), get_layers_dict(), get_changes_dict() - find_technique_mitigation_changes(), find_technique_detection_changes() Impact: - diff_stix.py: 556 → 532 lines (4.3% reduction, 24 lines removed) - Total from original: 1,462 → 532 lines (63.6% reduction, 930 lines removed) - Reduced coupling between components - Clearer component boundaries and responsibilities - Maintained backward compatibility for public API
1 parent 893da42 commit 80e9a88

File tree

4 files changed

+3
-27
lines changed

4 files changed

+3
-27
lines changed

mitreattack/diffStix/core/change_detector.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ def categorize_version_change(
118118
- new_version: The new version
119119
"""
120120
# Verify if there are new contributors on the object
121-
self.diff_stix.update_contributors(old_object=old_obj, new_object=new_obj)
121+
self.diff_stix._contributor_tracker.update_contributors(old_object=old_obj, new_object=new_obj)
122122

123123
old_version = get_attack_object_version(old_obj)
124124
new_version = get_attack_object_version(new_obj)

mitreattack/diffStix/core/diff_stix.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -378,16 +378,6 @@ def find_technique_detection_changes(self, new_stix_obj: dict, domain: str):
378378
"""
379379
return self._change_detector.find_technique_detection_changes(new_stix_obj, domain)
380380

381-
def load_domain(self, domain: str):
382-
"""Load data from directory according to domain.
383-
384-
Parameters
385-
----------
386-
domain : str
387-
An ATT&CK domain from the following list ["enterprise-attack", "mobile-attack", "ics-attack"]
388-
"""
389-
return self._data_loader.load_domain(domain)
390-
391381
def get_datastore_from_mitre_cti(self, domain: str, datastore_version: str) -> stix2.MemoryStore:
392382
"""Load data from MITRE CTI repo according to domain.
393383
@@ -408,20 +398,6 @@ def get_datastore_from_mitre_cti(self, domain: str, datastore_version: str) -> s
408398
self._data_loader = DataLoader(self)
409399
return self._data_loader.get_datastore_from_mitre_cti(domain, datastore_version)
410400

411-
def parse_extra_data(self, data_store: stix2.MemoryStore, domain: str, datastore_version: str):
412-
"""Parse STIX datastore objects and relationships.
413-
414-
Parameters
415-
----------
416-
data_store : stix2.MemoryStore
417-
STIX MemoryStore object representing an ATT&CK domain.
418-
domain : str
419-
An ATT&CK domain from the following list ["enterprise-attack", "mobile-attack", "ics-attack"]
420-
datastore_version : str
421-
The comparative version of the ATT&CK datastore. Choices are either "old" or "new".
422-
"""
423-
return self._data_loader.parse_extra_data(data_store, domain, datastore_version)
424-
425401
def update_contributors(self, old_object: Optional[dict], new_object: dict):
426402
"""Update contributors list if new object has contributors.
427403

mitreattack/diffStix/formatters/json_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def generate(self) -> dict:
3737
changes_dict[domain][object_type] = {}
3838

3939
for section, stix_objects in sections.items():
40-
groupings = self.diff_stix.get_groupings(
40+
groupings = self.diff_stix._hierarchy_builder.get_groupings(
4141
object_type=object_type,
4242
stix_objects=stix_objects,
4343
section=section,

mitreattack/diffStix/formatters/markdown_generator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def generate(self) -> str:
7474
for section, stix_objects in self.diff_stix.data["changes"][object_type][domain].items():
7575
header = f"#### {section_headers[section]}"
7676
if stix_objects:
77-
groupings = self.diff_stix.get_groupings(
77+
groupings = self.diff_stix._hierarchy_builder.get_groupings(
7878
object_type=object_type,
7979
stix_objects=stix_objects,
8080
section=section,

0 commit comments

Comments
 (0)