Skip to content
Merged
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
74 changes: 74 additions & 0 deletions .github/scripts/annotate_sbom_glib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env python3
"""Annotate the Rust SBOM's glib component with its in-tree patch provenance.

`Cargo.lock` records plain `glib 0.18.5`, but the build actually uses the
vendored fork `vendor/glib-0.18.5-patched/` carrying a soundness backport for
RUSTSEC-2024-0429 (see that directory's PROVENANCE.md). A version-keyed SBOM
consumer would otherwise misread the component as unpatched upstream — the
exact false positive OSTIF audit G-033 documents. This script records the
patch as CycloneDX pedigree on the component.

Usage: annotate_sbom_glib.py <sbom.cdx.json> (edits the file in place)

Fails loudly if no glib component is found: if the vendored patch has been
removed (GTK4 migration removal gate), delete this step and this script in
the same PR.
"""

import json
import sys

PROVENANCE_URL = (
"https://github.com/git-agentic/src-control/blob/main/"
"vendor/glib-0.18.5-patched/PROVENANCE.md"
)

def main(path: str) -> None:
with open(path) as f:
sbom = json.load(f)

glib = [
c
for c in sbom.get("components", [])
if c.get("name") == "glib" and c.get("purl", "").startswith("pkg:cargo/glib@")
]
if not glib:
sys.exit(
"no cargo glib component found in SBOM — if the vendored patch "
"was removed, delete this annotation step and script"
)

for c in glib:
c["pedigree"] = {
"patches": [
{
"type": "backport",
"diff": {"url": PROVENANCE_URL},
"resolves": [
{
"type": "security",
"id": "RUSTSEC-2024-0429",
"source": {"name": "RustSec"},
}
],
}
]
}
c.setdefault("properties", []).append(
{
"name": "src-control:vendored-patched-copy",
"value": (
"built from vendor/glib-0.18.5-patched (in-tree fork, "
"[patch.crates-io]); NOT the unpatched upstream 0.18.5"
),
}
)

with open(path, "w") as f:
json.dump(sbom, f, indent=2)
print(f"annotated {len(glib)} glib component(s) in {path}")

if __name__ == "__main__":
if len(sys.argv) != 2:
sys.exit(__doc__)
main(sys.argv[1])
12 changes: 8 additions & 4 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@ on:

permissions:
contents: read
checks: write
# Scheduled runs file findings as GitHub issues; without this the action
# fails with "Resource not accessible by integration" after a clean audit.
issues: write

jobs:
audit:
name: cargo audit (RustSec advisories)
runs-on: ubuntu-latest
# Write scopes are job-scoped, not workflow-level (Scorecard
# Token-Permissions; OSTIF audit T-20): audit-check writes check runs on
# PRs, and scheduled runs file findings as GitHub issues — without
# issues:write it fails with "Resource not accessible by integration".
permissions:
contents: read
checks: write
issues: write
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: rustsec/audit-check@69366f33c96575abad1ee0dba8212993eecbe998 # v2
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/sbom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: sbom

# Two-ecosystem CycloneDX SBOMs as CI artifacts (OSTIF audit T-10, G-005).
# Weekly + on lockfile change; not a PR gate. Attach to releases when a
# release pipeline exists (audit T-24).
on:
push:
branches: [main]
paths:
- "Cargo.lock"
- "apps/desktop/package-lock.json"
- ".github/workflows/sbom.yml"
- ".github/scripts/annotate_sbom_glib.py"
schedule:
# Weekly on Saturdays.
- cron: "41 6 * * 6"
workflow_dispatch:

permissions:
contents: read

jobs:
sbom:
name: generate SBOMs (CycloneDX)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: dtolnay/rust-toolchain@2fe4ca74464c5902a4f6e302d0a619b4ea911ccc # 1.96.1
with:
toolchain: 1.96.1
- name: install cargo-cyclonedx
run: cargo install cargo-cyclonedx --locked --version 0.5.9
- name: rust SBOMs (binaries, all target platforms)
# --target all so the Linux-only GTK stack (incl. the vendored glib)
# is represented regardless of runner OS.
run: cargo cyclonedx --format json --spec-version 1.5 --describe binaries --target all
- name: annotate vendored-patched glib (audit G-033)
# Cargo.lock says plain "glib 0.18.5"; the build actually uses the
# in-tree patched fork. Record the patch as pedigree so SBOM
# consumers don't misread it as unpatched upstream. Fails loudly if
# glib is gone — then remove this step and the script together.
run: python3 .github/scripts/annotate_sbom_glib.py apps/desktop/src-tauri/scl-desktop_bin.cdx.json
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: 24
- name: npm SBOM (desktop frontend, from lockfile)
working-directory: apps/desktop
run: npm sbom --sbom-format cyclonedx --package-lock-only > desktop-frontend.cdx.json
- name: collect
run: |
mkdir -p sbom-out
cp crates/cli/sc_bin.cdx.json sbom-out/
cp apps/desktop/src-tauri/scl-desktop_bin.cdx.json sbom-out/
cp apps/desktop/desktop-frontend.cdx.json sbom-out/
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: sbom-cyclonedx
path: sbom-out/
retention-days: 90
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ target/
apps/desktop/node_modules/
apps/desktop/dist/
apps/desktop/src-tauri/gen/

# Generated SBOMs (CI artifacts, never committed)
*.cdx.json
Loading