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

Ensure

    ('Array003', ('array', (0, 'String'))),

is always present, collapse the following into one:

( 'Struct032',
  ( 'struct',
    ('artifacts', 'Array002'),
    ('columnKind', 'String'),
    ('newlineSequences', 'Array003'),
    ('properties', 'Struct004'),
    ('results', 'Array023'),
    ('tool', 'Struct029'),
    ('versionControlProvenance', 'Array031'))),

( 'Struct033',
  ( 'struct',
    ('artifacts', 'Array002'),
    ('columnKind', 'String'),
    ('properties', 'Struct004'),
    ('results', 'Array023'),
    ('tool', 'Struct029'),
    ('versionControlProvenance', 'Array031')))
This commit is contained in:
Michael Hohn
2022-01-26 22:27:07 -08:00
committed by =Michael Hohn
parent 2adf0dfa21
commit 0b13a297a5

View File

@@ -212,6 +212,8 @@ relatedLocations_keys = set([first for first, _ in
('id', 'Int'),
]])
dummy_newlineSequences = ['\r\n', '\n', '\u2028', '\u2029']
def fillsig_dict(args, elem, context):
""" Fill in the missing fields in dictionary signatures.
"""
@@ -241,6 +243,10 @@ def fillsig_dict(args, elem, context):
# Ensure an id is present when message/physicalLocation are
full_elem['id'] = elem.get('id', -1)
_remaining_keys()
elif 'versionControlProvenance' in elem.keys():
# Ensure newlineSequences is present versionControlProvenance is
full_elem['newlineSequences'] = elem.get('newlineSequences', dummy_newlineSequences)
_remaining_keys()
else:
full_elem = elem