| 1 |
import json |
| 2 |
import os |
| 3 |
|
| 4 |
def sarif_from_env(): |
| 5 |
# return parsed JSON content a SARIF_PATH file |
| 6 |
json_filename = os.environ['SARIF_PATH'] |
| 7 |
json_filename += '.sarif' |
| 8 |
print('json_filename: %r' % json_filename) |
| 9 |
with open(json_filename) as f: |
| 10 |
json_data = f.read() |
| 11 |
return json.loads(json_data) |
| 12 |
|
| 13 |
def get_location_artifact_uri(location): |
| 14 |
return location['physicalLocation']['artifactLocation']['uri'] |
| 15 |
|
| 16 |
def get_location_physical_region(location): |
| 17 |
return location['physicalLocation']['region'] |
| 18 |
|
| 19 |
def get_location_snippet_text(location): |
| 20 |
return location['physicalLocation']['contextRegion']['snippet']['text'] |
| 21 |
|
| 22 |
def get_location_relationships(location): |
| 23 |
return location['relationships'] |