Skip to content

fastflowtransform.ci.sarif

write_sarif

write_sarif(summary, path, *, tool_name='FastFlowTransform CI', tool_version=None)

Serialize a CiSummary into a SARIF file consumable by GitHub code scanning or other tools.

This is intentionally minimal but standards-compliant enough for basic use.

Source code in src/fastflowtransform/ci/sarif.py
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def write_sarif(
    summary: CiSummary,
    path: Path,
    *,
    tool_name: str = "FastFlowTransform CI",
    tool_version: str | None = None,
) -> None:
    """
    Serialize a CiSummary into a SARIF file consumable by GitHub code scanning
    or other tools.

    This is intentionally minimal but standards-compliant enough for basic use.
    """
    results = [_issue_to_sarif_result(issue) for issue in summary.issues]

    driver: dict[str, Any] = {"name": tool_name}
    if tool_version:
        driver["version"] = tool_version

    sarif = {
        "version": "2.1.0",
        "runs": [
            {
                "tool": {"driver": driver},
                "results": results,
            }
        ],
    }

    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(json.dumps(sarif, indent=2), encoding="utf-8")