From c0f469ff50ecdc9aa3a772e0c1d522b05cbea4e3 Mon Sep 17 00:00:00 2001 From: Charissa Miller <48832936+clemiller@users.noreply.github.com> Date: Mon, 29 Apr 2024 09:44:09 -0400 Subject: [PATCH] Fix false warnings during layer ops (#174) * fix 173 * update changelog --- CHANGELOG.md | 6 ++++++ mitreattack/navlayers/manipulators/layerops.py | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f4c39a6..4e86b386 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,13 @@ # v3.0.5 - Changes staged +## Features + - Added functionality to `MitreAttackData` to retrieve a list of Procedure Examples by technique. [#172](https://github.com/mitre-attack/mitreattack-python/pull/172) +## Fixes + +- Fixed a layer comparison issue causing false warnings to appear during layer operations. [#173](https://github.com/mitre-attack/mitreattack-python/issues/173). + # v3.0.4 - 4/23/2024 ## Features diff --git a/mitreattack/navlayers/manipulators/layerops.py b/mitreattack/navlayers/manipulators/layerops.py index f0f3df71..40e6684e 100644 --- a/mitreattack/navlayers/manipulators/layerops.py +++ b/mitreattack/navlayers/manipulators/layerops.py @@ -181,9 +181,11 @@ def _merge_to_template(self, data, key=0): for entry in key_space: if entry != "techniques": standard = _raw[entry] - if any(y != standard for y in [getattr(x.layer, entry) for x in collide]): + layer_entries = [getattr(x.layer, entry) for x in collide] + layer_entries = [y.get_dict() if hasattr(y, 'get_dict') else y for y in layer_entries] + if any(y != standard for y in layer_entries): if entry == "domain": - print("FATAL ERROR! Layer mis-match on domain. " "Exiting.") + print("FATAL ERROR! Layer mis-match on domain. Exiting.") raise MismatchedDomain print(f"Warning! Layer mis-match detected for {entry}. Defaulting to {key}'s value") out[entry] = standard