mirror of
https://github.com/marcoallegretti/karapace.git
synced 2026-03-26 21:43:09 +00:00
fix supply chain: bump cargo-cyclonedx 0.5.7, fix SBOM generation, fix rmeta test
- Bump cargo-cyclonedx from 0.5.5 to 0.5.7 (supports lockfile v4) - Generate SBOM for karapace-cli crate only (single predictable file) - Fix --output-prefix → --override-filename (CLI change in 0.5.x) - Fix rmeta tampering test: accept build failure as valid defense (cargo rejects corrupted .rmeta with compilation errors)
This commit is contained in:
parent
e8c0af0ac4
commit
62b9b569be
12 changed files with 20 additions and 23385 deletions
11
.github/workflows/release.yml
vendored
11
.github/workflows/release.yml
vendored
|
|
@ -45,9 +45,11 @@ jobs:
|
||||||
- name: Build release binaries
|
- name: Build release binaries
|
||||||
run: cargo build --release --workspace --target ${{ matrix.target }}
|
run: cargo build --release --workspace --target ${{ matrix.target }}
|
||||||
- name: Install cargo-cyclonedx
|
- name: Install cargo-cyclonedx
|
||||||
run: cargo install cargo-cyclonedx@0.5.5 --locked
|
run: cargo install cargo-cyclonedx@0.5.7 --locked
|
||||||
- name: Generate SBOM
|
- name: Generate SBOM
|
||||||
run: cargo cyclonedx --format json --all
|
run: |
|
||||||
|
cargo cyclonedx --manifest-path crates/karapace-cli/Cargo.toml --format json --override-filename karapace_bom
|
||||||
|
mv crates/karapace-cli/karapace_bom.json .
|
||||||
- name: Compute and verify checksums
|
- name: Compute and verify checksums
|
||||||
run: |
|
run: |
|
||||||
cd target/${{ matrix.target }}/release
|
cd target/${{ matrix.target }}/release
|
||||||
|
|
@ -55,13 +57,12 @@ jobs:
|
||||||
sha256sum -c SHA256SUMS
|
sha256sum -c SHA256SUMS
|
||||||
- name: Validate SBOM
|
- name: Validate SBOM
|
||||||
run: |
|
run: |
|
||||||
SBOM=$(find crates/karapace-cli -name '*.cdx.json' | head -1)
|
|
||||||
python3 -c "
|
python3 -c "
|
||||||
import json
|
import json
|
||||||
with open('$SBOM') as f:
|
with open('karapace_bom.json') as f:
|
||||||
bom = json.load(f)
|
bom = json.load(f)
|
||||||
assert 'components' in bom and len(bom['components']) > 0
|
assert 'components' in bom and len(bom['components']) > 0
|
||||||
print(f'SBOM valid: {len(bom[\"components\"])} components')
|
print(f'SBOM valid: {len(bom["components"])} components')
|
||||||
"
|
"
|
||||||
- name: Verify static linking (musl only)
|
- name: Verify static linking (musl only)
|
||||||
if: contains(matrix.target, 'musl')
|
if: contains(matrix.target, 'musl')
|
||||||
|
|
|
||||||
16
.github/workflows/supply-chain-test.yml
vendored
16
.github/workflows/supply-chain-test.yml
vendored
|
|
@ -41,10 +41,12 @@ jobs:
|
||||||
run: cargo build --release -p karapace-cli -p karapace-dbus
|
run: cargo build --release -p karapace-cli -p karapace-dbus
|
||||||
|
|
||||||
- name: Install cargo-cyclonedx
|
- name: Install cargo-cyclonedx
|
||||||
run: cargo install cargo-cyclonedx@0.5.5 --locked
|
run: cargo install cargo-cyclonedx@0.5.7 --locked
|
||||||
|
|
||||||
- name: Generate SBOM
|
- name: Generate SBOM
|
||||||
run: cargo cyclonedx --format json --output-prefix karapace
|
run: |
|
||||||
|
cargo cyclonedx --manifest-path crates/karapace-cli/Cargo.toml --format json --override-filename karapace_bom
|
||||||
|
mv crates/karapace-cli/karapace_bom.json .
|
||||||
|
|
||||||
- name: Compute checksums
|
- name: Compute checksums
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -505,7 +507,7 @@ jobs:
|
||||||
fi
|
fi
|
||||||
echo "PASS: Clean rebuild matches baseline after multi-rlib tampering"
|
echo "PASS: Clean rebuild matches baseline after multi-rlib tampering"
|
||||||
|
|
||||||
- name: "Test: .rmeta tampering triggers rebuild"
|
- name: "Test: .rmeta tampering triggers rebuild or error"
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
BASELINE_HASH=$(sha256sum target/release/karapace | awk '{print $1}')
|
BASELINE_HASH=$(sha256sum target/release/karapace | awk '{print $1}')
|
||||||
|
|
@ -516,12 +518,16 @@ jobs:
|
||||||
open('$RMETA', 'wb').write(data)
|
open('$RMETA', 'wb').write(data)
|
||||||
"
|
"
|
||||||
done
|
done
|
||||||
cargo build --release -p karapace-cli -p karapace-dbus 2>&1 | tail -3
|
# Build may fail (cargo detects corrupted rmeta) or rebuild from source
|
||||||
|
if ! cargo build --release -p karapace-cli -p karapace-dbus 2>&1 | tail -5; then
|
||||||
|
echo "PASS: Cargo rejected tampered .rmeta files (build error = tampering detected)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
RMETA_HASH=$(sha256sum target/release/karapace | awk '{print $1}')
|
RMETA_HASH=$(sha256sum target/release/karapace | awk '{print $1}')
|
||||||
if [ "$RMETA_HASH" = "$BASELINE_HASH" ]; then
|
if [ "$RMETA_HASH" = "$BASELINE_HASH" ]; then
|
||||||
echo "PASS: Cargo rebuilt from source, ignoring tampered .rmeta"
|
echo "PASS: Cargo rebuilt from source, ignoring tampered .rmeta"
|
||||||
else
|
else
|
||||||
echo "FATAL: .rmeta tampering changed binary hash"
|
echo "FATAL: .rmeta tampering changed binary hash without detection"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -3,8 +3,8 @@ set -euo pipefail
|
||||||
|
|
||||||
command -v cargo-cyclonedx >/dev/null 2>&1 || {
|
command -v cargo-cyclonedx >/dev/null 2>&1 || {
|
||||||
echo "Installing cargo-cyclonedx..."
|
echo "Installing cargo-cyclonedx..."
|
||||||
cargo install cargo-cyclonedx@0.5.5 --locked
|
cargo install cargo-cyclonedx@0.5.7 --locked
|
||||||
}
|
}
|
||||||
|
|
||||||
cargo cyclonedx --format json --output-prefix karapace
|
cargo cyclonedx --format json --override-filename karapace_bom
|
||||||
echo "SBOM written to karapace_bom.json"
|
echo "SBOM written to karapace_bom.cdx.json"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue