sarif-to-dot: add more support for --fill-structure option

Expand

  ('Struct4827', ('struct', ('physicalLocation', 'Struct4963'))),

to have fields

  ( 'Struct2683',
    ( 'struct',
      ('id', 'Int'),
      ('message', 'Struct2774'),
      ('physicalLocation', 'Struct4963')))

and avoid a redundant table.
This commit is contained in:
Michael Hohn
2022-01-27 18:55:02 -08:00
committed by =Michael Hohn
parent eb53ede8b1
commit 119f9a5c18

View File

@@ -227,6 +227,8 @@ dummy_relatedLocations_entry = [
'endColumn': -1}},
'message': {'text': ''}}]
dummy_message_entry = {'text': ''}
def fillsig_dict(args, elem, context):
""" Fill in the missing fields in dictionary signatures.
"""
@@ -265,6 +267,11 @@ def fillsig_dict(args, elem, context):
full_elem['relatedLocations'] = elem.get('relatedLocations',
dummy_relatedLocations_entry)
_remaining_keys()
elif 'physicalLocation' in elem.keys():
# Ensure id and message are present
full_elem['id'] = elem.get('id', -1)
full_elem['message'] = elem.get('message', dummy_message_entry)
_remaining_keys()
else:
full_elem = elem