#!/usr/bin/env bash
# Scans the applications of a CoreMedia Content Cloud release with Trivy, using the
# published SBOM and VEX files.
#
# Usage: scan-sbom-vex.sh <release-files-url> [additional trivy options]
# <release-files-url> is the "SBOM & VEX (JSON)" link of the release or a local copy
# of the JSON document.
#
# Environment:
# CM_NEXUS_USER user name for the CoreMedia Nexus repository
# CM_NEXUS_PASSWORD password or token for the CoreMedia Nexus repository
#
# Example: scan-sbom-vex.sh "$URL" --severity HIGH,CRITICAL --exit-code 1
# The script exits with a non-zero status if a download fails or if Trivy fails, which
# includes findings when --exit-code 1 is given.
set -euo pipefail
[ $# -ge 1 ] || { echo "Usage: $0 <release-files-url> [trivy options]" >&2; exit 1; }
source_ref="$1"
shift
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
download() { # <url> <target file>
local auth=()
[ -n "${CM_NEXUS_USER:-}" ] && auth=(-u "${CM_NEXUS_USER}:${CM_NEXUS_PASSWORD:-}")
curl -fsSL ${auth[@]+"${auth[@]}"} -o "$2" "$1"
}
# Collect the download URLs of all pages of the search result
: > "$tmp/urls.txt"
if [ -f "$source_ref" ]; then
# A local copy cannot be paged, so it must contain the complete result
if [ -n "$(jq -r '.continuationToken // empty' "$source_ref")" ]; then
echo "$source_ref is an incomplete page of the search result; use the JSON link instead" >&2
exit 1
fi
jq -r '.items[].assets[].downloadUrl' "$source_ref" >> "$tmp/urls.txt"
else
token=""
while :; do
download "${source_ref}${token:+&continuationToken=${token}}" "$tmp/page.json"
jq -r '.items[].assets[].downloadUrl' "$tmp/page.json" >> "$tmp/urls.txt"
token="$(jq -r '.continuationToken // empty' "$tmp/page.json")"
[ -n "$token" ] || break
done
fi
# To scan SBOMs of your customized Blueprint or Docker images instead of the published
# SBOMs, replace the download of "$sbom_url" and the trivy call below accordingly.
status=0
found=0
while IFS= read -r sbom_url <&3; do
found=$((found + 1))
vex_url="${sbom_url%.sbom.json}.vex.json"
echo "==> ${sbom_url%/application.sbom.json}"
download "$sbom_url" "$tmp/sbom.json"
vex=()
if grep -qxF "$vex_url" "$tmp/urls.txt"; then
download "$vex_url" "$tmp/vex.json"
vex=(--vex "$tmp/vex.json" --show-suppressed)
else
echo "No VEX file found, scanning without it" >&2
fi
trivy sbom --quiet ${vex[@]+"${vex[@]}"} ${@+"$@"} "$tmp/sbom.json" || status=1
done 3< <(grep '\.sbom\.json$' "$tmp/urls.txt")
[ "$found" -gt 0 ] || { echo "No SBOM files found at ${source_ref}" >&2; exit 1; }
exit "$status"
Downloading SBOM and VEX Files for a Release
Learn what SBOM and VEX files are and where you can download them for a CoreMedia Content Cloud release.
What you will learn
- Understand what SBOM and VEX files are
- Find and download the SBOM and VEX files of a CoreMedia Content Cloud release
Prerequisites
- Having a CoreMedia Content Cloud release in use
Target Audience
Many organizations need to know exactly which third-party libraries are part of the software they run and whether known vulnerabilities in those libraries actually affect them. For this purpose, CoreMedia publishes a Software Bill of Materials (SBOM) and a Vulnerability Exploitability eXchange (VEX) file for the applications of a CoreMedia Content Cloud release. This guide explains what these files contain and where you can download them.
What are SBOM and VEX Files?
A Software Bill of Materials (SBOM) is a machine-readable inventory of all components, libraries and their versions that an application consists of. It is comparable to an ingredients list. With an SBOM you can:
-
find out which libraries are included in a release,
-
check your installation against newly discovered vulnerabilities, and
-
fulfil the supply chain requirements of your organization or of regulations.
A Vulnerability Exploitability eXchange (VEX) document complements the SBOM. Scanners that compare an SBOM with vulnerability databases often report vulnerabilities that cannot be exploited in the way the application uses the library. A VEX document states for each known vulnerability whether the application is affected, not affected or under investigation, and gives a justification. This helps you to concentrate on the findings that really matter.
CoreMedia provides both file types in the CycloneDX JSON format. Every application of a release has its own SBOM and its own VEX file.
| An SBOM does not change after a release has been published. A VEX file, however, may be updated after the release, because new vulnerabilities become known over time. Download the VEX files again from time to time to get the current assessment. |
Where to Find the Files
The files are linked from the Releases page of your CoreMedia Content Cloud version. Proceed as follows:
-
Open the download page of a release, for example the page for CoreMedia Content Cloud 2512.1.2:
-
Select the version you are interested in. The concrete release can be selected on this page.
-
In the section of the product you are interested in, for example Blueprint Workspace, click one of the SBOM & VEX links next to the download links. The links are shown in every section for which SBOM and VEX files are available:
-
SBOM & VEX (Nexus UI) opens the files of the release in the CoreMedia Nexus repository browser, where you can download them.
-
SBOM & VEX (JSON) returns a JSON document that lists the files of the release, including their download URLs. Use it to retrieve the files automatically.
Authentication required: Before opening the SBOM & VEX (JSON) link, open the SBOM & VEX (Nexus UI) link and sign in to Nexus in the same browser. Then open the JSON link again. For scripted access, provide your Nexus credentials as shown below.
-
-
Download the SBOM and VEX file of each application.
|
SBOM and VEX files are only available for newer releases. If a release does not show an SBOM & VEX link on its download page, no files have been published for it. |
Scanning the Files with Trivy
You can scan a release for vulnerabilities with Trivy, for example in a CI job. The following script reads the list of files that is linked as SBOM & VEX (JSON) on the download page. It downloads the SBOM and VEX file of every application of the release and scans each SBOM with Trivy. The VEX file is applied, so vulnerabilities that CoreMedia has assessed as not affecting the application are suppressed. Trivy lists the suppressed vulnerabilities separately.
|
The script in this guide is an example that shows how to scan the files. You may need to adjust it to the requirements and the environment of your organization. CoreMedia does not update it regularly. The script scans the SBOMs that CoreMedia publishes for the standard Blueprint and additional components. If you have customized your Blueprint workspace, you may want to replace the downloaded SBOMs with ones that you generate specifically for your customized Blueprint, or scan your Docker images instead (for example with If you write your own scripts that process the JSON document, these properties of each entry in
|
Prerequisites
The Script
Save the following script as scan-sbom-vex.sh:
Usage
Pass the SBOM & VEX (JSON) link of the release, followed by any Trivy options you want to use. Copy the link address from the download page:
export CM_NEXUS_USER=<user>
export CM_NEXUS_PASSWORD=<password-or-token>
bash scan-sbom-vex.sh \
"https://repository.coremedia.com/nexus/service/rest/v1/search?repository=sbom&tag=cms-cmcc-13-2512.1.2" \
--severity HIGH,CRITICAL --exit-code 1
The script runs Trivy with --quiet, which suppresses the progress and log output, for example the many Unsupported hash algorithm warnings that Trivy logs for the SHA3 hashes in the SBOMs. These warnings are harmless. Remove --quiet from the script if you want to see the log output.
| Use the SBOM & VEX (JSON) link only. The script cannot process the Nexus UI link, which is meant for browsing the files in a web browser. |
With --exit-code 1, the script fails if any vulnerability of the selected severities remains after applying the VEX files. This makes it suitable for CI jobs.