From d602efd3f07038cb5509ef3a6b434735ba893d00 Mon Sep 17 00:00:00 2001 From: Kristen Newbury Date: Thu, 15 Dec 2022 18:46:32 -0500 Subject: [PATCH] Bugfix signature subset superset mismatch when the template signature portion contains codeflows it was previously possible that a valid sarif problem portion that contains extra fields would be misdiagnosed as not parsable --- sarif_cli/typegraph.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sarif_cli/typegraph.py b/sarif_cli/typegraph.py index 3769fc6..4dce356 100644 --- a/sarif_cli/typegraph.py +++ b/sarif_cli/typegraph.py @@ -196,9 +196,14 @@ def _destructure_dict(typegraph: Typegraph, node, tree): ) else: - status_writer.unknown_sarif_parsing_shape["extra_info"] = "type fields {} do not match tree fields {}.".format(type_fields, tree_fields) - status_writer.csv_write(status_writer.unknown_sarif_parsing_shape) - raise Exception("typegraph: unhandled case reached: cannot match type " + # possibly looks like: (Struct9699)type_fields: [codeflows...] vs tree_fields: [...extra_properties] + # in that case we need to also try the Struct4055 signature here + if "codeFlows" in type_fields: + _destructure_dict(typegraph, "Struct4055", tree) + else: + status_writer.unknown_sarif_parsing_shape["extra_info"] = "type fields {} do not match tree fields {}.".format(type_fields, tree_fields) + status_writer.csv_write(status_writer.unknown_sarif_parsing_shape) + raise Exception("typegraph: unhandled case reached: cannot match type " "fields {} to tree fields {}. Data is invalid." .format(type_fields, tree_fields))