Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Export sarif paths relative to $GITHUB_WORKSPACE if present
Browse files Browse the repository at this point in the history
  • Loading branch information
michprev committed Oct 26, 2023
1 parent d258f22 commit a2c3272
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion woke/detectors/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
from inspect import cleandoc
from pathlib import Path
from typing import Dict, List

from rich_click import Command
Expand Down Expand Up @@ -85,6 +86,10 @@ def create_sarif_log(
DetectionImpact.INFO: "note",
}

workspace_root = os.getenv("GITHUB_WORKSPACE")
if workspace_root is not None:
workspace_root = Path(workspace_root).resolve()

results = []
for detector_name, r in detections.items():
for result in r:
Expand Down Expand Up @@ -126,7 +131,7 @@ def create_sarif_log(
Location(
physical_location=PhysicalLocation(
artifact_location=ArtifactLocation(
uri=f"{result.detection.ir_node.file}",
uri=f"{result.detection.ir_node.file if workspace_root is None else result.detection.ir_node.file.relative_to(workspace_root)}",
),
region=Region(
start_line=start_line,
Expand Down

0 comments on commit a2c3272

Please sign in to comment.