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
50 changes: 35 additions & 15 deletions .github/workflows/release-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ permissions:
env:
CARGO_TERM_COLOR: always
CARGO_NET_GIT_FETCH_WITH_CLI: "true"
CARGO_CYCLONEDX_VERSION: "0.5.9"
CARGO_CYCLONEDX_VERSION: "0.5.10"
CARGO_DENY_VERSION: "0.20.2"
CYCLONEDX_CLI_VERSION: "0.33.1"
CYCLONEDX_CLI_LINUX_X64_SHA256: "bfc8b2538da86fe239bc53658bbb63c1c8c510a293c1e6891aa5bea5d3c58746"
CYCLONEDX_CLI_LINUX_ARM64_SHA256: "b2e9fdf9665ef49868a2ec012171c6e785dcd69745bc5869e53e4f4bfb096a5f"
SBOMQS_VERSION: "v2.1.4"
SBOM_QUALITY_THRESHOLD: "8.3"

jobs:
validate:
Expand Down Expand Up @@ -312,25 +318,39 @@ jobs:
with:
rust-version: stable
components: rustfmt
cache-key: cargo-release-sbom-${{ runner.os }}-${{ runner.arch }}-stable-${{ env.CARGO_CYCLONEDX_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
cache-key: cargo-release-sbom-${{ runner.os }}-${{ runner.arch }}-stable-${{ env.CARGO_CYCLONEDX_VERSION }}-${{ env.CARGO_DENY_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install pinned cargo-cyclonedx
run: cargo install cargo-cyclonedx --version "${CARGO_CYCLONEDX_VERSION}" --locked
- name: Generate and upload SBOMs
- name: Install pinned cargo-deny license gate
run: cargo install cargo-deny --version "${CARGO_DENY_VERSION}" --locked
- name: Install hash-pinned Python security dependencies
run: python3 -m pip install --require-hashes --no-deps -r requirements-security.txt
- name: Install checksum-pinned CycloneDX schema validator
run: |
./scripts/install-cyclonedx-cli.sh "${RUNNER_TEMP}/cyclonedx-cli"
echo "${RUNNER_TEMP}/cyclonedx-cli" >> "${GITHUB_PATH}"
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
- name: Install pinned sbomqs
run: |
go install github.com/interlynk-io/sbomqs/v2@${SBOMQS_VERSION}
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- name: Generate, enrich, validate, and score the complete SBOM set
run: ./scripts/generate-sboms.sh sbom-artifacts sbom-artifacts/sbomqs-results.json
- name: Package and verify exact scored SBOM evidence
run: |
(cd sbom-artifacts && tar czf ../rust-gvm-api-sbom.tar.gz -- *.cdx.json *.cdx.xml sbomqs-results.json)
sha256sum rust-gvm-api-sbom.tar.gz > rust-gvm-api-sbom.tar.gz.sha256
python3 -B scripts/verify_sbom_release.py \
--threshold "${SBOM_QUALITY_THRESHOLD}" \
rust-gvm-api-sbom.tar.gz \
rust-gvm-api-sbom.tar.gz.sha256
- name: Upload verified SBOM archive and checksum
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: ${{ needs.validate.outputs.tag }}
run: |
cargo metadata --locked --all-features --format-version 1 > /dev/null
cargo cyclonedx --format json --all --all-features --target all --spec-version 1.5
cargo cyclonedx --format xml --all --all-features --target all --spec-version 1.5
mkdir -p sbom-artifacts
python3 scripts/collect_workspace_sboms.py \
--format json \
--format xml \
sbom-artifacts
cd sbom-artifacts && tar czf ../rust-gvm-api-sbom.tar.gz -- *.cdx.* && cd ..
sha256sum rust-gvm-api-sbom.tar.gz > rust-gvm-api-sbom.tar.gz.sha256
gh release upload "${RELEASE_TAG}" rust-gvm-api-sbom.tar.gz rust-gvm-api-sbom.tar.gz.sha256 --clobber
run: gh release upload "${RELEASE_TAG}" rust-gvm-api-sbom.tar.gz rust-gvm-api-sbom.tar.gz.sha256 --clobber

collect:
name: Release complete
Expand Down
41 changes: 19 additions & 22 deletions .github/workflows/security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ permissions:

env:
CARGO_AUDIT_VERSION: "0.22.2"
CARGO_CYCLONEDX_VERSION: "0.5.9"
CARGO_CYCLONEDX_VERSION: "0.5.10"
CARGO_DENY_VERSION: "0.20.2"
CARGO_GEIGER_VERSION: "0.13.0"
CARGO_MACHETE_VERSION: "0.9.2"
CARGO_VET_VERSION: "0.10.2"
SBOMQS_VERSION: "v2.0.5"
CYCLONEDX_CLI_VERSION: "0.33.1"
CYCLONEDX_CLI_LINUX_X64_SHA256: "bfc8b2538da86fe239bc53658bbb63c1c8c510a293c1e6891aa5bea5d3c58746"
CYCLONEDX_CLI_LINUX_ARM64_SHA256: "b2e9fdf9665ef49868a2ec012171c6e785dcd69745bc5869e53e4f4bfb096a5f"
SBOMQS_VERSION: "v2.1.4"
SBOM_QUALITY_THRESHOLD: "8.3"

jobs:
Expand Down Expand Up @@ -110,11 +114,14 @@ jobs:
rust-version: stable
components: rustfmt
cache-key: cargo-security-policy-${{ runner.os }}-${{ runner.arch }}-stable-${{ hashFiles('**/Cargo.lock') }}
- name: Install hash-pinned Python security dependencies
run: python3 -m pip install --require-hashes --no-deps -r requirements-security.txt
- name: Test fail-closed security helpers and workflow policy
run: >-
python3 -B -m unittest
tests.test_sbom_postprocess
tests.test_sbom_quality
tests.test_verify_sbom_release
tests.test_workspace_security
tests.test_security_workflow
-q
Expand All @@ -134,43 +141,33 @@ jobs:
with:
rust-version: stable
components: rustfmt
cache-key: cargo-security-sbom-${{ runner.os }}-${{ runner.arch }}-stable-${{ env.CARGO_CYCLONEDX_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
cache-key: cargo-security-sbom-${{ runner.os }}-${{ runner.arch }}-stable-${{ env.CARGO_CYCLONEDX_VERSION }}-${{ env.CARGO_DENY_VERSION }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install pinned cargo-cyclonedx
run: cargo install cargo-cyclonedx --version "${CARGO_CYCLONEDX_VERSION}" --locked
- name: Verify the locked all-feature workspace
run: cargo metadata --locked --all-features --format-version 1 > /dev/null
- name: Generate complete workspace CycloneDX JSON
run: >-
cargo cyclonedx --format json --all --all-features --target all
--spec-version 1.5
- name: Collect and post-process every workspace SBOM
- name: Install pinned cargo-deny license gate
run: cargo install cargo-deny --version "${CARGO_DENY_VERSION}" --locked
- name: Install checksum-pinned CycloneDX schema validator
run: |
python3 scripts/collect_workspace_sboms.py sbom-artifacts
python3 scripts/sbom_postprocess.py \
--cargo-toml Cargo.toml \
--declare-dependency-complete \
sbom-artifacts/*.cdx.json
./scripts/install-cyclonedx-cli.sh "${RUNNER_TEMP}/cyclonedx-cli"
echo "${RUNNER_TEMP}/cyclonedx-cli" >> "${GITHUB_PATH}"
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: stable
- name: Install pinned sbomqs
run: |
go install github.com/interlynk-io/sbomqs/v2@${SBOMQS_VERSION}
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- name: Enforce SBOM quality floor
run: |
sbomqs score --json sbom-artifacts/*.cdx.json > sbomqs-results.json
python3 scripts/check_sbom_quality.py \
--threshold "$SBOM_QUALITY_THRESHOLD" \
sbomqs-results.json
- name: Generate, enrich, validate, and score the complete SBOM set
run: ./scripts/generate-sboms.sh sbom-artifacts sbom-artifacts/sbomqs-results.json
- name: Upload machine-readable SBOM evidence
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v4
with:
name: sbom-quality-evidence
path: |
sbom-artifacts/*.cdx.json
sbomqs-results.json
sbom-artifacts/*.cdx.xml
sbom-artifacts/sbomqs-results.json
if-no-files-found: error
retention-days: 14

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
> workflow with the target version, label the generated PR `release`, and merge
> it. The tag workflow creates `v<version>` from the merge commit, and the
> publish workflow builds Debian, Arch Linux, OCI, user-documentation, and SBOM
> release artifacts.
> release artifacts. The SBOM archive contains schema-validated CycloneDX 1.6
> JSON and XML plus the sbomqs quality report; see [Releasing](RELEASING.md) for
> its checksum and verification contract.

REST gateway API for [Greenbone Vulnerability Management (GVM)](https://greenbone.github.io/docs/latest/), built on top of [rust-gvm](https://github.com/greenbone-hive/rust-gvm). REST is the implemented public gateway surface on `main`; MCP remains a planned peer adapter over the same shared core.

Expand Down
35 changes: 34 additions & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,35 @@ after a release.
- `gvm-gateway` Arch Linux packages (`.pkg.tar.zst`)
- `gvm-gateway` OCI image archives (`.oci.tar`)
- matching `.sha256` checksum files
- SBOM archives
- `rust-gvm-api-sbom.tar.gz`, containing CycloneDX 1.6 JSON and XML for all
seven inventoried workspace packages plus `sbomqs-results.json`
- `rust-gvm-api-sbom.tar.gz.sha256`

The release SBOM job runs the same `scripts/generate-sboms.sh` contract as
Security CI: cargo-cyclonedx 0.5.10 generation, a successful pinned cargo-deny
license check, conservative JSON enrichment, CycloneDX 1.6 schema validation,
and sbomqs 2.1.4 scoring with an inclusive 8.3 floor. The exact transformed
JSON files that are scored are the files placed in the archive. XML remains
generator-native but is schema-validated before packaging.

Before upload, `scripts/verify_sbom_release.py` verifies the archive checksum,
the exact seven JSON/XML pairs from the committed workspace inventory, release
version metadata, and one at-or-above-floor score for every archived JSON file.
It also rejects unexpected members. For local verification of downloaded
release evidence, run:

```bash
python3 -B scripts/verify_sbom_release.py \
rust-gvm-api-sbom.tar.gz \
rust-gvm-api-sbom.tar.gz.sha256
```

The archive deliberately contains no synthesized CPEs, dependency-completeness
claims, embedded CycloneDX signatures, or external release attestations. The
`.sha256` file authenticates archive bytes only; it is not an embedded SBOM
signature. License conclusions are limited to sole, simple SPDX identifiers
allowed by `deny.toml`, and exact crates.io distribution references are limited
to unqualified Cargo PURLs.

## Retry and Recovery

Expand Down Expand Up @@ -75,6 +103,11 @@ For local testing without releasing:
```bash
cargo build --locked --release -p gvm-gateway
cargo test
python3 -B -m unittest \
tests.test_sbom_postprocess \
tests.test_sbom_quality \
tests.test_verify_sbom_release \
tests.test_security_workflow -q
./scripts/build-binary-archive.sh --version "$(./scripts/workspace-version.sh)" --architecture amd64
./scripts/binary-archive-smoke.sh \
--archive "dist/binaries/gvm-gateway_$(./scripts/workspace-version.sh)_linux_amd64.tar.gz" \
Expand Down
46 changes: 32 additions & 14 deletions docs/WORKFLOW_SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,37 @@ For a dependency update:

## SBOM policy

Security installs the pinned `cargo-cyclonedx` release, verifies `Cargo.lock`
through `cargo metadata --locked --all-features`, and generates CycloneDX 1.5
JSON for every member of `supply-chain/workspace-packages.toml`.
`collect_workspace_sboms.py` fails unless exactly one generated document exists
for every inventoried package. `sbom_postprocess.py` adds deterministic document
licensing, build-lifecycle, supplier, repository, and completeness metadata;
`check_sbom_quality.py` fails if the machine-readable `sbomqs` result is absent,
malformed, or below 8.3 for any file. The generated SBOMs and score report are
uploaded as workflow evidence.

When updating `cargo-cyclonedx` or `sbomqs`, review release notes, update the
pinned version in Security (and the matching release-workflow pin for
`cargo-cyclonedx`), run the helper unit tests, generate the complete workspace
SBOM set, and confirm every score remains at least 8.3.
Security and tagged releases both call `scripts/generate-sboms.sh`; workflow
policy tests reject either lane reimplementing or bypassing that command
contract. The script verifies `Cargo.lock` through
`cargo metadata --locked --all-features`, then uses pinned `cargo-cyclonedx`
0.5.10 to generate CycloneDX 1.6 JSON and XML for every member of
`supply-chain/workspace-packages.toml`. `collect_workspace_sboms.py` fails unless
exactly one document of each format exists for every inventoried package. The
checksum-pinned CycloneDX CLI validates every post-processed JSON and
generator-native XML document against the 1.6 schemas.

License conclusions are opt-in and occur only after pinned `cargo-deny` 0.20.2
successfully checks `deny.toml` in the same script. A sole, simple Cargo SPDX
identifier in `[licenses].allow` becomes matching declared and concluded
license objects. Composite expressions, `LicenseRef` or custom values,
malformed or disallowed entries, non-Cargo components, and existing conclusions
remain untouched. Exact unqualified `pkg:cargo/name@version` PURLs receive a
URL-encoded crates.io distribution reference; qualified, fragmented, local,
and non-Cargo PURLs do not.

The transform also adds deterministic document licensing, build lifecycle,
supplier, and repository metadata. It deliberately does not synthesize CPEs,
CycloneDX signatures, or completeness claims. XML remains generator-native.
Pinned `sbomqs` 2.1.4 scores the exact transformed JSON files, and
`check_sbom_quality.py` fails if its machine-readable report is absent,
malformed, incomplete, or below 8.3 for any file. Security uploads both formats
and the report as workflow evidence.

When updating any SBOM tool, review its release notes and atomically update the
matching pins in Security and release publication. Run the helper and workflow
policy tests, generate all seven JSON/XML pairs, validate both formats, and
confirm every JSON score remains at least 8.3.

## First-party unsafe-code policy

Expand All @@ -88,6 +105,7 @@ Run the deterministic helper suite with:
python3 -B -m unittest \
tests.test_sbom_postprocess \
tests.test_sbom_quality \
tests.test_verify_sbom_release \
tests.test_workspace_security \
tests.test_security_workflow -q
cargo vet --locked
Expand Down
20 changes: 18 additions & 2 deletions docs/user/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@
## Release artifacts

Current releases publish Debian packages, Arch Linux packages, an OCI image
archive, and this user documentation package with the matching OpenAPI
specification.
archive, this user documentation package with the matching OpenAPI
specification, and `rust-gvm-api-sbom.tar.gz` with its `.sha256` checksum. The
SBOM archive contains CycloneDX 1.6 JSON and XML for all seven workspace
packages plus a machine-readable `sbomqs-results.json`; every JSON score is at
least 8.3 under sbomqs 2.1.4.

Verify the checksum with `sha256sum --check rust-gvm-api-sbom.tar.gz.sha256`.
Maintainers and source users can additionally run this from a matching checkout:

```bash
python3 -B scripts/verify_sbom_release.py \
rust-gvm-api-sbom.tar.gz \
rust-gvm-api-sbom.tar.gz.sha256
```

The archive does not claim dependency completeness, synthesize CPEs, or contain
embedded CycloneDX signatures or external attestations; the separate checksum
is not an embedded signature.

Choose the package or container form that matches your environment.

Expand Down
3 changes: 3 additions & 0 deletions requirements-security.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Safe XML parsing for release evidence. The hash pins the universal PyPI wheel.
defusedxml==0.7.1 \
--hash=sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61
28 changes: 22 additions & 6 deletions scripts/collect_workspace_sboms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
SUPPORTED_FORMATS = ("json", "xml")


def collect(destination: Path, formats: tuple[str, ...] = ("json",)) -> list[Path]:
def collect(
destination: Path,
formats: tuple[str, ...] = ("json",),
remove_sources: bool = False,
) -> list[Path]:
destination = destination.resolve()
destination.mkdir(parents=True, exist_ok=True)
collected = []
sources: list[Path] = []
for package in validated_inventory():
package_dir = (ROOT / package.manifest).parent
for document_format in formats:
Expand All @@ -30,9 +33,17 @@ def collect(destination: Path, formats: tuple[str, ...] = ("json",)) -> list[Pat
f"expected one {document_format.upper()} SBOM for {package.name} "
f"beside {package.manifest}"
)
target = destination / source.name
sources.append(source)

destination.mkdir(parents=True, exist_ok=True)
collected = []
for source in sources:
target = destination / source.name
if remove_sources:
shutil.move(source, target)
else:
shutil.copyfile(source, target)
collected.append(target)
collected.append(target)
return collected


Expand All @@ -45,11 +56,16 @@ def main(argv: list[str]) -> int:
dest="formats",
help="document format to collect; repeat for multiple formats (default: json)",
)
parser.add_argument(
"--remove-sources",
action="store_true",
help="move generated package-adjacent documents into the destination",
)
parser.add_argument("destination", type=Path)
args = parser.parse_args(argv)
try:
formats = tuple(dict.fromkeys(args.formats or ("json",)))
collected = collect(args.destination, formats)
collected = collect(args.destination, formats, args.remove_sources)
except (OSError, ValueError) as error:
print(f"error: {error}", file=sys.stderr)
return 2
Expand Down
Loading
Loading