Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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*"
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
env:
VERSION: ${{ github.event.inputs.version }}
NEXT_VERSION: 20000101-SNAPSHOT
EXPECTED_GPG_FINGERPRINT: F6109A4F3F5616E1A7A62099E02DB03BAF6C438C

jobs:
release:
Expand Down Expand Up @@ -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 }}
Expand All @@ -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()
Expand All @@ -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
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/verify-release-signing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
12 changes: 12 additions & 0 deletions change_log.md
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
14 changes: 7 additions & 7 deletions empiricism/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>empiricism</artifactId>
<artifactId>java-html-sanitizer-empiricism</artifactId>
<version>20000101-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>parent</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-parent</artifactId>
<version>20000101-SNAPSHOT</version>
</parent>

Expand All @@ -22,13 +22,13 @@

<dependencies>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>owasp-java-html-sanitizer</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>java8-shim</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-java8-shim</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
18 changes: 9 additions & 9 deletions examples/pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>examples</artifactId>
<artifactId>java-html-sanitizer-examples</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>parent</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-parent</artifactId>
<version>20000101-SNAPSHOT</version>
</parent>

Expand All @@ -29,8 +29,8 @@

<dependencies>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>owasp-java-html-sanitizer</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer</artifactId>
<version>${project.version}</version>
</dependency>
<!-- The shims are optional dependencies of the sanitizer, so they do not
Expand All @@ -43,14 +43,14 @@
the Java 8 fallback while `mvn verify`, which puts the shaded jar
first, ran against ForJava10AndLater. -->
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>java8-shim</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-java8-shim</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>java10-shim</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-java10-shim</artifactId>
<version>${project.version}</version>
<scope>runtime</scope>
</dependency>
Expand Down
10 changes: 5 additions & 5 deletions java10-shim/pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>java10-shim</artifactId>
<artifactId>java-html-sanitizer-java10-shim</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>parent</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-parent</artifactId>
<version>20000101-SNAPSHOT</version>
</parent>

Expand Down Expand Up @@ -59,8 +59,8 @@

<dependencies>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>java8-shim</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-java8-shim</artifactId>
</dependency>
</dependencies>
</project>
6 changes: 3 additions & 3 deletions java8-shim/pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>java8-shim</artifactId>
<artifactId>java-html-sanitizer-java8-shim</artifactId>
<packaging>jar</packaging>
<parent>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>parent</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-parent</artifactId>
<version>20000101-SNAPSHOT</version>
</parent>

Expand Down
34 changes: 34 additions & 0 deletions legacy-relocation/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause -->
<!-- Published with every release at the coordinates used before issue #531,
so that builds and dependency update tools that still name them are
pointed at the same version under org.owasp. It carries no code and no
dependencies. The relocation leaves the version out, so it always
points at the release it is published with. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-parent</artifactId>
<version>20000101-SNAPSHOT</version>
</parent>

<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>owasp-java-html-sanitizer</artifactId>
<packaging>pom</packaging>

<name>OWASP Java HTML Sanitizer (relocated)</name>
<description>
Relocation to org.owasp:java-html-sanitizer. Releases from this version
on are published only under the new coordinates.
</description>
<url>https://github.com/OWASP/java-html-sanitizer</url>

<distributionManagement>
<relocation>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer</artifactId>
<message>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</message>
</relocation>
</distributionManagement>
</project>
7 changes: 5 additions & 2 deletions owasp-java-html-sanitizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
35 changes: 23 additions & 12 deletions owasp-java-html-sanitizer/pom.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>owasp-java-html-sanitizer</artifactId>
<artifactId>java-html-sanitizer</artifactId>
<packaging>bundle</packaging>
<parent>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>parent</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-parent</artifactId>
<version>20000101-SNAPSHOT</version>
</parent>

Expand Down Expand Up @@ -119,6 +119,12 @@
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
<!-- bnd derives the default symbolic name from the Maven
coordinates. Releases before the move to org.owasp had
com.googlecode.owasp-java-html-sanitizer, and keeping it
lets OSGi containers treat new releases as upgrades of the
same bundle. See issue #531. -->
<Bundle-SymbolicName>com.googlecode.owasp-java-html-sanitizer</Bundle-SymbolicName>
<Export-Package>org.owasp.html</Export-Package>
<!-- The java8-shim and java10-shim classes are inlined into this
JAR by the shade plugin below, which runs after bnd has
Expand Down Expand Up @@ -190,17 +196,22 @@
multiple JARs. See https://github.com/OWASP/java-html-sanitizer/issues/341 -->
<artifactSet>
<includes>
<include>com.googlecode.owasp-java-html-sanitizer:java8-shim</include>
<include>com.googlecode.owasp-java-html-sanitizer:java10-shim</include>
<include>org.owasp:java-html-sanitizer-java8-shim</include>
<include>org.owasp:java-html-sanitizer-java10-shim</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<!-- Exclude shim Maven metadata to avoid duplicate
pom.properties / pom.xml entries in the JAR -->
<exclude>META-INF/maven/com.googlecode.owasp-java-html-sanitizer/java*/**</exclude>
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. -->
<exclude>META-INF/maven/org.owasp/java-html-sanitizer-java8-shim/**</exclude>
<exclude>META-INF/maven/org.owasp/java-html-sanitizer-java10-shim/**</exclude>
</excludes>
</filter>
<!-- java10-shim is compiled for Java 10. Take only the copy
Expand All @@ -213,7 +224,7 @@
a change to the shim's release moves the class instead
of silently dropping it. See issue #515. -->
<filter>
<artifact>com.googlecode.owasp-java-html-sanitizer:java10-shim</artifact>
<artifact>org.owasp:java-html-sanitizer-java10-shim</artifact>
<includes>
<include>META-INF/versions/**</include>
</includes>
Expand Down Expand Up @@ -338,13 +349,13 @@

<dependencies>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>java8-shim</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-java8-shim</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
<artifactId>java10-shim</artifactId>
<groupId>org.owasp</groupId>
<artifactId>java-html-sanitizer-java10-shim</artifactId>
<optional>true</optional>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<location>target/classes/META-INF/MANIFEST.MF</location>
<contains>Export-Package: org.owasp.html</contains>
</file>
<!-- The OSGi identity predates the move to org.owasp coordinates and
must not follow them. See issue #531. -->
<file>
<location>target/classes/META-INF/MANIFEST.MF</location>
<contains>Bundle-SymbolicName: com.googlecode.owasp-java-html-sanitizer</contains>
</file>
<!-- The JPMS module descriptor is compiled for Java 9 into the
versioned directory of the multi-release jar, and Java 9 and later
look there only when the manifest says Multi-Release. Without
Expand Down
Loading
Loading