Skip to content

Commit

Permalink
Fix up the output to adhere to SARIF schema
Browse files Browse the repository at this point in the history
Fixes #315

Signed-off-by: Eric Brown <[email protected]>
  • Loading branch information
ericwb committed Mar 4, 2024
1 parent dd0857c commit 778b983
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions precli/renderers/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,20 @@ def to_fix(self, file_name: str, fix: Fix):
artifact_location=sarif_om.ArtifactLocation(
uri=self.to_uri(file_name)
),
replacements=sarif_om.Replacement(
deleted_region=sarif_om.Region(
start_line=fix.deleted_location.start_line,
end_line=fix.deleted_location.end_line,
start_column=fix.deleted_location.start_column,
end_column=fix.deleted_location.end_column,
replacements=[
sarif_om.Replacement(
deleted_region=sarif_om.Region(
start_line=fix.deleted_location.start_line,
end_line=fix.deleted_location.end_line,
start_column=fix.deleted_location.start_column,
end_column=fix.deleted_location.end_column,
),
inserted_content=fix.inserted_content,
),
inserted_content=fix.inserted_content,
),
],
)
],
description=fix.description,
description=sarif_om.Message(text=fix.description),
)

def render(self, run: Run):
Expand Down Expand Up @@ -105,8 +107,10 @@ def render(self, run: Run):
)

sarif_result = sarif_om.Result(
message=result.message,
analysis_target=result.artifact.file_name,
message=sarif_om.Message(text=result.message),
analysis_target=sarif_om.ArtifactLocation(
uri=self.to_uri(result.artifact.file_name)
),
fixes=fixes,
level=result.level.name.lower(),
locations=[
Expand Down

0 comments on commit 778b983

Please sign in to comment.