Skip to content

A free, open-source alternative to Burp Suite: an intercepting proxy and web app security testing suite with Repeater, Intruder, Collaborator and a built-in OWASP ZAP scanner. Linux, AGPL-3.0.

5.5 KB
Raw Blame
#!/usr/bin/env bash
# Report whether the tools Open Suite bundles have newer upstream releases, and
# whether the jars in lib/ are the ones tools/versions pins.
#
# It changes nothing: it prints the pinned version, the latest upstream
# version and whether an update is available, so you can decide what to bump
# in tools/versions. Run it before every release.
#
# With --strict it also fails (exit 1) when a library, the Java runtime or the
# scan engine or one of its add-ons is behind, when a browser pin is older than
# the stable browser release, when a jar in lib/ does not match
# its pinned hash, or when a lookup failed: a check that could not look is not
# a check that passed. The weekly workflow runs it that way.
#
# Deliberately not set -e: one failed upstream lookup must not stop the rest of
# the report.
set -u
DIR="$(cd "$(dirname "$0")/.." && pwd)"
source "$DIR/tools/versions"
STRICT=0; [ "${1:-}" = "--strict" ] && STRICT=1
BAD=0

row() { printf '  %-22s pinned %-11s latest %-11s %s\n' "$1" "$2" "$3" "$4"; }

# check <name> <pinned> <latest>: a version that should equal the newest release.
check() {
    local st
    if [ -z "$3" ]; then st="LOOKUP FAILED"; BAD=1
    elif [ "$2" != "$3" ]; then st="UPDATE AVAILABLE"; BAD=1
    else st="up to date"; fi
    row "$1" "${2:-?}" "${3:-?}" "$st"
}

# Chromium snapshots are built continuously, so a pin is always behind the
# newest one. What matters is the stable release: a pin from before the point
# the current stable version was branched at is a browser older than the one
# people are running, and counts as behind.
# browser <name> <pinned revision> <chromiumdash platform>
browser() {
    local st stable pos ver
    stable="$(curl -fsS --max-time 20 "https://chromiumdash.appspot.com/fetch_releases?channel=Stable&platform=$3&num=1" 2>/dev/null)"
    pos="$(printf '%s' "$stable" | grep -oE '"chromium_main_branch_position": *[0-9]+' | head -1 | grep -oE '[0-9]+$')"
    ver="$(printf '%s' "$stable" | grep -oE '"version": *"[^"]*"' | head -1 | cut -d'"' -f4)"
    if [ -z "$pos" ]; then st="LOOKUP FAILED"; BAD=1
    elif [ "$2" -lt "$pos" ]; then st="OLDER THAN STABLE $ver"; BAD=1
    else st="at or after stable $ver"; fi
    row "$1" "$2" "${pos:-?}" "$st"
}

# The newest release of a Maven Central artifact, from its own metadata file.
maven() {
    curl -fsS --max-time 20 "https://repo1.maven.org/maven2/$1/maven-metadata.xml" 2>/dev/null \
        | grep -oE '<release>[^<]*' | head -1 | cut -d'>' -f2
}

# jar <file in lib/> <pinned sha256>
jar() {
    local got
    got="$( { sha256sum "$DIR/lib/$1" 2>/dev/null || shasum -a 256 "$DIR/lib/$1" 2>/dev/null; } | cut -d' ' -f1)"
    if [ -n "$got" ] && [ "$got" = "$2" ]; then printf '  %-30s matches its pinned hash\n' "$1"
    else printf '  %-30s DOES NOT MATCH its pinned hash\n' "$1"; BAD=1; fi
}

echo "Open Suite bundled tool versions:"
echo

# ZAP engine: latest GitHub release tag.
ZAP_LATEST=$(curl -fsS --max-time 20 https://api.github.com/repos/zaproxy/zaproxy/releases/latest 2>/dev/null \
    | grep -oE '"tag_name": *"[^"]*"' | head -1 | cut -d'"' -f4 | sed 's/^v//')
check "zap-engine" "${ZAP_VERSION:-}" "$ZAP_LATEST"

# The Java runtime every package carries: the newest Temurin release of the pinned major.
JDK_LATEST=$(curl -fsS --max-time 20 "https://api.adoptium.net/v3/assets/latest/${JDK_VERSION%%.*}/hotspot?os=linux&architecture=x64&image_type=jdk" 2>/dev/null \
    | grep -oE '"release_name": *"[^"]*"' | head -1 | cut -d'"' -f4 | sed 's/^jdk-//')
check "java-runtime" "$JDK_VERSION" "$JDK_LATEST"

# The engine add-ons fetched beside the Core package: the versions its own
# marketplace lists for this engine release.
ZAP_SERIES="$(printf '%s' "${ZAP_VERSION:-}" | cut -d. -f1,2)"
ADDONS="$(curl -fsS --max-time 30 "https://raw.githubusercontent.com/zaproxy/zap-admin/master/ZapVersions-$ZAP_SERIES.xml" 2>/dev/null)"
addon() { # <id in the marketplace> <pinned version>
    local latest
    latest="$(printf '%s\n' "$ADDONS" | awk -v t="<addon_$1>" 'index($0,t){f=1} f && /<version>/{gsub(/.*<version>|<\/version>.*/,""); print; exit}')"
    check "addon $1" "$2" "$latest"
}
addon selenium "$ZAP_ADDON_SELENIUM"
addon spiderAjax "$ZAP_ADDON_SPIDERAJAX"
addon commonlib "$ZAP_ADDON_COMMONLIB"
addon ascanrulesBeta "$ZAP_ADDON_ASCANRULES_BETA"
addon pscanrulesBeta "$ZAP_ADDON_PSCANRULES_BETA"
addon replacer "$ZAP_ADDON_REPLACER"
addon scripts "$ZAP_ADDON_SCRIPTS"
addon zest "$ZAP_ADDON_ZEST"
addon authhelper "$ZAP_ADDON_AUTHHELPER"
addon openapi "$ZAP_ADDON_OPENAPI"
addon soap "$ZAP_ADDON_SOAP"
addon graphql "$ZAP_ADDON_GRAPHQL"

# Chromium: each platform's pin against the stable release.
browser "chromium" "$CHROMIUM_REVISION" Linux
browser "chromium-windows" "$CHROMIUM_REVISION_WINDOWS" Windows
browser "chromium-mac" "$CHROMIUM_REVISION_MAC_ARM" Mac

# The vendored jars: the newest release on Maven Central.
check "bouncycastle" "$BOUNCYCASTLE_VERSION" "$(maven org/bouncycastle/bcprov-jdk18on)"
check "brotli-dec" "$BROTLI_DEC_VERSION" "$(maven org/brotli/dec)"

echo
echo "Vendored jars in lib/:"
echo
jar "bcprov-jdk18on-$BOUNCYCASTLE_VERSION.jar" "$BOUNCYCASTLE_PROV_SHA256"
jar "bcpkix-jdk18on-$BOUNCYCASTLE_VERSION.jar" "$BOUNCYCASTLE_PKIX_SHA256"
jar "bcutil-jdk18on-$BOUNCYCASTLE_VERSION.jar" "$BOUNCYCASTLE_UTIL_SHA256"
jar "dec-$BROTLI_DEC_VERSION.jar" "$BROTLI_DEC_SHA256"

echo
echo "To update: edit tools/versions (a version and its SHA256 together),"
echo "then run the matching fetch script (./fetch-zap.sh, ./fetch-browser.sh)"
echo "or replace the jar in lib/."

if [ "$STRICT" = 1 ] && [ "$BAD" = 1 ]; then
    echo
    echo "Something above needs attention." >&2
    exit 1
fi