Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[debug] add some logs for checking issue map #34

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions cloudbuild_dev.yaml
Original file line number Diff line number Diff line change
@@ -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"
12 changes: 11 additions & 1 deletion sarif-parser/src/sarif_parser/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""sarif-parser - Parse SARIF reports and covert them to DeepSource issues."""

from __future__ import annotations

import hashlib
Expand Down Expand Up @@ -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"]:
Expand Down Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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 = []
Expand Down Expand Up @@ -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)
Loading