diff --git a/cloudbuild_dev.yaml b/cloudbuild_dev.yaml new file mode 100644 index 00000000..fea9a716 --- /dev/null +++ b/cloudbuild_dev.yaml @@ -0,0 +1,13 @@ +# Build and Push the sarif parser image to GCR +timeout: 5m0s + +steps: + - name: "gcr.io/cloud-builders/docker:20.10.14" + args: + - build + - -t + - ${_REGISTRY_NAME}:dev # always use 'dev' tag on development builds + - . +images: ["${_REGISTRY_NAME}:dev"] +options: + machineType: "E2_HIGHCPU_8" diff --git a/sarif-parser/src/sarif_parser/__init__.py b/sarif-parser/src/sarif_parser/__init__.py index 8f55099e..c44316ee 100644 --- a/sarif-parser/src/sarif_parser/__init__.py +++ b/sarif-parser/src/sarif_parser/__init__.py @@ -1,4 +1,5 @@ """sarif-parser - Parse SARIF reports and covert them to DeepSource issues.""" + from __future__ import annotations import hashlib @@ -57,6 +58,7 @@ def parse( deepsource_issues: list[Issue] = [] total_report_issues = 0 + sanitised_issues_count = 0 for run in sarif_data["runs"]: total_report_issues += len(run["results"]) for issue in run["results"]: @@ -96,6 +98,7 @@ def parse( issue_code = issue["ruleId"] if issue_code in issue_map: issue_code = issue_map[issue_code]["issue_code"] + sanitised_issues_count += 1 else: # This issue isn't sanitised. Send an alert. sentry.raise_info( @@ -121,9 +124,11 @@ def parse( logger.info( "Total issues in SARIF report: %s. \n" - "Issues extracted for the run in files sent for analysis: %s", + "Issues extracted for the run in files sent for analysis: %s. \n" + "Sanitized issues count, with id in map: %s.", total_report_issues, len(deepsource_issues), + sanitised_issues_count, ) return deepsource_issues @@ -174,6 +179,10 @@ def run_sarif_parser( sentry.raise_info( f"Could not find issue map at {issue_map_path} for analyzer." ) + # Add a log too + logger.warning( + "Could not find issue map at %s for analyzer.", issue_map_path + ) # Run parser deepsource_issues = [] @@ -202,5 +211,6 @@ def run_sarif_parser( "is_passed": len(deepsource_issues) == 0, "extra_data": {}, } + with open(output_path, "w") as file: json.dump(issues_dict, file)