You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tooling.apache.org by ar...@apache.org on 2026/07/16 09:59:43 UTC
(tooling-trusted-releases) branch arm updated (dca4c2f2 -> b0311e37)
This is an automated email from the ASF dual-hosted git repository.
alitheg pushed a change to branch arm
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
discard dca4c2f2 #1403 - validate spec parity in SBOM tooling
new b0311e37 #1403 - validate spec parity in SBOM tooling
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (dca4c2f2)
\
N -- N -- N refs/heads/arm (b0311e37)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.github/workflows/build.yml | 5 +++++
Dockerfile.alpine | 14 ++++++++------
scripts/ci/check_syft_cli_spec.sh | 4 ++--
3 files changed, 15 insertions(+), 8 deletions(-)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org
(tooling-trusted-releases) 01/01: #1403 - validate spec parity in SBOM tooling
Posted by ar...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alitheg pushed a commit to branch arm
in repository https://gitbox.apache.org/repos/asf/tooling-trusted-releases.git
commit b0311e37d52a28ed472919aaf2bf720611394294
Author: Alastair McFarlane <ar...@apache.org>
AuthorDate: Thu Jul 16 10:26:35 2026 +0100
#1403 - validate spec parity in SBOM tooling
---
.github/workflows/build.yml | 5 ++
.github/workflows/generatesbom.yml | 5 ++
Dockerfile.alpine | 21 ++++---
scripts/ci/check_sbom_spec_parity.py | 116 +++++++++++++++++++++++++++++++++++
scripts/ci/check_syft_cli_spec.sh | 21 +++++++
5 files changed, 161 insertions(+), 7 deletions(-)
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b83e5669..4b9540c5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -107,6 +107,11 @@ jobs:
-H "Accept: application/vnd.github+json" \
"${api}/issues" -d "$data" >/dev/null
+ - name: Build image and check SBOM spec parity
+ run: |
+ docker build -f Dockerfile.alpine -t atr:ci .
+ docker run --rm atr:ci .venv/bin/python scripts/ci/check_sbom_spec_parity.py --require-tools
+
- name: Run Playwright end-to-end tests
run: |
sh tests/run-playwright.sh
diff --git a/.github/workflows/generatesbom.yml b/.github/workflows/generatesbom.yml
index b165bc1e..5ff1c79f 100644
--- a/.github/workflows/generatesbom.yml
+++ b/.github/workflows/generatesbom.yml
@@ -32,6 +32,11 @@ jobs:
cache-from: type=gha
cache-to: type=gha,mode=max
+ - name: Check SBOM toolchain spec parity
+ run: |
+ docker run --rm tooling-trusted-release:latest \
+ .venv/bin/python scripts/ci/check_sbom_spec_parity.py --require-tools
+
- name: Generate SBOM
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
with:
diff --git a/Dockerfile.alpine b/Dockerfile.alpine
index 698afd95..50680913 100644
--- a/Dockerfile.alpine
+++ b/Dockerfile.alpine
@@ -40,7 +40,8 @@ FROM python:3.14.5-alpine3.22 AS depbuilder
RUN apk update && \
apk add --no-cache \
curl \
- go
+ go \
+ icu-libs
# install additional tools
ENV RAT_VERSION=0.18
@@ -58,26 +59,32 @@ RUN set -eux; \
rm -rf /tmp/apache-rat
# WORKDIR /var/run
-ENV SYFT_VERSION=1.38.2
-ENV SYFT_INSTALL_SHA256=01d0d15aff461f1bc54d1716feb4824341918c4f37e1b6a5a0c0caee2251be67
+ENV SYFT_VERSION=1.46.0
+ENV SYFT_INSTALL_SHA256=8a277b4b4dc21809ecd9a0e4926f4d7319affc6451a607fdeb3e5e1fbd9bc573
+ENV SYFT_SHA256=574df1a0862ff88ad933be214e81069e35b17618a13e019f8f1c84fe063222a2
# RUN GOPATH=/usr/local go install github.com/anchore/syft/cmd/syft@v${SYFT_VERSION}
-# TODO: This is much faster than the above, but we should figure out how to pin the binaries
+# Faster than a go-install; the resulting binary is pinned by SHA after install
RUN curl -fsSL https://raw.githubusercontent.com/anchore/syft/v${SYFT_VERSION}/install.sh -o /tmp/syft-install.sh && \
echo "${SYFT_INSTALL_SHA256} /tmp/syft-install.sh" | sha256sum -c - && \
- sh /tmp/syft-install.sh -b /usr/local/bin && \
+ sh /tmp/syft-install.sh -b /usr/local/bin "v${SYFT_VERSION}" && \
+ echo "${SYFT_SHA256} /usr/local/bin/syft" | sha256sum -c - && \
rm -f /tmp/syft-install.sh
ENV PARLAY_VERSION=0.9.0
RUN GOPATH=/usr/local go install github.com/snyk/parlay@v${PARLAY_VERSION}
ENV SBOMQS_VERSION=1.1.0
RUN GOPATH=/usr/local go install github.com/interlynk-io/sbomqs@v${SBOMQS_VERSION}
-ENV CDXCLI_VERSION=0.29.1
-ENV CDXCLI_SHA256=526d55f67ac53744f45525f30f0f210d3a95e044b5073904cb3eacb8f8e52135
+ENV CDXCLI_VERSION=0.32.0
+ENV CDXCLI_SHA256=29138e6068e6cf2dc60e776d078c2b17cbf45750c485aa12c28e1fef5556a15f
RUN curl -fsSL https://github.com/CycloneDX/cyclonedx-cli/releases/download/v${CDXCLI_VERSION}/cyclonedx-linux-musl-x64 \
-o /usr/local/bin/cyclonedx && \
echo "${CDXCLI_SHA256} /usr/local/bin/cyclonedx" | sha256sum -c - && \
chmod +x /usr/local/bin/cyclonedx
+# Refuse to build a stage whose syft emits a spec the CLI cannot validate
+COPY scripts/ci/check_syft_cli_spec.sh /tmp/check_syft_cli_spec.sh
+RUN sh /tmp/check_syft_cli_spec.sh
+
# final image
FROM python:3.14.5-alpine3.22
diff --git a/scripts/ci/check_sbom_spec_parity.py b/scripts/ci/check_sbom_spec_parity.py
new file mode 100755
index 00000000..c4d8a755
--- /dev/null
+++ b/scripts/ci/check_sbom_spec_parity.py
@@ -0,0 +1,116 @@
+#!/usr/bin/env python3
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Check that the installed SBOM toolchain agrees on a CycloneDX spec version.
+
+syft generates SBOMs, the CycloneDX CLI validates them, and cyclonedx-python-lib parses
+and re-serialises them. If syft or the lib can emit a spec version the CLI cannot
+validate, the platform produces files it then rejects. This is meant to run inside the
+built image, where all three are present.
+"""
+
+import json
+import shutil
+import subprocess
+import sys
+import tempfile
+from typing import Final
+
+import cyclonedx.exception.output as exc_output
+import cyclonedx.model.bom as bom
+import cyclonedx.output as output
+import cyclonedx.schema as schema
+
+_ISSUE_REF: Final = "issue #1403"
+_PROBE_MARKER: Final = "placeholder.txt"
+
+
+def cli_accepts(cyclonedx_bin: str, document: str) -> bool:
+ with tempfile.NamedTemporaryFile("w", suffix=".cdx.json") as handle:
+ handle.write(document)
+ handle.flush()
+ proc = subprocess.run(
+ [cyclonedx_bin, "validate", "--fail-on-errors", "--input-format", "json", "--input-file", handle.name],
+ text=True,
+ capture_output=True,
+ check=False,
+ )
+ return proc.returncode == 0
+
+
+def cli_supported_versions(cyclonedx_bin: str) -> list[schema.SchemaVersion]:
+ supported = []
+ for version in schema.SchemaVersion:
+ try:
+ rendered = output.make_outputter(
+ bom=bom.Bom(), output_format=schema.OutputFormat.JSON, schema_version=version
+ ).output_as_string()
+ except exc_output.FormatNotSupportedException:
+ # JSON only exists from spec 1.2 onward, so the older versions never apply here
+ continue
+ if cli_accepts(cyclonedx_bin, rendered):
+ supported.append(version)
+ return supported
+
+
+def main() -> int:
+ syft_bin = shutil.which("syft")
+ cyclonedx_bin = shutil.which("cyclonedx")
+ require_tools = "--require-tools" in sys.argv[1:]
+ if (syft_bin is None) or (cyclonedx_bin is None):
+ missing = f"syft={syft_bin} cyclonedx={cyclonedx_bin}"
+ if require_tools:
+ print(f"FAIL: SBOM tools not both present ({missing})", file=sys.stderr)
+ return 1
+ print(f"SKIP: SBOM tools not both present ({missing})")
+ return 0
+
+ cli_versions = cli_supported_versions(cyclonedx_bin)
+ lib_ceiling = max(schema.SchemaVersion)
+ syft_spec = syft_default_spec(syft_bin)
+ syft_version = schema.SchemaVersion.from_version(syft_spec)
+
+ print(f"CLI validates: {sorted(v.to_version() for v in cli_versions)}")
+ print(f"lib can emit up to: {lib_ceiling.to_version()}")
+ print(f"syft emits: {syft_spec}")
+
+ problems = []
+ if syft_version not in cli_versions:
+ problems.append(f"syft emits {syft_spec} but the CLI cannot validate it (syft to CLI)")
+ if lib_ceiling not in cli_versions:
+ problems.append(f"lib can emit {lib_ceiling.to_version()} but the CLI cannot validate it (lib to CLI)")
+ if problems:
+ for problem in problems:
+ print(f"FAIL: {problem} - see {_ISSUE_REF}", file=sys.stderr)
+ return 1
+
+ print("PASS: syft, the CLI, and cyclonedx-python-lib agree on a CycloneDX spec")
+ return 0
+
+
+def syft_default_spec(syft_bin: str) -> str:
+ with tempfile.TemporaryDirectory() as work:
+ with open(f"{work}/{_PROBE_MARKER}", "w", encoding="utf-8") as handle:
+ handle.write("placeholder\n")
+ proc = subprocess.run([syft_bin, work, "-o", "cyclonedx-json"], text=True, capture_output=True, check=True)
+ return json.loads(proc.stdout).get("specVersion", "")
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/scripts/ci/check_syft_cli_spec.sh b/scripts/ci/check_syft_cli_spec.sh
new file mode 100755
index 00000000..b012540b
--- /dev/null
+++ b/scripts/ci/check_syft_cli_spec.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Fail if syft emits a CycloneDX spec version the bundled CLI cannot validate.
+
+set -eu
+
+work="$(mktemp -d)"
+trap 'rm -rf "$work"' EXIT
+
+printf 'placeholder\n' > "$work/placeholder.txt"
+syft "$work" -o cyclonedx-json > "$work/sbom.cdx.json" 2>/dev/null
+
+spec="$(sed -n 's/.*"specVersion"[[:space:]]*:[[:space:]]*"\([^"]*\)".*/\1/p' "$work/sbom.cdx.json" | head -n1)"
+printf 'syft emits CycloneDX spec %s\n' "$spec"
+
+if out="$(cyclonedx validate --fail-on-errors --input-format json --input-file "$work/sbom.cdx.json" 2>&1)"
+then
+ printf 'PASS: CDX CLI validates syft output - both agree on spec %s\n' "$spec"
+else
+ printf 'FAIL: CDX CLI cannot validate syft output spec %s\n%s\n' "$spec" "$out" >&2
+ exit 1
+fi
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@tooling.apache.org
For additional commands, e-mail: commits-help@tooling.apache.org