From a881924a3d2945d57a699dae4e05a5cef95b7a8b Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Sat, 7 Nov 2026 19:40:56 -0800 Subject: [PATCH 01/14] Publish as org.owasp:java-html-sanitizer with relocation and SHA-512 signatures Move the reactor to org.owasp coordinates (issue #531): the library is org.owasp:java-html-sanitizer, its parent java-html-sanitizer-parent, and the unpublished modules get the same prefix. A new legacy-relocation module publishes, with each release, a POM-only relocation at com.googlecode.owasp-java-html-sanitizer: owasp-java-html-sanitizer that points to the same version under the new coordinates. Java packages, the JPMS module name and, now pinned, the OSGi bundle symbolic name are unchanged. The shade exclude names the shim metadata directories in full, since java*/** under org.owasp would also strip the library's own pom.properties. JReleaser's built-in signer hashes with SHA-1, so sign with gpg in command mode with SHA-512 instead. scripts/with-release-key.sh puts the pinned release key alone in a temporary keyring for it. The release and the no-publish check now verify the staging repository holds exactly the expected components before anything is tagged or uploaded, and the signature check rejects digests weaker than SHA-256. Co-Authored-By: Claude Opus 5.5 --- .github/dependabot.yml | 1 + .github/workflows/build.yml | 2 +- .github/workflows/release.yml | 17 ++++-- .github/workflows/verify-release-signing.yml | 9 ++- AGENTS.md | 2 +- change_log.md | 12 ++++ empiricism/pom.xml | 14 ++--- examples/pom.xml | 18 +++--- java10-shim/pom.xml | 10 ++-- java8-shim/pom.xml | 6 +- legacy-relocation/pom.xml | 34 +++++++++++ owasp-java-html-sanitizer/README.md | 7 ++- owasp-java-html-sanitizer/pom.xml | 35 +++++++---- .../test/resources/packaging-verification.xml | 6 ++ pom.xml | 24 ++++++-- scripts/check-staged-release.sh | 58 +++++++++++++++++++ scripts/verify-artifact-signatures.sh | 11 ++-- scripts/with-release-key.sh | 44 ++++++++++++++ 18 files changed, 251 insertions(+), 59 deletions(-) create mode 100644 legacy-relocation/pom.xml create mode 100755 scripts/check-staged-release.sh create mode 100755 scripts/with-release-key.sh diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a386fb02..1b97da62 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -30,3 +30,4 @@ updates: open-pull-requests-limit: 0 ignore: - dependency-name: "com.googlecode.owasp-java-html-sanitizer:*" + - dependency-name: "org.owasp:java-html-sanitizer*" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 03a186ad..ba9ebab7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,7 +61,7 @@ jobs: - name: Run the Java 8 consumer check on Java 8 run: | - set -- owasp-java-html-sanitizer/target/owasp-java-html-sanitizer-*.jar + set -- owasp-java-html-sanitizer/target/java-html-sanitizer-*.jar if [ $# -ne 1 ] || [ ! -f "$1" ]; then echo "::error::expected one packaged jar, found: $*" exit 1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ec68c0c8..defd9cd7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,6 +11,7 @@ on: env: VERSION: ${{ github.event.inputs.version }} NEXT_VERSION: 20000101-SNAPSHOT + EXPECTED_GPG_FINGERPRINT: F6109A4F3F5616E1A7A62099E02DB03BAF6C438C jobs: release: @@ -106,9 +107,12 @@ jobs: id: build run: ./mvnw -ntp -B -Ppublication + - name: Check staged release + id: check_staged + run: scripts/check-staged-release.sh target/staging-deploy "$VERSION" + - name: Sign release tag env: - EXPECTED_GPG_FINGERPRINT: F6109A4F3F5616E1A7A62099E02DB03BAF6C438C GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} @@ -121,13 +125,13 @@ jobs: JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} - JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} + GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} + GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} JRELEASER_MASTODON_ACCESS_TOKEN: ${{ secrets.MASTODON_ACCESS_TOKEN }} JRELEASER_BLUESKY_HOST: ${{ secrets.BLUESKY_HOST }} JRELEASER_BLUESKY_HANDLE: ${{ secrets.BLUESKY_HANDLE }} JRELEASER_BLUESKY_PASSWORD: ${{ secrets.BLUESKY_PASSWORD }} - run: ./mvnw -ntp -B -N -Ppublication jreleaser:full-release + run: scripts/with-release-key.sh ./mvnw -ntp -B -N -Ppublication jreleaser:full-release - name: Release log if: always() @@ -147,9 +151,10 @@ jobs: git push origin main - name: Undo the release commit after a build failure - if: failure() && steps.set_version.outputs.bumped == 'true' && steps.build.outcome == 'failure' + if: failure() && steps.set_version.outputs.bumped == 'true' && (steps.build.outcome == 'failure' || steps.check_staged.outcome == 'failure') run: | - # The build failed before JReleaser ran, so nothing was published. + # The build or the staging check failed before JReleaser ran, so + # nothing was published. # A failure during or after JReleaser needs manual review because # the release may already have been published or tagged. if [ "$(git log -1 --format=%s)" != "Release version $VERSION" ]; then diff --git a/.github/workflows/verify-release-signing.yml b/.github/workflows/verify-release-signing.yml index 80dad52b..a8201fcf 100644 --- a/.github/workflows/verify-release-signing.yml +++ b/.github/workflows/verify-release-signing.yml @@ -39,6 +39,9 @@ jobs: - name: Build staged artifacts run: ./mvnw -ntp -B -Ppublication + - name: Check staged release + run: scripts/check-staged-release.sh target/staging-deploy "$VERSION" + - name: Check signed tag without publishing it env: GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} @@ -53,9 +56,9 @@ jobs: JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME: dry-run-only JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD: dry-run-only JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} - JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} - run: ./mvnw -ntp -B -N -Ppublication -Djreleaser.dry.run=true jreleaser:deploy + GPG_SECRET_KEY: ${{ secrets.GPG_SECRET_KEY }} + GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} + run: scripts/with-release-key.sh ./mvnw -ntp -B -N -Ppublication -Djreleaser.dry.run=true jreleaser:deploy - name: Check artifact signatures env: diff --git a/AGENTS.md b/AGENTS.md index c835e887..a5733975 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ Guidance for AI-assisted work in this repository. This is a security-critical li ## Project -OWASP Java HTML Sanitizer (`com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`). Takes attacker-controlled HTML and produces HTML that is safe to embed in a web page. Allowlist policies are built with `HtmlPolicyBuilder` and compiled into thread-safe `PolicyFactory` instances. +OWASP Java HTML Sanitizer (`org.owasp:java-html-sanitizer`; releases before issue #531 were `com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`, where `legacy-relocation/` now publishes a relocation POM with each release). Takes attacker-controlled HTML and produces HTML that is safe to embed in a web page. Allowlist policies are built with `HtmlPolicyBuilder` and compiled into thread-safe `PolicyFactory` instances. This is a multi-module Maven build: diff --git a/change_log.md b/change_log.md index 10808dc4..e942ba39 100644 --- a/change_log.md +++ b/change_log.md @@ -1,6 +1,18 @@ # OWASP Java HTML Sanitizer Change Log Most recent at top. + * Next release + * Published as `org.owasp:java-html-sanitizer`. The previous coordinates, + `com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`, + get a relocation POM with each release that points to the new ones; + releases already published there are unchanged. Java packages, the + JPMS module name and the OSGi bundle symbolic name are unchanged. + Replace the old coordinates with the new ones: a dependency that still + names an older release under the old coordinates puts a second copy of + the library on the class path. See issue #531. + * Release artifacts and tags are signed with the project release key, + fingerprint `F6109A4F3F5616E1A7A62099E02DB03BAF6C438C`, and artifact + signatures use SHA-512 instead of SHA-1. * Release 20261107.1 * Percent-encode NUL, DEL, C1 controls, noncharacters and lone surrogates in event-stream, preprocessor- or policy-supplied URL attribute values, diff --git a/empiricism/pom.xml b/empiricism/pom.xml index 91d391d4..493a2928 100644 --- a/empiricism/pom.xml +++ b/empiricism/pom.xml @@ -1,11 +1,11 @@ 4.0.0 - empiricism + java-html-sanitizer-empiricism 20000101-SNAPSHOT jar - com.googlecode.owasp-java-html-sanitizer - parent + org.owasp + java-html-sanitizer-parent 20000101-SNAPSHOT @@ -22,13 +22,13 @@ - com.googlecode.owasp-java-html-sanitizer - owasp-java-html-sanitizer + org.owasp + java-html-sanitizer ${project.version} - com.googlecode.owasp-java-html-sanitizer - java8-shim + org.owasp + java-html-sanitizer-java8-shim ${project.version} diff --git a/examples/pom.xml b/examples/pom.xml index 7cd6e009..6efcb0cc 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - examples + java-html-sanitizer-examples jar - com.googlecode.owasp-java-html-sanitizer - parent + org.owasp + java-html-sanitizer-parent 20000101-SNAPSHOT @@ -29,8 +29,8 @@ - com.googlecode.owasp-java-html-sanitizer - owasp-java-html-sanitizer + org.owasp + java-html-sanitizer ${project.version} - com.googlecode.owasp-java-html-sanitizer - java8-shim + org.owasp + java-html-sanitizer-java8-shim ${project.version} runtime - com.googlecode.owasp-java-html-sanitizer - java10-shim + org.owasp + java-html-sanitizer-java10-shim ${project.version} runtime diff --git a/java10-shim/pom.xml b/java10-shim/pom.xml index ed8e07dc..732efd23 100644 --- a/java10-shim/pom.xml +++ b/java10-shim/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - java10-shim + java-html-sanitizer-java10-shim jar - com.googlecode.owasp-java-html-sanitizer - parent + org.owasp + java-html-sanitizer-parent 20000101-SNAPSHOT @@ -59,8 +59,8 @@ - com.googlecode.owasp-java-html-sanitizer - java8-shim + org.owasp + java-html-sanitizer-java8-shim diff --git a/java8-shim/pom.xml b/java8-shim/pom.xml index 085ef17b..413f5a75 100644 --- a/java8-shim/pom.xml +++ b/java8-shim/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - java8-shim + java-html-sanitizer-java8-shim jar - com.googlecode.owasp-java-html-sanitizer - parent + org.owasp + java-html-sanitizer-parent 20000101-SNAPSHOT diff --git a/legacy-relocation/pom.xml b/legacy-relocation/pom.xml new file mode 100644 index 00000000..0fbf4b5a --- /dev/null +++ b/legacy-relocation/pom.xml @@ -0,0 +1,34 @@ + + + + + 4.0.0 + + org.owasp + java-html-sanitizer-parent + 20000101-SNAPSHOT + + + com.googlecode.owasp-java-html-sanitizer + owasp-java-html-sanitizer + pom + + OWASP Java HTML Sanitizer (relocated) + + Relocation to org.owasp:java-html-sanitizer. Releases from this version + on are published only under the new coordinates. + + https://github.com/OWASP/java-html-sanitizer + + + + org.owasp + java-html-sanitizer + The OWASP Java HTML Sanitizer is now published as org.owasp:java-html-sanitizer. See https://github.com/OWASP/java-html-sanitizer/blob/main/docs/maven.md + + + diff --git a/owasp-java-html-sanitizer/README.md b/owasp-java-html-sanitizer/README.md index f05f9ef3..19cb3d8e 100644 --- a/owasp-java-html-sanitizer/README.md +++ b/owasp-java-html-sanitizer/README.md @@ -2,8 +2,11 @@ # Core Library Module -This module builds the published -`com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer` artifact. +This module builds the published `org.owasp:java-html-sanitizer` artifact. +Releases before issue #531 were published as +`com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`, where +the [relocation module](../legacy-relocation/pom.xml) now publishes a POM with +each release that points to the new coordinates. It combines HTML parsing, tag balancing, allowlist policy enforcement, and rendering to produce sanitized HTML. See the [getting-started guide](../docs/getting_started.md) for using the public API. diff --git a/owasp-java-html-sanitizer/pom.xml b/owasp-java-html-sanitizer/pom.xml index 706b7179..09ff14a9 100644 --- a/owasp-java-html-sanitizer/pom.xml +++ b/owasp-java-html-sanitizer/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - owasp-java-html-sanitizer + java-html-sanitizer bundle - com.googlecode.owasp-java-html-sanitizer - parent + org.owasp + java-html-sanitizer-parent 20000101-SNAPSHOT @@ -119,6 +119,12 @@ maven-bundle-plugin + + com.googlecode.owasp-java-html-sanitizer org.owasp.html - com.googlecode.owasp-java-html-sanitizer:java8-shim - com.googlecode.owasp-java-html-sanitizer:java10-shim + org.owasp:java-html-sanitizer-java8-shim + org.owasp:java-html-sanitizer-java10-shim @@ -199,8 +205,13 @@ *:* - META-INF/maven/com.googlecode.owasp-java-html-sanitizer/java*/** + pom.properties / pom.xml entries in the JAR. Name + the shim directories in full: a looser pattern such + as java*/** also matches java-html-sanitizer/ and + strips this artifact's own metadata, which + dependency scanners use to identify the JAR. --> + META-INF/maven/org.owasp/java-html-sanitizer-java8-shim/** + META-INF/maven/org.owasp/java-html-sanitizer-java10-shim/** - com.googlecode.owasp-java-html-sanitizer:java10-shim + org.owasp:java-html-sanitizer-java10-shim META-INF/versions/** @@ -338,13 +349,13 @@ - com.googlecode.owasp-java-html-sanitizer - java8-shim + org.owasp + java-html-sanitizer-java8-shim true - com.googlecode.owasp-java-html-sanitizer - java10-shim + org.owasp + java-html-sanitizer-java10-shim true diff --git a/owasp-java-html-sanitizer/src/test/resources/packaging-verification.xml b/owasp-java-html-sanitizer/src/test/resources/packaging-verification.xml index 6eb4be9a..7ced33ad 100644 --- a/owasp-java-html-sanitizer/src/test/resources/packaging-verification.xml +++ b/owasp-java-html-sanitizer/src/test/resources/packaging-verification.xml @@ -6,6 +6,12 @@ target/classes/META-INF/MANIFEST.MF Export-Package: org.owasp.html + + + target/classes/META-INF/MANIFEST.MF + Bundle-SymbolicName: com.googlecode.owasp-java-html-sanitizer + ALWAYS true + COMMAND + + + --digest-algo + SHA512 + + diff --git a/scripts/check-staged-release.sh b/scripts/check-staged-release.sh new file mode 100755 index 00000000..536e9603 --- /dev/null +++ b/scripts/check-staged-release.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause + +# Checks that a release staging repository holds exactly the components a +# release publishes: the library and its parent under org.owasp, and a +# relocation POM at the coordinates used before issue #531. + +set -euo pipefail + +repository=${1:?staging repository required} +version=${2:?release version required} +if [[ ! $version =~ ^[0-9]{8}\.[0-9]+$ ]]; then + echo 'Invalid release version' >&2 + exit 1 +fi + +library=org/owasp/java-html-sanitizer/$version/java-html-sanitizer-$version +parent=org/owasp/java-html-sanitizer-parent/$version/java-html-sanitizer-parent-$version +legacy=com/googlecode/owasp-java-html-sanitizer/owasp-java-html-sanitizer/$version/owasp-java-html-sanitizer-$version +expected=$(printf '%s\n' "$library.jar" "$library.pom" "$library-javadoc.jar" \ + "$library-sources.jar" "$parent.pom" "$legacy.pom" | sort) +actual=$(cd "$repository" && find . -type f ! -name '*.md5' ! -name '*.sha1' \ + ! -name '*.sha256' ! -name '*.sha512' ! -name '*.asc' ! -name 'maven-metadata*' | + sed 's#^\./##' | sort) +if [[ $actual != "$expected" ]]; then + echo 'Staged artifacts differ from the expected release components:' >&2 + diff <(echo "$expected") <(echo "$actual") >&2 || true + exit 1 +fi + +relocation=$(tr -d ' \n\r\t' < "$repository/$legacy.pom") +for element in 'org.owaspjava-html-sanitizer' \ + 'pom'; do + if [[ $relocation != *"$element"* ]]; then + echo "Relocation POM lacks $element" >&2 + exit 1 + fi +done +if [[ $relocation == *''* || $relocation == *''* ]]; then + echo 'Relocation POM must have no dependencies and no pinned target version' >&2 + exit 1 +fi + +entries=$(unzip -Z1 "$repository/$library.jar") +if ! grep -qx 'META-INF/maven/org.owasp/java-html-sanitizer/pom.properties' <<<"$entries"; then + echo 'Library JAR lacks its own Maven metadata' >&2 + exit 1 +fi +if grep -q '^META-INF/maven/.*shim' <<<"$entries"; then + echo 'Library JAR carries shim Maven metadata' >&2 + exit 1 +fi +if ! unzip -p "$repository/$library.jar" META-INF/MANIFEST.MF | + grep -q '^Bundle-SymbolicName: com\.googlecode\.owasp-java-html-sanitizer'; then + echo 'Library JAR has an unexpected OSGi symbolic name' >&2 + exit 1 +fi +echo "Staged release $version has the expected components" diff --git a/scripts/verify-artifact-signatures.sh b/scripts/verify-artifact-signatures.sh index e783d2b1..5bc6899f 100755 --- a/scripts/verify-artifact-signatures.sh +++ b/scripts/verify-artifact-signatures.sh @@ -40,10 +40,13 @@ while IFS= read -r -d '' artifact; do echo "Missing signature for ${artifact#"$repository"/}" >&2 exit 1 fi - signer=$(gpg --batch --status-fd 1 --verify "$artifact.asc" "$artifact" 2>/dev/null | - awk '$1 == "[GNUPG:]" && $2 == "VALIDSIG" { print $NF; exit }') || true - if [[ $signer != "$EXPECTED_GPG_FINGERPRINT" ]]; then - echo "Bad or unexpected signature on ${artifact#"$repository"/}" >&2 + status=$(gpg --batch --status-fd 1 --verify "$artifact.asc" "$artifact" 2>/dev/null) || true + # VALIDSIG ends with the primary key fingerprint; its eighth field is the + # hash algorithm, which must be SHA-256 (8), SHA-384 (9) or SHA-512 (10). + read -r signer digest < <(awk '$1 == "[GNUPG:]" && $2 == "VALIDSIG" { print $NF, $10; exit }' <<<"$status") || true + if [[ ${signer:-} != "$EXPECTED_GPG_FINGERPRINT" || ! ${digest:-} =~ ^(8|9|10)$ ]]; then + echo "Bad, weak or unexpected signature on ${artifact#"$repository"/}:" >&2 + grep '^\[GNUPG:\] \(VALIDSIG\|BADSIG\|ERRSIG\|FAILURE\|NO_PUBKEY\|ERROR\)' <<<"$status" >&2 || true exit 1 fi echo "Verified ${artifact#"$repository"/}" diff --git a/scripts/with-release-key.sh b/scripts/with-release-key.sh new file mode 100755 index 00000000..ea7c0133 --- /dev/null +++ b/scripts/with-release-key.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause + +# Runs a command, normally JReleaser, with the release key alone in a +# temporary GnuPG home, and points JReleaser's gpg command signer at it. + +set -euo pipefail + +if (($# == 0)); then + echo 'Command required' >&2 + exit 1 +fi +: "${GPG_SECRET_KEY:?GPG_SECRET_KEY required}" +: "${GPG_PUBLIC_KEY:?GPG_PUBLIC_KEY required}" +: "${EXPECTED_GPG_FINGERPRINT:?EXPECTED_GPG_FINGERPRINT required}" +if [[ ! $EXPECTED_GPG_FINGERPRINT =~ ^[0-9A-F]{40}$ ]]; then + echo 'Invalid expected release signing fingerprint' >&2 + exit 1 +fi + +signing_home=$(mktemp -d) +trap 'gpgconf --kill gpg-agent >/dev/null 2>&1 || true; rm -rf "$signing_home"' EXIT +chmod 700 "$signing_home" +export GNUPGHOME=$signing_home +public_fingerprint=$(printf '%s\n' "$GPG_PUBLIC_KEY" | + gpg --batch --show-keys --with-colons | + awk -F: '$1 == "fpr" { print $10; exit }') +if [[ $public_fingerprint != "$EXPECTED_GPG_FINGERPRINT" ]]; then + echo 'Release public key fingerprint does not match the configured key' >&2 + exit 1 +fi +printf '%s\n' "$GPG_PUBLIC_KEY" | gpg --batch --quiet --import +printf '%s\n' "$GPG_SECRET_KEY" | gpg --batch --quiet --import + +fingerprint=$(gpg --batch --with-colons --list-secret-keys | + awk -F: '$1 == "sec" { primary = 1; next } $1 == "fpr" && primary { print $10; primary = 0 }') +if [[ $fingerprint != "$EXPECTED_GPG_FINGERPRINT" ]]; then + echo 'Expected exactly one release signing key, the configured one' >&2 + exit 1 +fi + +export JRELEASER_GPG_HOMEDIR=$signing_home +export JRELEASER_GPG_KEYNAME=$fingerprint +"$@" From 51b175f2ff56546063f374392c8bdbdff2a8089a Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 12:38:05 +0700 Subject: [PATCH 02/14] Check the whole relocation element for a pinned version The staging check looked for a version only as the first child of the relocation element, and it also requires groupId and artifactId to come first, so a version written after them passed. A pinned version would send every later release at the old coordinates to one fixed release. Look anywhere inside the element. See issue #531. Co-Authored-By: Claude Fable 5.2 --- scripts/check-staged-release.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/check-staged-release.sh b/scripts/check-staged-release.sh index 536e9603..1ba082a8 100755 --- a/scripts/check-staged-release.sh +++ b/scripts/check-staged-release.sh @@ -36,7 +36,9 @@ for element in 'org.owaspjava-html-sa exit 1 fi done -if [[ $relocation == *''* || $relocation == *''* ]]; then +target=${relocation#*} +target=${target%%*} +if [[ $relocation == *''* || $target == *''* ]]; then echo 'Relocation POM must have no dependencies and no pinned target version' >&2 exit 1 fi From ced9c860648055ccff709544bff6099c09f31f81 Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 12:38:05 +0700 Subject: [PATCH 03/14] Let the signing check ask Maven Central to validate the bundle A release now deploys two namespaces in one bundle, and nothing in the repository can show whether the publishing token may deploy both. If it may not, the release fails after the release commit and the signed tag are pushed, which the workflow does not undo. The Verify release signing workflow gets an opt-in central_upload input. With it, the bundle JReleaser built at the placeholder version is uploaded to the Central Portal as USER_MANAGED, which Central holds until a separate publish request that the script never makes. The script reports Central's validation result and errors, then drops the deployment. See issue #531. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/verify-release-signing.yml | 24 +++++++ scripts/validate-central-bundle.sh | 74 ++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100755 scripts/validate-central-bundle.sh diff --git a/.github/workflows/verify-release-signing.yml b/.github/workflows/verify-release-signing.yml index a8201fcf..5e612f96 100644 --- a/.github/workflows/verify-release-signing.yml +++ b/.github/workflows/verify-release-signing.yml @@ -3,9 +3,20 @@ name: Verify release signing # Exercises the release signing path with the repository's release key # without publishing anything: the tag is created and deleted on the runner, # and JReleaser deploys in dry-run mode with placeholder Central credentials. +# +# With central_upload, the bundle JReleaser built is also uploaded to Maven +# Central with the real publishing token, validated there, and dropped. That +# is the only way to learn before a release whether the token may deploy +# both org.owasp and the relocation POM's namespace. The upload is never +# published. on: workflow_dispatch: + inputs: + central_upload: + description: 'Also have Maven Central validate the placeholder bundle, then drop it (never published)' + type: boolean + default: false permissions: contents: read @@ -64,3 +75,16 @@ jobs: env: GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} run: scripts/verify-artifact-signatures.sh target/staging-deploy + + - name: Have Maven Central validate the bundle, then drop it + if: ${{ inputs.central_upload }} + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + run: | + set -- target/jreleaser/deploy/mavenCentral/sonatype/*-bundle.zip + if [ $# -ne 1 ] || [ ! -f "$1" ]; then + echo "::error::expected one deployment bundle, found: $*" + exit 1 + fi + scripts/validate-central-bundle.sh "$1" diff --git a/scripts/validate-central-bundle.sh b/scripts/validate-central-bundle.sh new file mode 100755 index 00000000..c12a8e55 --- /dev/null +++ b/scripts/validate-central-bundle.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause + +# Uploads a deployment bundle to the Maven Central Publisher Portal so that +# Central validates it, reports the result, and drops the deployment. It +# never publishes: the upload is USER_MANAGED, which Central holds until a +# separate publish request, and this script makes none. Use it with a +# bundle built at a placeholder version to learn, before a real release, +# whether the publishing token may deploy every namespace in the bundle. + +set -euo pipefail + +bundle=${1:?deployment bundle required} +api=${2:-https://central.sonatype.com/api/v1/publisher} +poll_seconds=${3:-10} +: "${SONATYPE_USERNAME:?SONATYPE_USERNAME required}" +: "${SONATYPE_PASSWORD:?SONATYPE_PASSWORD required}" +if [[ ! -f $bundle ]]; then + echo "Deployment bundle $bundle does not exist" >&2 + exit 1 +fi + +auth_file=$(mktemp) +deployment= +finish() { + rm -f "$auth_file" + if [[ -n $deployment ]]; then + echo "::warning::Deployment $deployment was not dropped; drop it at https://central.sonatype.com/publishing/deployments" >&2 + fi +} +trap finish EXIT +chmod 600 "$auth_file" +# Keep the token out of the process list. +printf 'header = "Authorization: Bearer %s"\n' \ + "$(printf '%s:%s' "$SONATYPE_USERNAME" "$SONATYPE_PASSWORD" | base64 | tr -d '\n')" > "$auth_file" +call() { + curl --silent --show-error --fail-with-body --max-time 300 --config "$auth_file" "$@" +} + +uploaded=$(call --request POST --form "bundle=@$bundle" \ + "$api/upload?name=validation-only&publishingType=USER_MANAGED") +if [[ ! $uploaded =~ ^[0-9a-f-]{36}$ ]]; then + echo 'Central did not return a deployment identifier' >&2 + exit 1 +fi +deployment=$uploaded +echo "Uploaded as deployment $deployment; waiting for validation" + +state=PENDING +status= +for _ in $(seq 60); do + status=$(call --request POST "$api/status?id=$deployment") + state=$(jq -r '.deploymentState // "UNKNOWN"' <<<"$status") + if [[ $state != PENDING && $state != VALIDATING ]]; then + break + fi + sleep "$poll_seconds" +done +echo "Deployment state: $state" +jq '{deploymentState, purls, errors}' <<<"$status" + +# Central drops only deployments that have finished validating. One that +# is left behind stays unpublished, and the exit handler says so. +if [[ $state == VALIDATED || $state == FAILED ]] && + call --request DELETE "$api/deployment/$deployment" > /dev/null; then + echo "Dropped deployment $deployment" + deployment= +fi + +if [[ $state != VALIDATED ]]; then + echo 'Central did not validate the bundle' >&2 + exit 1 +fi +echo 'Central validated the bundle; nothing was published' From 55eaecf6510df7537e07aa258b536b80db0ef045 Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 12:46:47 +0700 Subject: [PATCH 04/14] Use the project namespace org.owasp.html-sanitizer The library becomes org.owasp.html-sanitizer:html-sanitizer rather than org.owasp:java-html-sanitizer. A namespace of its own matches the other OWASP libraries on Maven Central (org.owasp.encoder, org.owasp.antisamy, org.owasp.json-sanitizer), and Central grants publishing rights per namespace, so the token this repository holds can be limited to this project instead of covering all of org.owasp. "java" is dropped from both names as redundant on Maven Central. The parent and the unpublished modules take the html-sanitizer- prefix. The relocation module, the staging check, the packaging checks and the Java 8 consumer job follow. The Java package, the JPMS module name and the OSGi symbolic name are unchanged. See issue #531. Co-Authored-By: Claude Fable 5.2 --- .github/dependabot.yml | 2 +- .github/workflows/build.yml | 2 +- .github/workflows/verify-release-signing.yml | 2 +- AGENTS.md | 2 +- change_log.md | 3 +- empiricism/pom.xml | 14 ++++---- examples/pom.xml | 18 +++++----- java10-shim/pom.xml | 10 +++--- java8-shim/pom.xml | 6 ++-- legacy-relocation/pom.xml | 21 +++++------ owasp-java-html-sanitizer/README.md | 2 +- owasp-java-html-sanitizer/pom.xml | 35 ++++++++++--------- .../test/resources/packaging-verification.xml | 5 +-- pom.xml | 12 +++---- scripts/check-staged-release.sh | 13 +++---- 15 files changed, 76 insertions(+), 71 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 1b97da62..8d2bd07d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -30,4 +30,4 @@ updates: open-pull-requests-limit: 0 ignore: - dependency-name: "com.googlecode.owasp-java-html-sanitizer:*" - - dependency-name: "org.owasp:java-html-sanitizer*" + - dependency-name: "org.owasp.html-sanitizer:html-sanitizer*" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ba9ebab7..b01abab6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -61,7 +61,7 @@ jobs: - name: Run the Java 8 consumer check on Java 8 run: | - set -- owasp-java-html-sanitizer/target/java-html-sanitizer-*.jar + set -- owasp-java-html-sanitizer/target/html-sanitizer-*.jar if [ $# -ne 1 ] || [ ! -f "$1" ]; then echo "::error::expected one packaged jar, found: $*" exit 1 diff --git a/.github/workflows/verify-release-signing.yml b/.github/workflows/verify-release-signing.yml index 5e612f96..9211e0b8 100644 --- a/.github/workflows/verify-release-signing.yml +++ b/.github/workflows/verify-release-signing.yml @@ -7,7 +7,7 @@ name: Verify release signing # With central_upload, the bundle JReleaser built is also uploaded to Maven # Central with the real publishing token, validated there, and dropped. That # is the only way to learn before a release whether the token may deploy -# both org.owasp and the relocation POM's namespace. The upload is never +# both the new namespace and the relocation POM's. The upload is never # published. on: diff --git a/AGENTS.md b/AGENTS.md index b954c91f..e48018b0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -4,7 +4,7 @@ Guidance for AI-assisted work in this repository. This is a security-critical li ## Project -OWASP Java HTML Sanitizer (`org.owasp:java-html-sanitizer`; releases before issue #531 were `com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`, where `legacy-relocation/` now publishes a relocation POM with each release). Takes attacker-controlled HTML and produces HTML that is safe to embed in a web page. Allowlist policies are built with `HtmlPolicyBuilder` and compiled into thread-safe `PolicyFactory` instances. +OWASP Java HTML Sanitizer (`org.owasp.html-sanitizer:html-sanitizer`; releases before issue #531 were `com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`, where `legacy-relocation/` now publishes a relocation POM with each release). Takes attacker-controlled HTML and produces HTML that is safe to embed in a web page. Allowlist policies are built with `HtmlPolicyBuilder` and compiled into thread-safe `PolicyFactory` instances. This is a multi-module Maven build: diff --git a/change_log.md b/change_log.md index b5bd6b53..a199462f 100644 --- a/change_log.md +++ b/change_log.md @@ -2,7 +2,8 @@ Most recent at top. * Next release - * Published as `org.owasp:java-html-sanitizer`. The previous coordinates, + * Published as `org.owasp.html-sanitizer:html-sanitizer`. The + previous coordinates, `com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`, get a relocation POM with each release that points to the new ones; releases already published there are unchanged. Java packages, the diff --git a/empiricism/pom.xml b/empiricism/pom.xml index 493a2928..72f68289 100644 --- a/empiricism/pom.xml +++ b/empiricism/pom.xml @@ -1,11 +1,11 @@ 4.0.0 - java-html-sanitizer-empiricism + html-sanitizer-empiricism 20000101-SNAPSHOT jar - org.owasp - java-html-sanitizer-parent + org.owasp.html-sanitizer + html-sanitizer-parent 20000101-SNAPSHOT @@ -22,13 +22,13 @@ - org.owasp - java-html-sanitizer + org.owasp.html-sanitizer + html-sanitizer ${project.version} - org.owasp - java-html-sanitizer-java8-shim + org.owasp.html-sanitizer + html-sanitizer-java8-shim ${project.version} diff --git a/examples/pom.xml b/examples/pom.xml index 6efcb0cc..b63853aa 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - java-html-sanitizer-examples + html-sanitizer-examples jar - org.owasp - java-html-sanitizer-parent + org.owasp.html-sanitizer + html-sanitizer-parent 20000101-SNAPSHOT @@ -29,8 +29,8 @@ - org.owasp - java-html-sanitizer + org.owasp.html-sanitizer + html-sanitizer ${project.version} - org.owasp - java-html-sanitizer-java8-shim + org.owasp.html-sanitizer + html-sanitizer-java8-shim ${project.version} runtime - org.owasp - java-html-sanitizer-java10-shim + org.owasp.html-sanitizer + html-sanitizer-java10-shim ${project.version} runtime diff --git a/java10-shim/pom.xml b/java10-shim/pom.xml index 732efd23..63ca276b 100644 --- a/java10-shim/pom.xml +++ b/java10-shim/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - java-html-sanitizer-java10-shim + html-sanitizer-java10-shim jar - org.owasp - java-html-sanitizer-parent + org.owasp.html-sanitizer + html-sanitizer-parent 20000101-SNAPSHOT @@ -59,8 +59,8 @@ - org.owasp - java-html-sanitizer-java8-shim + org.owasp.html-sanitizer + html-sanitizer-java8-shim diff --git a/java8-shim/pom.xml b/java8-shim/pom.xml index 413f5a75..39e50bc0 100644 --- a/java8-shim/pom.xml +++ b/java8-shim/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - java-html-sanitizer-java8-shim + html-sanitizer-java8-shim jar - org.owasp - java-html-sanitizer-parent + org.owasp.html-sanitizer + html-sanitizer-parent 20000101-SNAPSHOT diff --git a/legacy-relocation/pom.xml b/legacy-relocation/pom.xml index 0fbf4b5a..d7e0b506 100644 --- a/legacy-relocation/pom.xml +++ b/legacy-relocation/pom.xml @@ -2,14 +2,14 @@ + pointed at the same version under the new coordinates. It carries no + code and no dependencies. The relocation leaves the version out, so it + always points at the release it is published with. --> 4.0.0 - org.owasp - java-html-sanitizer-parent + org.owasp.html-sanitizer + html-sanitizer-parent 20000101-SNAPSHOT @@ -19,16 +19,17 @@ OWASP Java HTML Sanitizer (relocated) - Relocation to org.owasp:java-html-sanitizer. Releases from this version - on are published only under the new coordinates. + Relocation to org.owasp.html-sanitizer:html-sanitizer. + Releases from this version on are published only under the new + coordinates. https://github.com/OWASP/java-html-sanitizer - org.owasp - java-html-sanitizer - The OWASP Java HTML Sanitizer is now published as org.owasp:java-html-sanitizer. See https://github.com/OWASP/java-html-sanitizer/blob/main/docs/maven.md + org.owasp.html-sanitizer + html-sanitizer + The OWASP Java HTML Sanitizer is now published as org.owasp.html-sanitizer:html-sanitizer. See https://github.com/OWASP/java-html-sanitizer/blob/main/docs/maven.md diff --git a/owasp-java-html-sanitizer/README.md b/owasp-java-html-sanitizer/README.md index 19cb3d8e..cb6d1d90 100644 --- a/owasp-java-html-sanitizer/README.md +++ b/owasp-java-html-sanitizer/README.md @@ -2,7 +2,7 @@ # Core Library Module -This module builds the published `org.owasp:java-html-sanitizer` artifact. +This module builds the published `org.owasp.html-sanitizer:html-sanitizer` artifact. Releases before issue #531 were published as `com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`, where the [relocation module](../legacy-relocation/pom.xml) now publishes a POM with diff --git a/owasp-java-html-sanitizer/pom.xml b/owasp-java-html-sanitizer/pom.xml index 09ff14a9..4dd366da 100644 --- a/owasp-java-html-sanitizer/pom.xml +++ b/owasp-java-html-sanitizer/pom.xml @@ -1,10 +1,10 @@ 4.0.0 - java-html-sanitizer + html-sanitizer bundle - org.owasp - java-html-sanitizer-parent + org.owasp.html-sanitizer + html-sanitizer-parent 20000101-SNAPSHOT @@ -120,7 +120,7 @@ @@ -196,8 +196,8 @@ multiple JARs. See https://github.com/OWASP/java-html-sanitizer/issues/341 --> - org.owasp:java-html-sanitizer-java8-shim - org.owasp:java-html-sanitizer-java10-shim + org.owasp.html-sanitizer:html-sanitizer-java8-shim + org.owasp.html-sanitizer:html-sanitizer-java10-shim @@ -206,12 +206,13 @@ - META-INF/maven/org.owasp/java-html-sanitizer-java8-shim/** - META-INF/maven/org.owasp/java-html-sanitizer-java10-shim/** + the shim directories in full: a pattern loose + enough to match both shims can also match this + artifact's own directory and strip the metadata + that dependency scanners use to identify the + JAR. --> + META-INF/maven/org.owasp.html-sanitizer/html-sanitizer-java8-shim/** + META-INF/maven/org.owasp.html-sanitizer/html-sanitizer-java10-shim/** - org.owasp:java-html-sanitizer-java10-shim + org.owasp.html-sanitizer:html-sanitizer-java10-shim META-INF/versions/** @@ -349,13 +350,13 @@ - org.owasp - java-html-sanitizer-java8-shim + org.owasp.html-sanitizer + html-sanitizer-java8-shim true - org.owasp - java-html-sanitizer-java10-shim + org.owasp.html-sanitizer + html-sanitizer-java10-shim true diff --git a/owasp-java-html-sanitizer/src/test/resources/packaging-verification.xml b/owasp-java-html-sanitizer/src/test/resources/packaging-verification.xml index 7ced33ad..db1baf06 100644 --- a/owasp-java-html-sanitizer/src/test/resources/packaging-verification.xml +++ b/owasp-java-html-sanitizer/src/test/resources/packaging-verification.xml @@ -6,8 +6,9 @@ target/classes/META-INF/MANIFEST.MF Export-Package: org.owasp.html - + target/classes/META-INF/MANIFEST.MF Bundle-SymbolicName: com.googlecode.owasp-java-html-sanitizer diff --git a/pom.xml b/pom.xml index e8c17fbf..82c12f74 100644 --- a/pom.xml +++ b/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - org.owasp - java-html-sanitizer-parent + org.owasp.html-sanitizer + html-sanitizer-parent 20000101-SNAPSHOT pom @@ -263,13 +263,13 @@ application while protecting against XSS. - org.owasp - java-html-sanitizer-java8-shim + org.owasp.html-sanitizer + html-sanitizer-java8-shim ${project.version} - org.owasp - java-html-sanitizer-java10-shim + org.owasp.html-sanitizer + html-sanitizer-java10-shim ${project.version} diff --git a/scripts/check-staged-release.sh b/scripts/check-staged-release.sh index 1ba082a8..7337f1a1 100755 --- a/scripts/check-staged-release.sh +++ b/scripts/check-staged-release.sh @@ -2,8 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause # Checks that a release staging repository holds exactly the components a -# release publishes: the library and its parent under org.owasp, and a -# relocation POM at the coordinates used before issue #531. +# release publishes: the library and its parent under +# org.owasp.html-sanitizer, and a relocation POM at the coordinates used +# before issue #531. set -euo pipefail @@ -14,8 +15,8 @@ if [[ ! $version =~ ^[0-9]{8}\.[0-9]+$ ]]; then exit 1 fi -library=org/owasp/java-html-sanitizer/$version/java-html-sanitizer-$version -parent=org/owasp/java-html-sanitizer-parent/$version/java-html-sanitizer-parent-$version +library=org/owasp/html-sanitizer/html-sanitizer/$version/html-sanitizer-$version +parent=org/owasp/html-sanitizer/html-sanitizer-parent/$version/html-sanitizer-parent-$version legacy=com/googlecode/owasp-java-html-sanitizer/owasp-java-html-sanitizer/$version/owasp-java-html-sanitizer-$version expected=$(printf '%s\n' "$library.jar" "$library.pom" "$library-javadoc.jar" \ "$library-sources.jar" "$parent.pom" "$legacy.pom" | sort) @@ -29,7 +30,7 @@ if [[ $actual != "$expected" ]]; then fi relocation=$(tr -d ' \n\r\t' < "$repository/$legacy.pom") -for element in 'org.owaspjava-html-sanitizer' \ +for element in 'org.owasp.html-sanitizerhtml-sanitizer' \ 'pom'; do if [[ $relocation != *"$element"* ]]; then echo "Relocation POM lacks $element" >&2 @@ -44,7 +45,7 @@ if [[ $relocation == *''* || $target == *''* ]]; then fi entries=$(unzip -Z1 "$repository/$library.jar") -if ! grep -qx 'META-INF/maven/org.owasp/java-html-sanitizer/pom.properties' <<<"$entries"; then +if ! grep -qx 'META-INF/maven/org.owasp.html-sanitizer/html-sanitizer/pom.properties' <<<"$entries"; then echo 'Library JAR lacks its own Maven metadata' >&2 exit 1 fi From 9201a90ba1f421e59d2105de9558ab758b537d1c Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 13:15:27 +0700 Subject: [PATCH 05/14] Take the review: the Central check shows why it failed and fails loudly When Central refused a request, the script exited with curl's status alone and discarded the response body, the one thing that says why. The body now goes to the log. A failed status request ended the run at once and left a deployment that might still validate; three in a row are needed now. When the deployment validated but could not be dropped the run was green; it now fails, since a validated placeholder left in the Portal has a Publish button. The upload is named validation-only-DO-NOT-PUBLISH. Before uploading, the script asks Central whether each POM in the bundle is already published, as JReleaser does before a release, so the check exercises that request for both namespaces too. Co-Authored-By: Claude Fable 5.2 --- scripts/validate-central-bundle.sh | 50 +++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/scripts/validate-central-bundle.sh b/scripts/validate-central-bundle.sh index c12a8e55..442106e0 100755 --- a/scripts/validate-central-bundle.sh +++ b/scripts/validate-central-bundle.sh @@ -20,12 +20,13 @@ if [[ ! -f $bundle ]]; then exit 1 fi +portal=https://central.sonatype.com/publishing/deployments auth_file=$(mktemp) deployment= finish() { rm -f "$auth_file" if [[ -n $deployment ]]; then - echo "::warning::Deployment $deployment was not dropped; drop it at https://central.sonatype.com/publishing/deployments" >&2 + echo "::warning::Deployment $deployment was not dropped; drop it, and do not publish it, at $portal" >&2 fi } trap finish EXIT @@ -33,12 +34,37 @@ chmod 600 "$auth_file" # Keep the token out of the process list. printf 'header = "Authorization: Bearer %s"\n' \ "$(printf '%s:%s' "$SONATYPE_USERNAME" "$SONATYPE_PASSWORD" | base64 | tr -d '\n')" > "$auth_file" +# Prints the response body. When Central refuses, the body says why, so it +# goes to the log before the script stops. call() { - curl --silent --show-error --fail-with-body --max-time 300 --config "$auth_file" "$@" + local body + if ! body=$(curl --silent --show-error --fail-with-body --max-time 300 --config "$auth_file" "$@"); then + printf '%s\n' "$body" >&2 + return 1 + fi + printf '%s\n' "$body" } +# JReleaser asks Central whether each POM's coordinates are already +# published before it uploads, so ask the same question with the same token. +while IFS= read -r pom; do + artifact_version=${pom%/*} + artifact_path=${artifact_version%/*} + group_path=${artifact_path%/*} + namespace=${group_path//\//.} + name=${artifact_path##*/} + version=${artifact_version##*/} + published=$(call --get --data-urlencode "namespace=$namespace" --data-urlencode "name=$name" \ + --data-urlencode "version=$version" "$api/published") + if [[ $(jq -r '.published' <<<"$published") != false ]]; then + echo "Central does not report $namespace:$name:$version as unpublished: $published" >&2 + exit 1 + fi + echo "Not yet published, as expected: $namespace:$name:$version" +done < <(unzip -Z1 "$bundle" | grep '\.pom$') + uploaded=$(call --request POST --form "bundle=@$bundle" \ - "$api/upload?name=validation-only&publishingType=USER_MANAGED") + "$api/upload?name=validation-only-DO-NOT-PUBLISH&publishingType=USER_MANAGED") if [[ ! $uploaded =~ ^[0-9a-f-]{36}$ ]]; then echo 'Central did not return a deployment identifier' >&2 exit 1 @@ -48,11 +74,17 @@ echo "Uploaded as deployment $deployment; waiting for validation" state=PENDING status= +failures=0 for _ in $(seq 60); do - status=$(call --request POST "$api/status?id=$deployment") - state=$(jq -r '.deploymentState // "UNKNOWN"' <<<"$status") - if [[ $state != PENDING && $state != VALIDATING ]]; then - break + if status=$(call --request POST "$api/status?id=$deployment"); then + failures=0 + state=$(jq -r '.deploymentState // "UNKNOWN"' <<<"$status") + if [[ $state != PENDING && $state != VALIDATING ]]; then + break + fi + elif ((++failures >= 3)); then + echo 'Central did not answer three status requests in a row' >&2 + exit 1 fi sleep "$poll_seconds" done @@ -71,4 +103,8 @@ if [[ $state != VALIDATED ]]; then echo 'Central did not validate the bundle' >&2 exit 1 fi +if [[ -n $deployment ]]; then + echo 'Central validated the bundle, but the deployment could not be dropped' >&2 + exit 1 +fi echo 'Central validated the bundle; nothing was published' From f035f6a5f07b9b232929cb1be4afa960e6a3c4f8 Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 13:16:36 +0700 Subject: [PATCH 06/14] Take the review: the staging check accounts for every staged file Checksum and signature files were skipped wherever they were, so a stray one, such as org/owasp/stray.sha512, passed the check and would have been uploaded: JReleaser leaves only the repository metadata out of the bundle. Each such file now counts as the file it belongs to, which must be an expected component, and each expected component must itself be present. The check also reads the staged library POM. The library has no runtime dependencies and the shims are unpublished, so a dependency there that is neither test nor provided scope fails the release. Co-Authored-By: Claude Fable 5.2 --- scripts/check-staged-release.sh | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/scripts/check-staged-release.sh b/scripts/check-staged-release.sh index 7337f1a1..9eb29c63 100755 --- a/scripts/check-staged-release.sh +++ b/scripts/check-staged-release.sh @@ -20,14 +20,22 @@ parent=org/owasp/html-sanitizer/html-sanitizer-parent/$version/html-sanitizer-pa legacy=com/googlecode/owasp-java-html-sanitizer/owasp-java-html-sanitizer/$version/owasp-java-html-sanitizer-$version expected=$(printf '%s\n' "$library.jar" "$library.pom" "$library-javadoc.jar" \ "$library-sources.jar" "$parent.pom" "$legacy.pom" | sort) -actual=$(cd "$repository" && find . -type f ! -name '*.md5' ! -name '*.sha1' \ - ! -name '*.sha256' ! -name '*.sha512' ! -name '*.asc' ! -name 'maven-metadata*' | - sed 's#^\./##' | sort) +# A checksum or signature counts as the file it belongs to, so one that sits +# beside no expected component is reported instead of being uploaded. The +# repository metadata is the only thing JReleaser leaves out of the bundle. +actual=$(cd "$repository" && find . -type f ! -name 'maven-metadata.xml*' | + sed -E 's#^\./##; s#(\.asc)?(\.(md5|sha1|sha256|sha512))?$##' | sort -u) if [[ $actual != "$expected" ]]; then echo 'Staged artifacts differ from the expected release components:' >&2 diff <(echo "$expected") <(echo "$actual") >&2 || true exit 1 fi +while IFS= read -r component; do + if [[ ! -f $repository/$component ]]; then + echo "Staged release lacks $component" >&2 + exit 1 + fi +done <<<"$expected" relocation=$(tr -d ' \n\r\t' < "$repository/$legacy.pom") for element in 'org.owasp.html-sanitizerhtml-sanitizer' \ @@ -44,6 +52,23 @@ if [[ $relocation == *''* || $target == *''* ]]; then exit 1 fi +# The library has no runtime dependencies and the shims are not published, +# so a dependency in its POM that is neither test nor provided scope would +# reach every consumer, and one on a shim would not resolve. +pom=$(tr -d ' \n\r\t' < "$repository/$library.pom") +if [[ $pom == *''* ]]; then + pom=${pom%%*}${pom##*} +fi +dependencies=${pom#*} +dependencies=${dependencies%%*} +declared=$(grep -o '' <<<"$dependencies" | wc -l | tr -d ' ') +scoped=$(grep -o -E '(test|provided)' <<<"$dependencies" | wc -l | tr -d ' ') +if [[ $pom != *''* || $pom == *''* || + $declared -eq 0 || $declared -ne $scoped ]]; then + echo "Library POM must declare only test and provided dependencies: $declared declared, $scoped so scoped" >&2 + exit 1 +fi + entries=$(unzip -Z1 "$repository/$library.jar") if ! grep -qx 'META-INF/maven/org.owasp.html-sanitizer/html-sanitizer/pom.properties' <<<"$entries"; then echo 'Library JAR lacks its own Maven metadata' >&2 From 9b518c6c0f31557d105f8ff5180732246404e658 Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 13:17:11 +0700 Subject: [PATCH 07/14] Take the review: list the relocation module for Dependabot The file's own header says a new module needs a line under directories, and legacy-relocation had none. The ignore rule for the new coordinates now covers the whole project namespace, as the rule for the old one does. Co-Authored-By: Claude Fable 5.2 --- .github/dependabot.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 8d2bd07d..c5461d10 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -25,9 +25,10 @@ updates: - "/owasp-java-html-sanitizer" - "/examples" - "/empiricism" + - "/legacy-relocation" schedule: interval: "weekly" open-pull-requests-limit: 0 ignore: - dependency-name: "com.googlecode.owasp-java-html-sanitizer:*" - - dependency-name: "org.owasp.html-sanitizer:html-sanitizer*" + - dependency-name: "org.owasp.html-sanitizer:*" From 29b0b2b40d1cec897758f3a2b06927eaf6f3b22b Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 13:17:11 +0700 Subject: [PATCH 08/14] Take the review: keep the armored key from the wrapped command with-release-key.sh ran its command with GPG_SECRET_KEY and GPG_PUBLIC_KEY still exported, so the armored secret key reached Maven, every plugin and JReleaser, none of which need it once it is in the temporary keyring. They are unset before the command runs. Co-Authored-By: Claude Fable 5.2 --- scripts/with-release-key.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/with-release-key.sh b/scripts/with-release-key.sh index ea7c0133..c4d98864 100755 --- a/scripts/with-release-key.sh +++ b/scripts/with-release-key.sh @@ -41,4 +41,6 @@ fi export JRELEASER_GPG_HOMEDIR=$signing_home export JRELEASER_GPG_KEYNAME=$fingerprint +# The key is in the keyring now; the command has no use for the armored copy. +unset GPG_SECRET_KEY GPG_PUBLIC_KEY "$@" From 6578f6948dade8805b528584fa2f59d4c066dd44 Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 13:17:11 +0700 Subject: [PATCH 09/14] Take the review: the shim comments no longer name the old jar Co-Authored-By: Claude Fable 5.2 --- java10-shim/pom.xml | 2 +- java8-shim/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/java10-shim/pom.xml b/java10-shim/pom.xml index 63ca276b..b626b054 100644 --- a/java10-shim/pom.xml +++ b/java10-shim/pom.xml @@ -18,7 +18,7 @@ 10 - + true diff --git a/java8-shim/pom.xml b/java8-shim/pom.xml index 39e50bc0..b1ec15dc 100644 --- a/java8-shim/pom.xml +++ b/java8-shim/pom.xml @@ -12,7 +12,7 @@ https://github.com/OWASP/java-html-sanitizer - + true From 3290f42229c26db799c2b8011f37516a76351a47 Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 13:17:32 +0700 Subject: [PATCH 10/14] Take the review: ship the migration docs with the coordinate change The release workflow rewrites the version in docs/maven.md in place. With the docs left for a later change, a release cut in between, such as an urgent security fix, would have told users to depend on the old coordinates at a version that is only a relocation POM, and the relocation message would have sent them to a guide that did not yet mention the move. The Maven guide, the README badge and the javadoc and download links now name org.owasp.html-sanitizer:html-sanitizer, and docs/maven.md gains a migration section: what changed and what did not, where the old coordinates may be named, what the relocation POM does, and how to find and remove a second copy of the library when an older release still arrives under the old coordinates. The Maven and Gradle fixes it lists were each resolved against a staged repository. The change log entry says the same in brief. This pull request should therefore be merged just before the first release under the new coordinates: until then they, and the javadoc.io pages for them, do not exist. See issue #531. Co-Authored-By: Claude Fable 5.2 --- README.md | 12 ++--- change_log.md | 8 ++-- docs/getting_started.md | 16 +++---- docs/maven.md | 100 ++++++++++++++++++++++++++++++++++++++-- 4 files changed, 115 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 5b2e28e4..5b33f575 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OWASP Java HTML Sanitizer -[![Build](https://github.com/OWASP/java-html-sanitizer/actions/workflows/build.yml/badge.svg)](https://github.com/OWASP/java-html-sanitizer/actions/workflows/build.yml) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/2602/badge)](https://www.bestpractices.dev/projects/2602) [![Maven Central](https://img.shields.io/maven-central/v/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer.svg)](https://search.maven.org/artifact/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer) +[![Build](https://github.com/OWASP/java-html-sanitizer/actions/workflows/build.yml/badge.svg)](https://github.com/OWASP/java-html-sanitizer/actions/workflows/build.yml) [![OpenSSF Best Practices](https://www.bestpractices.dev/projects/2602/badge)](https://www.bestpractices.dev/projects/2602) [![Maven Central](https://img.shields.io/maven-central/v/org.owasp.html-sanitizer/html-sanitizer.svg)](https://central.sonatype.com/artifact/org.owasp.html-sanitizer/html-sanitizer) A fast and easy to configure HTML Sanitizer written in Java which lets @@ -60,7 +60,7 @@ with `-pl`, also use `-am` so Maven builds the modules it depends on. ## Prepackaged Policies You can use -[prepackaged policies](https://www.javadoc.io/doc/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/Sanitizers.html): +[prepackaged policies](https://www.javadoc.io/doc/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/Sanitizers.html): ```Java PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS); @@ -72,7 +72,7 @@ String safeHTML = policy.sanitize(untrustedHTML); The [tests](https://github.com/OWASP/java-html-sanitizer/blob/main/owasp-java-html-sanitizer/src/test/java/org/owasp/html/HtmlPolicyBuilderTest.java) show how to configure your own -[policy](https://www.javadoc.io/doc/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/HtmlPolicyBuilder.html): +[policy](https://www.javadoc.io/doc/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/HtmlPolicyBuilder.html): ```Java PolicyFactory policy = new HtmlPolicyBuilder() @@ -87,7 +87,7 @@ String safeHTML = policy.sanitize(untrustedHTML); ## Custom Policies You can write -[custom policies](https://www.javadoc.io/doc/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/ElementPolicy.html) +[custom policies](https://www.javadoc.io/doc/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/ElementPolicy.html) to do things like changing `h1`s to `div`s with a certain class: ```Java @@ -110,7 +110,7 @@ need to be explicitly whitelisted using the `allowWithoutAttributes()` method if you want them to be allowed through the filter when these elements do not include any attributes. -[Attribute policies](https://www.javadoc.io/doc/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/AttributePolicy.html) allow running custom code too. Adding an attribute policy will not water down any default policy like `style` or URL attribute checks. +[Attribute policies](https://www.javadoc.io/doc/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/AttributePolicy.html) allow running custom code too. Adding an attribute policy will not water down any default policy like `style` or URL attribute checks. ```Java PolicyFactory myPolicy = new HtmlPolicyBuilder() @@ -179,7 +179,7 @@ of the output. ## Telemetry -When a policy rejects an element or attribute it notifies an [HtmlChangeListener](https://www.javadoc.io/doc/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/HtmlChangeListener.html). +When a policy rejects an element or attribute it notifies an [HtmlChangeListener](https://www.javadoc.io/doc/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/HtmlChangeListener.html). You can use this to keep track of policy violation trends and find out when someone is making an effort to breach your security. diff --git a/change_log.md b/change_log.md index a199462f..5d07786e 100644 --- a/change_log.md +++ b/change_log.md @@ -8,9 +8,11 @@ Most recent at top. get a relocation POM with each release that points to the new ones; releases already published there are unchanged. Java packages, the JPMS module name and the OSGi bundle symbolic name are unchanged. - Replace the old coordinates with the new ones: a dependency that still - names an older release under the old coordinates puts a second copy of - the library on the class path. See issue #531. + Replace the old coordinates with the new ones. If another dependency + still brings in an older release under the old coordinates, the build + resolves both JARs and the older one can be the one that loads: manage + the old coordinates to the new version, or exclude them. + `docs/maven.md` has the steps. See issue #531. * Release artifacts and tags are signed with the project release key, fingerprint `F6109A4F3F5616E1A7A62099E02DB03BAF6C438C`, and artifact signatures use SHA-512 instead of SHA-1. diff --git a/docs/getting_started.md b/docs/getting_started.md index a69cb9b9..6b8a029b 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -4,11 +4,11 @@ If you are using Maven then follow the [maven](maven.md) directions to add a dependency. Otherwise, -[download prebuilt jars](https://search.maven.org/artifact/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/) +[download prebuilt jars](https://central.sonatype.com/artifact/org.owasp.html-sanitizer/html-sanitizer) or `git clone git@github.com:OWASP/java-html-sanitizer.git` and build the latest source. -Unless maven is managing your CLASSPATH for you, you need to add `owasp-java-html-sanitizer.jar`. +Unless maven is managing your CLASSPATH for you, you need to add `html-sanitizer.jar`. Once you have your CLASSPATH set up correctly with the relevant JARs you should be able to add @@ -29,18 +29,18 @@ project, not classes in the jar: there is nothing under `org.owasp.html.examples` to import. The -[javadoc](https://static.javadoc.io/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/index.html) +[javadoc](https://static.javadoc.io/org.owasp.html-sanitizer/html-sanitizer/latest/index.html) covers more detailed topics, including -[customization](https://static.javadoc.io/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/HtmlPolicyBuilder.html). +[customization](https://static.javadoc.io/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/HtmlPolicyBuilder.html). Important classes are: - * [Sanitizers](https://static.javadoc.io/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/Sanitizers.html) contains combinable pre-packaged policies. - * [HtmlPolicyBuilder](https://static.javadoc.io/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/HtmlPolicyBuilder.html) lets you easily build custom policies. + * [Sanitizers](https://static.javadoc.io/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/Sanitizers.html) contains combinable pre-packaged policies. + * [HtmlPolicyBuilder](https://static.javadoc.io/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/HtmlPolicyBuilder.html) lets you easily build custom policies. For advanced use, see: - * [AttributePolicy](https://static.javadoc.io/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/AttributePolicy.html) and [ElementPolicy](https://static.javadoc.io/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/ElementPolicy.html) allow complex customization. - * [HtmlStreamEventReceiver](https://static.javadoc.io/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/org/owasp/html/HtmlStreamEventReceiver.html) if you don't just want a `String` as output. + * [AttributePolicy](https://static.javadoc.io/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/AttributePolicy.html) and [ElementPolicy](https://static.javadoc.io/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/ElementPolicy.html) allow complex customization. + * [HtmlStreamEventReceiver](https://static.javadoc.io/org.owasp.html-sanitizer/html-sanitizer/latest/org/owasp/html/HtmlStreamEventReceiver.html) if you don't just want a `String` as output. ## Asking Questions diff --git a/docs/maven.md b/docs/maven.md index f4c4b887..e23b03e2 100644 --- a/docs/maven.md +++ b/docs/maven.md @@ -1,20 +1,25 @@ # Using with Maven The HTML Sanitizer is available from -[Maven Central](https://search.maven.org/#browse%7C84770979) +[Maven Central](https://central.sonatype.com/artifact/org.owasp.html-sanitizer/html-sanitizer) Including among your POMs `` this snippet of XML... ```Java - com.googlecode.owasp-java-html-sanitizer - owasp-java-html-sanitizer + org.owasp.html-sanitizer + html-sanitizer 20261110.1 ``` ...will make the sanitizer available. +Releases up to 20261110.1 were published as +`com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`. If +your build names those coordinates, see +[Migrating from the old coordinates](#migrating-from-the-old-coordinates). + The sanitizer JAR is self-contained: the `java8-shim` and `java10-shim` artifacts are bundled inside it and do **not** need to be declared as separate dependencies, including when using the JPMS module path. @@ -44,9 +49,96 @@ Bigger numbers are more recent and the [change log](../change_log.md) can shed light on the salient differences. You should be able to build with the HTML sanitizer. You can read the -[javadoc](https://static.javadoc.io/com.googlecode.owasp-java-html-sanitizer/owasp-java-html-sanitizer/latest/index.html), +[javadoc](https://static.javadoc.io/org.owasp.html-sanitizer/html-sanitizer/latest/index.html), and if you have questions that aren't answered by these pages, you can ask in [GitHub Discussions](https://github.com/OWASP/java-html-sanitizer/discussions/categories/q-a). Happy sanitizing... + +## Migrating from the old coordinates + +Releases up to 20261110.1 were published as +`com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer`. Later +releases are published as `org.owasp.html-sanitizer:html-sanitizer`. Only +the coordinates changed: the Java package is still `org.owasp.html`, the JPMS +module is still `owasp.java.html.sanitizer`, the OSGi bundle symbolic name is +still `com.googlecode.owasp-java-html-sanitizer`, version numbers continue +the same sequence, and the JAR still runs on Java 8. + +Replace the old coordinates with the new ones wherever your build names +them: + + * dependency declarations and `` entries, BOMs and + Gradle version catalogs; + * exclusions, which match on coordinates: an exclusion of the old + coordinates does not exclude the new ones; + * lock files and dependency verification files, which need regenerating; + * allowlists in repository managers and license or security scanners. + +The old coordinates keep getting a relocation POM with each release. It +contains no code. A build that asks for a later release under the old +coordinates gets the JAR from the new ones, and Maven prints a warning that +the artifact has been relocated. This keeps dependency update tools working, +but it is a bridge, not a place to stay. + +**A build pinned to 20261110.1 or earlier does not migrate by itself, and +gets no further fixes.** Those releases are unchanged and carry no +relocation. + +### Two copies on the class path + +Maven and Gradle treat the old and new coordinates as unrelated artifacts. +If your build depends on the new coordinates while another dependency still +brings in 20261110.1 or earlier under the old ones, both JARs are resolved. +They contain the same classes, and the JVM uses whichever comes first on the +class path or module path, so an older sanitizer can silently be the one +that runs. Check for this after migrating: + +``` +mvn dependency:tree -Dincludes=com.googlecode.owasp-java-html-sanitizer +gradle dependencyInsight --dependency owasp-java-html-sanitizer +``` + +If the old coordinates show up, do one of these. Each leaves a single JAR, +the new one. + +Maven, manage the old coordinates to a relocated version, the one you use +under the new coordinates: + +```Java + + + + com.googlecode.owasp-java-html-sanitizer + owasp-java-html-sanitizer + 20261110.1 + + + +``` + +Maven, or exclude them from the dependency that brings them in: + +```Java + + + com.googlecode.owasp-java-html-sanitizer + owasp-java-html-sanitizer + + +``` + +Gradle, substitute the new module for the old one in every configuration, +with the version you use in place of `VERSION`: + +``` +configurations.all { + resolutionStrategy.dependencySubstitution { + substitute module('com.googlecode.owasp-java-html-sanitizer:owasp-java-html-sanitizer') using module('org.owasp.html-sanitizer:html-sanitizer:VERSION') + } +} +``` + +A Gradle dependency constraint on the old coordinates at a relocated +version, or an `exclude`, works as well. From 1b4b7d5541f094ca325734afd9d775636c9b141b Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 13:27:11 +0700 Subject: [PATCH 11/14] Say why the staging check failed when a count is zero The script runs with pipefail, so when the library POM held no dependency, or none in test or provided scope, the grep that counts them matched nothing, failed the pipeline, and ended the script with status 1 and no message. The release was stopped, correctly, but the log did not say by what. The counts now tolerate zero matches and the check reports them. Co-Authored-By: Claude Fable 5.2 --- scripts/check-staged-release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/check-staged-release.sh b/scripts/check-staged-release.sh index 9eb29c63..76a4f5e7 100755 --- a/scripts/check-staged-release.sh +++ b/scripts/check-staged-release.sh @@ -61,8 +61,8 @@ if [[ $pom == *''* ]]; then fi dependencies=${pom#*} dependencies=${dependencies%%*} -declared=$(grep -o '' <<<"$dependencies" | wc -l | tr -d ' ') -scoped=$(grep -o -E '(test|provided)' <<<"$dependencies" | wc -l | tr -d ' ') +declared=$({ grep -o '' <<<"$dependencies" || true; } | wc -l | tr -d ' ') +scoped=$({ grep -o -E '(test|provided)' <<<"$dependencies" || true; } | wc -l | tr -d ' ') if [[ $pom != *''* || $pom == *''* || $declared -eq 0 || $declared -ne $scoped ]]; then echo "Library POM must declare only test and provided dependencies: $declared declared, $scoped so scoped" >&2 From 89a68e2446aed5f4efd5e12f6d336160ccfb121a Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 14:11:14 +0700 Subject: [PATCH 12/14] Take the review: the staging check reads every dependency in the POM The check read only the first dependencies element outside build. The dependency-reduced POM writes profiles before dependencies, so a profile holding only test dependencies was the block that got read, and a compile-scope dependency in the main block after it passed. The reviewer got this through a real publication build. Every dependency outside build is counted now, and a POM with profiles or dependency management of its own is refused, since the count would misread it; the library POM has neither. The file listing also takes symbolic links, which JReleaser follows into the bundle and find -type f skipped. Co-Authored-By: Claude Fable 5.2 --- scripts/check-staged-release.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/scripts/check-staged-release.sh b/scripts/check-staged-release.sh index 76a4f5e7..c9c6602f 100755 --- a/scripts/check-staged-release.sh +++ b/scripts/check-staged-release.sh @@ -22,8 +22,9 @@ expected=$(printf '%s\n' "$library.jar" "$library.pom" "$library-javadoc.jar" \ "$library-sources.jar" "$parent.pom" "$legacy.pom" | sort) # A checksum or signature counts as the file it belongs to, so one that sits # beside no expected component is reported instead of being uploaded. The -# repository metadata is the only thing JReleaser leaves out of the bundle. -actual=$(cd "$repository" && find . -type f ! -name 'maven-metadata.xml*' | +# repository metadata is the only thing JReleaser leaves out of the bundle, +# and it follows symbolic links, so they are listed too. +actual=$(cd "$repository" && find . ! -type d ! -name 'maven-metadata.xml*' | sed -E 's#^\./##; s#(\.asc)?(\.(md5|sha1|sha256|sha512))?$##' | sort -u) if [[ $actual != "$expected" ]]; then echo 'Staged artifacts differ from the expected release components:' >&2 @@ -56,15 +57,19 @@ fi # so a dependency in its POM that is neither test nor provided scope would # reach every consumer, and one on a shim would not resolve. pom=$(tr -d ' \n\r\t' < "$repository/$library.pom") +# The count below takes every dependency outside as one a consumer +# gets. A profile or dependency management would put others among them, +# and the POM has neither, so refuse one that does rather than misread it. +if [[ $pom == *''* || $pom == *''* ]]; then + echo 'Library POM has profiles or dependency management, which this check does not read' >&2 + exit 1 +fi if [[ $pom == *''* ]]; then pom=${pom%%*}${pom##*} fi -dependencies=${pom#*} -dependencies=${dependencies%%*} -declared=$({ grep -o '' <<<"$dependencies" || true; } | wc -l | tr -d ' ') -scoped=$({ grep -o -E '(test|provided)' <<<"$dependencies" || true; } | wc -l | tr -d ' ') -if [[ $pom != *''* || $pom == *''* || - $declared -eq 0 || $declared -ne $scoped ]]; then +declared=$({ grep -o '' <<<"$pom" || true; } | wc -l | tr -d ' ') +scoped=$({ grep -o -E '(test|provided)' <<<"$pom" || true; } | wc -l | tr -d ' ') +if [[ $declared -eq 0 || $declared -ne $scoped ]]; then echo "Library POM must declare only test and provided dependencies: $declared declared, $scoped so scoped" >&2 exit 1 fi From dd2312706632ee0af9b3f809b971736579eeac82 Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 14:12:30 +0700 Subject: [PATCH 13/14] Take the review: close four gaps in the Central validation script A bundle that could not be read, or held no POM, skipped the published check in silence and went on to upload; it now stops. A reply of {"published":"false"}, a string, passed as unpublished; the value must be the boolean. When the upload request failed or returned no identifier, nothing said that Central might still hold a deployment; a warning now does. A status reply that was not JSON ended the run on jq's parse error; it now counts as a failed request and the reply is logged if three come in a row. Co-Authored-By: Claude Fable 5.2 --- scripts/validate-central-bundle.sh | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/scripts/validate-central-bundle.sh b/scripts/validate-central-bundle.sh index 442106e0..acec34dd 100755 --- a/scripts/validate-central-bundle.sh +++ b/scripts/validate-central-bundle.sh @@ -47,6 +47,11 @@ call() { # JReleaser asks Central whether each POM's coordinates are already # published before it uploads, so ask the same question with the same token. +poms=$(unzip -Z1 "$bundle" | grep '\.pom$') || true +if [[ -z $poms ]]; then + echo "Deployment bundle $bundle cannot be read or holds no POM" >&2 + exit 1 +fi while IFS= read -r pom; do artifact_version=${pom%/*} artifact_path=${artifact_version%/*} @@ -56,16 +61,18 @@ while IFS= read -r pom; do version=${artifact_version##*/} published=$(call --get --data-urlencode "namespace=$namespace" --data-urlencode "name=$name" \ --data-urlencode "version=$version" "$api/published") - if [[ $(jq -r '.published' <<<"$published") != false ]]; then + if ! jq -e '.published == false' <<<"$published" > /dev/null 2>&1; then echo "Central does not report $namespace:$name:$version as unpublished: $published" >&2 exit 1 fi echo "Not yet published, as expected: $namespace:$name:$version" -done < <(unzip -Z1 "$bundle" | grep '\.pom$') +done <<<"$poms" -uploaded=$(call --request POST --form "bundle=@$bundle" \ - "$api/upload?name=validation-only-DO-NOT-PUBLISH&publishingType=USER_MANAGED") -if [[ ! $uploaded =~ ^[0-9a-f-]{36}$ ]]; then +# If the request fails part-way, Central may still have taken the bundle. +if ! uploaded=$(call --request POST --form "bundle=@$bundle" \ + "$api/upload?name=validation-only-DO-NOT-PUBLISH&publishingType=USER_MANAGED") || + [[ ! $uploaded =~ ^[0-9a-f-]{36}$ ]]; then + echo "::warning::The upload may have left a deployment; look at $portal and drop it without publishing" >&2 echo 'Central did not return a deployment identifier' >&2 exit 1 fi @@ -76,20 +83,23 @@ state=PENDING status= failures=0 for _ in $(seq 60); do - if status=$(call --request POST "$api/status?id=$deployment"); then + # An answer that is not JSON counts as no answer. + if status=$(call --request POST "$api/status?id=$deployment") && + parsed=$(jq -r '.deploymentState // "UNKNOWN"' <<<"$status" 2> /dev/null); then failures=0 - state=$(jq -r '.deploymentState // "UNKNOWN"' <<<"$status") + state=$parsed if [[ $state != PENDING && $state != VALIDATING ]]; then break fi elif ((++failures >= 3)); then - echo 'Central did not answer three status requests in a row' >&2 + printf '%s\n' "$status" >&2 + echo 'Central gave no usable answer to three status requests in a row' >&2 exit 1 fi sleep "$poll_seconds" done echo "Deployment state: $state" -jq '{deploymentState, purls, errors}' <<<"$status" +jq '{deploymentState, purls, errors}' <<<"$status" 2> /dev/null || printf '%s\n' "$status" # Central drops only deployments that have finished validating. One that # is left behind stays unpublished, and the exit handler says so. From b0755947b5c17a6d67958b8513e997c5f1ab2f91 Mon Sep 17 00:00:00 2001 From: Jim Manico Date: Tue, 24 Nov 2026 14:12:42 +0700 Subject: [PATCH 14/14] Take the review: say which version of the old coordinates matters After a correct fix Gradle's dependencyInsight still lists the old coordinates, at the relocated version, so "if the old coordinates show up" sent readers looking for a problem they no longer had. The guide now says to act on 20261110.1 or earlier. Co-Authored-By: Claude Fable 5.2 --- docs/maven.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/maven.md b/docs/maven.md index e23b03e2..df9716f9 100644 --- a/docs/maven.md +++ b/docs/maven.md @@ -100,8 +100,10 @@ mvn dependency:tree -Dincludes=com.googlecode.owasp-java-html-sanitizer gradle dependencyInsight --dependency owasp-java-html-sanitizer ``` -If the old coordinates show up, do one of these. Each leaves a single JAR, -the new one. +If either shows the old coordinates at 20261110.1 or earlier, do one of +these. Each leaves a single JAR, the new one. The old coordinates at a +later version are only the relocation, which Gradle still lists, and are +harmless. Maven, manage the old coordinates to a relocated version, the one you use under the new coordinates: