mirror of
https://github.com/hohn/sarif-cli.git
synced 2025-12-16 17:23:03 +01:00
Fix missing 'region' key in relatedLocations: use whole-file output
The goal is fixed-structure output formatting, so whole-file output uses -1,-1,-1,-1 for line, column information.
This commit is contained in:
committed by
=Michael Hohn
parent
1271589bc4
commit
f1d21e4a43
@@ -71,6 +71,10 @@ for runi in S.indices(sarif_struct, 'runs'):
|
|||||||
else:
|
else:
|
||||||
S.msg("REFERENCE: %s: %s\n\n" % ("<NoFile>", message))
|
S.msg("REFERENCE: %s: %s\n\n" % ("<NoFile>", message))
|
||||||
else:
|
else:
|
||||||
|
if region == S.WholeFile:
|
||||||
|
l1, c1, l2, c2 = -1, -1, -1, -1
|
||||||
|
else:
|
||||||
|
l1, c1, l2, c2 = S.lineinfo(region)
|
||||||
l1, c1, l2, c2 = S.lineinfo(region)
|
l1, c1, l2, c2 = S.lineinfo(region)
|
||||||
filepath = "%s:%d:%d:%d:%d" % (artifact['uri'], l1, c1, l2, c2)
|
filepath = "%s:%d:%d:%d:%d" % (artifact['uri'], l1, c1, l2, c2)
|
||||||
if args.csv:
|
if args.csv:
|
||||||
@@ -97,7 +101,10 @@ for runi in S.indices(sarif_struct, 'runs'):
|
|||||||
else:
|
else:
|
||||||
S.msg("FLOW STEP %d: %s: %s\n\n" % (loci, "<NoFile>", message))
|
S.msg("FLOW STEP %d: %s: %s\n\n" % (loci, "<NoFile>", message))
|
||||||
else:
|
else:
|
||||||
l1, c1, l2, c2 = S.lineinfo(region)
|
if region == S.WholeFile:
|
||||||
|
l1, c1, l2, c2 = -1, -1, -1, -1
|
||||||
|
else:
|
||||||
|
l1, c1, l2, c2 = S.lineinfo(region)
|
||||||
filepath = "%s:%d:%d:%d:%d" % (artifact['uri'], l1, c1, l2, c2)
|
filepath = "%s:%d:%d:%d:%d" % (artifact['uri'], l1, c1, l2, c2)
|
||||||
if args.csv:
|
if args.csv:
|
||||||
S.write_csv(cw, "flow_step", loci, artifact['uri'], l1, c1, l2, c2, message)
|
S.write_csv(cw, "flow_step", loci, artifact['uri'], l1, c1, l2, c2, message)
|
||||||
|
|||||||
@@ -45,11 +45,13 @@ def get_relatedlocation_message_info(related_location):
|
|||||||
|
|
||||||
Returns: (message, artifact, region) by default
|
Returns: (message, artifact, region) by default
|
||||||
For an empty 'physicalLocation' key, returns (message, sarif_cli.NoFile, sarif_cli.NoFile)
|
For an empty 'physicalLocation' key, returns (message, sarif_cli.NoFile, sarif_cli.NoFile)
|
||||||
|
For an empty 'region' key, returns (message, artifact, sarif_cli.WholeFile)
|
||||||
"""
|
"""
|
||||||
message = get(related_location, 'message', 'text')
|
message = get(related_location, 'message', 'text')
|
||||||
if 'physicalLocation' in related_location:
|
if 'physicalLocation' in related_location:
|
||||||
artifact = get(related_location, 'physicalLocation', 'artifactLocation')
|
ploc = get(related_location, 'physicalLocation')
|
||||||
region = get(related_location, 'physicalLocation', 'region')
|
artifact = ploc.get('artifactLocation')
|
||||||
|
region = ploc.get('region', WholeFile)
|
||||||
else:
|
else:
|
||||||
artifact, region = NoFile, NoFile
|
artifact, region = NoFile, NoFile
|
||||||
return message, artifact, region
|
return message, artifact, region
|
||||||
|
|||||||
Reference in New Issue
Block a user