diff --git a/pytm/pytm.py b/pytm/pytm.py index 295e2f0..a711687 100644 --- a/pytm/pytm.py +++ b/pytm/pytm.py @@ -859,6 +859,7 @@ def resolve(self): elements = defaultdict(list) for e in TM._elements: if not e.inScope: + e.findings = findings continue override_ids = set(f.threat_id for f in e.overrides) @@ -2089,6 +2090,8 @@ def encode_threat_data(obj): "threat_id", "references", "condition", + "cvss", + "response", ] if type(obj) is Finding or (len(obj) != 0 and type(obj[0]) is Finding): @@ -2104,7 +2107,8 @@ def encode_threat_data(obj): # ignore missing attributes, since this can be called # on both a Finding and a Threat continue - setattr(t, a, html.escape(v)) + if v is not None: + setattr(t, a, html.escape(v)) encoded_threat_data.append(t) diff --git a/tests/test_private_func.py b/tests/test_private_func.py index 3e9aea2..4ce0816 100644 --- a/tests/test_private_func.py +++ b/tests/test_private_func.py @@ -10,10 +10,12 @@ Dataflow, Datastore, DatastoreType, + Finding, Process, Server, Threat, UIError, + encode_threat_data, ) @@ -245,3 +247,41 @@ def test_defaults(self): case["condition"], ), ) + + +class TestFunction(unittest.TestCase): + def test_encode_threat_data(self): + findings = [ + Finding( + description="A test description", + severity="High", + id="1", + threat_id="INP01", + cvss="9.876", + response="A test response", + ), + Finding( + description="An escape test