From 74f6f33fa0e1e884e61f09690a1c7d5cd5901e29 Mon Sep 17 00:00:00 2001 From: Srijan Saurav Date: Thu, 12 Sep 2024 16:05:12 +0530 Subject: [PATCH 1/4] add some logs for debugging --- sarif-parser/src/sarif_parser/__init__.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sarif-parser/src/sarif_parser/__init__.py b/sarif-parser/src/sarif_parser/__init__.py index 8f55099e..a5b2e3d9 100644 --- a/sarif-parser/src/sarif_parser/__init__.py +++ b/sarif-parser/src/sarif_parser/__init__.py @@ -57,6 +57,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 +97,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 +123,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 +178,8 @@ 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 +208,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) From bab9b7b6f8f9976071aced96b3c5d783fbf67e7d Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 12 Sep 2024 10:37:45 +0000 Subject: [PATCH 2/4] style: format code with Black and isort This commit fixes the style issues introduced in 74f6f33 according to the output from Black and isort. Details: https://github.com/DeepSourceCorp/community-analyzers/pull/34 --- sarif-parser/src/sarif_parser/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sarif-parser/src/sarif_parser/__init__.py b/sarif-parser/src/sarif_parser/__init__.py index a5b2e3d9..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 @@ -179,7 +180,9 @@ def run_sarif_parser( 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) + logger.warning( + "Could not find issue map at %s for analyzer.", issue_map_path + ) # Run parser deepsource_issues = [] From 13a42948c9a1b8cf5a9349ac46c1780f84045250 Mon Sep 17 00:00:00 2001 From: Srijan Saurav <68371686+srijan-deepsource@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:24:55 +0530 Subject: [PATCH 3/4] Create cloudbuild_dev.yml Signed-off-by: Srijan Saurav <68371686+srijan-deepsource@users.noreply.github.com> --- cloudbuild_dev.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 cloudbuild_dev.yml diff --git a/cloudbuild_dev.yml b/cloudbuild_dev.yml new file mode 100644 index 00000000..fea9a716 --- /dev/null +++ b/cloudbuild_dev.yml @@ -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" From 06ef6dea7a656a85d7877c4f1fd6d7cd59959c2f Mon Sep 17 00:00:00 2001 From: Srijan Saurav <68371686+srijan-deepsource@users.noreply.github.com> Date: Thu, 12 Sep 2024 16:25:29 +0530 Subject: [PATCH 4/4] Rename cloudbuild_dev.yml to cloudbuild_dev.yaml Signed-off-by: Srijan Saurav <68371686+srijan-deepsource@users.noreply.github.com> --- cloudbuild_dev.yml => cloudbuild_dev.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cloudbuild_dev.yml => cloudbuild_dev.yaml (100%) diff --git a/cloudbuild_dev.yml b/cloudbuild_dev.yaml similarity index 100% rename from cloudbuild_dev.yml rename to cloudbuild_dev.yaml