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:
Michael Hohn
2021-12-08 16:02:31 -08:00
committed by =Michael Hohn
parent 1271589bc4
commit f1d21e4a43
2 changed files with 12 additions and 3 deletions

View File

@@ -45,11 +45,13 @@ def get_relatedlocation_message_info(related_location):
Returns: (message, artifact, region) by default
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')
if 'physicalLocation' in related_location:
artifact = get(related_location, 'physicalLocation', 'artifactLocation')
region = get(related_location, 'physicalLocation', 'region')
ploc = get(related_location, 'physicalLocation')
artifact = ploc.get('artifactLocation')
region = ploc.get('region', WholeFile)
else:
artifact, region = NoFile, NoFile
return message, artifact, region