From fb0e1b9c1cc9e4b2fef23a4b320848cf93029e11 Mon Sep 17 00:00:00 2001 From: Kristen Newbury Date: Fri, 2 Dec 2022 16:00:40 -0500 Subject: [PATCH] Change sarif sig severity to problem.severity and rm redundant table col for kind --- sarif_cli/scan_tables.py | 19 ++++++++----------- sarif_cli/signature.py | 2 +- sarif_cli/signature_single.py | 2 +- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/sarif_cli/scan_tables.py b/sarif_cli/scan_tables.py index d6b79a7..382dec0 100644 --- a/sarif_cli/scan_tables.py +++ b/sarif_cli/scan_tables.py @@ -39,8 +39,7 @@ class ScanTablesTypes: 'query_kind' : pd.StringDtype(), 'query_precision' : pd.StringDtype(), 'query_severity' : pd.StringDtype(), - - 'result_type' : pd.StringDtype(), + 'codeFlow_id' : pd.UInt64Dtype(), 'message' : pd.StringDtype(), @@ -150,9 +149,9 @@ def joins_for_results(basetables, external_info): """ Form and return the `results` table """ - # Get one table per result_type, then stack them, - # kind_problem - # kind_pathproblem + # Get one table per query_kind, then stack them, + # problem + # path-problem # # Concatenation with an empty table triggers type conversion to float, so don't # include empty tables. @@ -195,9 +194,8 @@ def _results_from_kind_problem(basetables, external_info): 'query_id' : b.kind_problem.rule_id, 'query_kind' : "problem", 'query_precision' : [_populate_from_rule_table("precision", b, i) for i in range(len(b.kind_problem))], - 'query_severity' : [_populate_from_rule_table("severity", b, i) for i in range(len(b.kind_problem))], - - 'result_type' : "kind_problem", + 'query_severity' : [_populate_from_rule_table("problem.severity", b, i) for i in range(len(b.kind_problem))], + 'codeFlow_id' : 0, # link to codeflows (kind_pathproblem only, NULL here) 'message': b.kind_problem.message_text, @@ -284,9 +282,8 @@ def _results_from_kind_pathproblem(basetables, external_info): 'query_id' : cfid0ppt0.rule_id.values[0], 'query_kind' : "path-problem", 'query_precision' : _populate_from_rule_table_code_flow("precision", b, cfid0ppt0), - 'query_severity' : _populate_from_rule_table_code_flow("severity", b, cfid0ppt0), - # - 'result_type' : "kind_pathproblem", + 'query_severity' : _populate_from_rule_table_code_flow("problem.severity", b, cfid0ppt0), + 'codeFlow_id' : cfid0, # 'message': cfid0ppt0.message_text.values[0], diff --git a/sarif_cli/signature.py b/sarif_cli/signature.py index 582dbee..ea99552 100644 --- a/sarif_cli/signature.py +++ b/sarif_cli/signature.py @@ -209,7 +209,7 @@ properties_keys = set([first for first, _ in dummy_properties = { 'kind' : 'scli-dyys dummy value', 'precision' : 'scli-dyys dummy value', 'security-severity' : 'scli-dyys dummy value', - 'severity' : 'scli-dyys dummy value', + 'problem.severity' : 'scli-dyys dummy value', 'sub-severity' : 'scli-dyys dummy value', 'tags' : ['scli-dyys dummy value'], } diff --git a/sarif_cli/signature_single.py b/sarif_cli/signature_single.py index 050cab7..3da4b8d 100644 --- a/sarif_cli/signature_single.py +++ b/sarif_cli/signature_single.py @@ -84,7 +84,7 @@ struct_graph_2022_02_01 = ( ('kind', 'String'), ('precision', 'String'), ('security-severity', 'String'), - ('severity', 'String'), + ('problem.severity', 'String'), ('sub-severity', 'String'), ('tags', 'Array7069'))), ( 'Struct6818',