mirror of
https://github.com/hohn/sarif-cli.git
synced 2025-12-16 17:23:03 +01:00
sarif-to-dot: add more support for --fill-structure option
Collapse multipl 'physicalLocation's into one; from
( 'Struct006',
('struct', ('artifactLocation', 'Struct000'), ('region', 'Struct005'))),
('Struct036', ('struct', ('artifactLocation', 'Struct000'))),
to
( 'Struct006',
('struct', ('artifactLocation', 'Struct000'), ('region', 'Struct005'))),
This commit is contained in:
committed by
=Michael Hohn
parent
b816705574
commit
d7d566c5db
@@ -173,8 +173,21 @@ region_keys = set([first for first, _ in [ ('endColumn', 'Int'),
|
||||
('startColumn', 'Int'),
|
||||
('startLine', 'Int')]
|
||||
])
|
||||
def dummy_region():
|
||||
""" Return a region with needed keys and "empty" entries -1
|
||||
"""
|
||||
return {
|
||||
'endColumn' : -1,
|
||||
'endLine' : -1,
|
||||
'startColumn' : -1,
|
||||
'startLine' : -1
|
||||
}
|
||||
|
||||
physicalLocation_keys = set([first for first, _ in
|
||||
[ ('artifactLocation', 'Struct000'), ('region', 'Struct005')]])
|
||||
|
||||
def fillsig_dict(args, elem, context):
|
||||
"""
|
||||
""" Fill in the missing fields in dictionary signatures.
|
||||
"""
|
||||
# Supplement all missing fields for a 'region'
|
||||
if region_keys.intersection(elem.keys()):
|
||||
@@ -187,6 +200,12 @@ def fillsig_dict(args, elem, context):
|
||||
rest = set(elem.keys()) - set(full_elem.keys())
|
||||
for key in rest:
|
||||
full_elem[key] = elem[key]
|
||||
elif physicalLocation_keys.intersection(elem.keys()):
|
||||
full_elem = {}
|
||||
full_elem['region'] = elem.get('region', dummy_region())
|
||||
rest = set(elem.keys()) - set(full_elem.keys())
|
||||
for key in rest:
|
||||
full_elem[key] = elem[key]
|
||||
else:
|
||||
full_elem = elem
|
||||
|
||||
|
||||
Reference in New Issue
Block a user