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

Remove def.ws prefix from aggregate sarif report #2119

Merged
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
11 changes: 11 additions & 0 deletions megalinter/reporters/SarifReporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,22 @@ def fix_sarif(self, linter_sarif_obj, linter: Linter):
# Update run in full list
linter_sarif_obj["runs"][id_run] = run
return linter_sarif_obj

# If DEFAULT_WORKSPACE is set, don't add that to the SARIF-report prefix
def fix_default_workspace_prefix(self, artifactLocation):
default_workspace = config.get("DEFAULT_WORKSPACE", "")
if default_workspace:
if artifactLocation["uri"].startswith(default_workspace):
artifactLocation["uri"] = artifactLocation["uri"].replace(default_workspace,"",1)
return artifactLocation["uri"]

# Replace startLine and endLine in region or contextRegion
def fix_sarif_physical_location(self, physical_location):

for location_key in physical_location.keys():
location_item = physical_location[location_key]
if "uri" in location_item and location_key == "artifactLocation":
location_item["uri"] = self.fix_default_workspace_prefix(location_item)
if "startLine" in location_item and location_item["startLine"] == 0:
location_item["startLine"] = 1
if "endLine" in location_item and location_item["endLine"] == 0:
Expand Down