Skip to content

Instantly share code, notes, and snippets.

@sunsided
Last active January 12, 2024 19:03
Show Gist options
  • Save sunsided/cec429eaf7c51dd0374f207d68daa675 to your computer and use it in GitHub Desktop.
Save sunsided/cec429eaf7c51dd0374f207d68daa675 to your computer and use it in GitHub Desktop.
Create SBOMs in SPDX and CycloneDX format for a local repository
#!/usr/bin/env bash
set -euo pipefail
CACHE=$(realpath ~/.cache/trivy)
if [ $# -eq 0 ]; then
echo "Please specify a local repository to scan."
exit 1
else
REPO=$(realpath $1)
docker run --rm -it --user "$(id -u):$(id -g)" -v "$CACHE:/.cache/trivy:rw" -v "$REPO:/code:rw" aquasec/trivy fs --format spdx-json --output /code/sbom-spdx.json /code
docker run --rm -it --user "$(id -u):$(id -g)" -v "$CACHE:/.cache/trivy:rw" -v "$REPO:/code:rw" aquasec/trivy fs --format cyclonedx --output /code/sbom-cyclonedx.json /code
fi
#!/usr/bin/env bash
set -euo pipefail
if [ $# -eq 0 ]; then
echo "Please specify a local repository to scan."
exit 1
else
REPO=$(realpath $1)
docker run --rm -it -v "$REPO:/code:ro" aquasec/trivy fs /code
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment