Skip to content

Commit 7a577d1

Browse files
authored
[codex] Add summary-json CI cookbook
Add docs-only CI cookbook for consuming --summary-json PATH with Python and PowerShell examples. No runtime behavior, workflow, package metadata, release tag, schema, examples, or publishing status changes.
1 parent 2e4d8dd commit 7a577d1

4 files changed

Lines changed: 82 additions & 2 deletions

File tree

tools/sbom-diff-and-risk/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ It uses conservative heuristics for change intelligence. By default it does not
1010

1111
This project has two different provenance stories:
1212

13-
For a concise reviewer-facing overview, start with [docs/reviewer-brief.md](docs/reviewer-brief.md). For reproducible review evidence and verification commands, use [docs/reviewer-evidence-pack.md](docs/reviewer-evidence-pack.md). For machine-readable JSON output shape, see [docs/report-schema.md](docs/report-schema.md).
13+
For a concise reviewer-facing overview, start with [docs/reviewer-brief.md](docs/reviewer-brief.md). For reproducible review evidence and verification commands, use [docs/reviewer-evidence-pack.md](docs/reviewer-evidence-pack.md). For machine-readable JSON output shape, see [docs/report-schema.md](docs/report-schema.md). For CI consumption of summary-only output, see [docs/summary-json-ci-cookbook.md](docs/summary-json-ci-cookbook.md).
1414

1515
1. If you want to verify `sbom-diff-and-risk` itself, start with [docs/verification.md](docs/verification.md).
1616
2. If you want to use `sbom-diff-and-risk` to analyze third-party dependency provenance, start with [Dependency provenance analysis](#dependency-provenance-analysis-opt-in) and [Dependency provenance reporting](#dependency-provenance-reporting).
@@ -179,6 +179,8 @@ Offline mode remains the default. No network access occurs unless `--enrich-pypi
179179

180180
The checked-in [examples/sample-summary.json](examples/sample-summary.json) artifact is generated from the bundled CycloneDX example with `--summary-json outputs/summary.json` and matches the `summary` object in [examples/sample-report.json](examples/sample-report.json).
181181

182+
For CI dashboard, job-summary, and local-threshold examples, see [docs/summary-json-ci-cookbook.md](docs/summary-json-ci-cookbook.md).
183+
182184
## Dependency Provenance Analysis (Opt-in)
183185

184186
This section is about analyzing third-party package provenance signals. It is not about verifying the `sbom-diff-and-risk` tool's own release artifacts.

tools/sbom-diff-and-risk/docs/report-schema.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ When provenance policy fields are relevant, reports may also include `provenance
3030

3131
## Summary contract
3232

33-
`summary` is the stable, compact entry point for automation that needs counts without walking the full report. The `--summary-json PATH` CLI option writes only this stable `report.json["summary"]` object. The checked-in [../examples/sample-summary.json](../examples/sample-summary.json) artifact is the summary-only output for the default CycloneDX example and matches the `summary` object in [../examples/sample-report.json](../examples/sample-report.json).
33+
`summary` is the stable, compact entry point for automation that needs counts without walking the full report. The `--summary-json PATH` CLI option writes only this stable `report.json["summary"]` object. The checked-in [../examples/sample-summary.json](../examples/sample-summary.json) artifact is the summary-only output for the default CycloneDX example and matches the `summary` object in [../examples/sample-report.json](../examples/sample-report.json). For CI consumption examples, see [summary-json-ci-cookbook.md](summary-json-ci-cookbook.md).
3434

3535
Base `summary` fields:
3636

tools/sbom-diff-and-risk/docs/reviewer-evidence-pack.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ The SARIF sample is intentionally conservative. It covers selected high-signal f
7575

7676
For consumers of the JSON output, see [report-schema.md](report-schema.md). It documents the stable `summary` contract, including conditional `summary.policy` and `summary.enrichment` fields.
7777

78+
For CI dashboard, job-summary, and local-threshold examples that consume `outputs/summary.json`, see [summary-json-ci-cookbook.md](summary-json-ci-cookbook.md).
79+
7880
## Release Verification Path
7981

8082
Start with the GitHub Release for the version under review. For `v0.6.0`, inspect the release and assets:
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Summary JSON CI cookbook
2+
3+
This page shows how to consume `--summary-json PATH` in CI without changing the `sbom-diff-risk` analysis model.
4+
5+
`--summary-json` writes a compact machine-readable JSON object. It is the same object as `report.json["summary"]`, and is useful for CI dashboards, job summaries, and small local gates where a repository wants to set its own thresholds.
6+
7+
## Minimal command
8+
9+
```bash
10+
sbom-diff-risk compare \
11+
--before examples/cdx_before.json \
12+
--after examples/cdx_after.json \
13+
--out-json outputs/report.json \
14+
--summary-json outputs/summary.json
15+
```
16+
17+
The full report remains available at `outputs/report.json`. The compact summary-only object is written to `outputs/summary.json`.
18+
19+
## Python consumer
20+
21+
This example reads the summary and applies an explicit local threshold. The threshold is chosen by the caller; it is not a built-in package safety verdict.
22+
23+
```python
24+
import json
25+
from pathlib import Path
26+
27+
summary = json.loads(Path("outputs/summary.json").read_text(encoding="utf-8"))
28+
29+
added = summary["added"]
30+
removed = summary["removed"]
31+
changed = summary["changed"]
32+
risk_counts = summary["risk_counts"]
33+
34+
print(f"added={added} removed={removed} changed={changed}")
35+
print(f"risk_counts={risk_counts}")
36+
37+
max_new_packages = 2
38+
if risk_counts.get("new_package", 0) > max_new_packages:
39+
raise SystemExit(f"new_package count exceeds local threshold: {max_new_packages}")
40+
```
41+
42+
## PowerShell consumer
43+
44+
This example uses `ConvertFrom-Json` and applies the same kind of explicit local threshold.
45+
46+
```powershell
47+
$summary = Get-Content outputs/summary.json -Raw | ConvertFrom-Json
48+
49+
$added = $summary.added
50+
$removed = $summary.removed
51+
$changed = $summary.changed
52+
$newPackageCount = $summary.risk_counts.new_package
53+
54+
Write-Output "added=$added removed=$removed changed=$changed"
55+
Write-Output "new_package=$newPackageCount"
56+
57+
$maxNewPackages = 2
58+
if ($newPackageCount -gt $maxNewPackages) {
59+
throw "new_package count exceeds local threshold: $maxNewPackages"
60+
}
61+
```
62+
63+
## Compatibility notes
64+
65+
- `summary.policy` appears only when policy evaluation is applied.
66+
- `summary.enrichment` appears only when PyPI or Scorecard enrichment is used.
67+
- `unchanged` is absent because unchanged components are not modeled.
68+
- Absence of `summary.policy` or `summary.enrichment` means the feature was not used, not that it failed.
69+
- Consumers should treat new unrecognized fields as additive data.
70+
71+
## Non-claims
72+
73+
- `sbom-diff-risk` is not a CVE scanner.
74+
- The summary is not a dependency safety oracle.
75+
- Default runs do not perform hidden network access.
76+
- Production PyPI publishing remains intentionally deferred.

0 commit comments

Comments
 (0)