You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by el...@apache.org on 2025/06/02 10:24:26 UTC
(maven-javadoc-plugin) branch 387 created (now ff7f20cc)
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a change to branch 387
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
at ff7f20cc Remove workaround for long patched CVE in javadoc
This branch includes the following new commits:
new ff7f20cc Remove workaround for long patched CVE in javadoc
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(maven-javadoc-plugin) 01/01: Remove workaround for long patched CVE in javadoc
Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
elharo pushed a commit to branch 387
in repository https://gitbox.apache.org/repos/asf/maven-javadoc-plugin.git
commit ff7f20cc91bf7b2a1a2c8d2dd3c85e3d26b473bb
Author: Elliotte Rusty Harold <el...@ibiblio.org>
AuthorDate: Mon Jun 2 06:24:13 2025 -0400
Remove workaround for long patched CVE in javadoc
---
.../maven/plugins/javadoc/AbstractJavadocMojo.java | 69 +---------------------
1 file changed, 3 insertions(+), 66 deletions(-)
diff --git a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
index d0f1a272..84bb0359 100644
--- a/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
+++ b/src/main/java/org/apache/maven/plugins/javadoc/AbstractJavadocMojo.java
@@ -19,7 +19,6 @@
package org.apache.maven.plugins.javadoc;
import java.io.File;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
@@ -118,9 +117,7 @@ import org.codehaus.plexus.languages.java.jpms.ResolvePathResult;
import org.codehaus.plexus.languages.java.jpms.ResolvePathsRequest;
import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult;
import org.codehaus.plexus.languages.java.version.JavaVersion;
-import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -1567,10 +1564,10 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
private List<String> sourceFileExcludes;
/**
- * To apply a security fix on generated javadoc, see
- * <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-1571>CVE-2013-157</a>.
+ * No-op. Not needed in Java 8+ or the most recent versions of JDK 6 and 7.
* @since 2.9.1
*/
+ @Deprecated
@Parameter(defaultValue = "true", property = "maven.javadoc.applyJavadocSecurityFix")
private boolean applyJavadocSecurityFix = true;
@@ -2079,20 +2076,6 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
scriptFile.delete();
}
}
- if (applyJavadocSecurityFix) {
- // finally, patch the Javadoc vulnerability in older Javadoc tools (CVE-2013-1571):
- try {
- final int patched = fixFrameInjectionBug(javadocOutputDirectory, getDocencoding());
- if (patched > 0) {
- getLog().info(String.format(
- "Fixed Javadoc frame injection vulnerability (CVE-2013-1571) in %d files.", patched));
- }
- } catch (IOException e) {
- throw new MavenReportException("Failed to patch javadocs vulnerability: " + e.getMessage(), e);
- }
- } else {
- getLog().info("applying javadoc security fix has been disabled");
- }
}
/**
@@ -5197,53 +5180,7 @@ public abstract class AbstractJavadocMojo extends AbstractMojo {
}
/**
- * Patches the given Javadoc output directory to work around CVE-2013-1571
- * (see http://www.kb.cert.org/vuls/id/225657).
- *
- * @param javadocOutputDirectory directory to scan for vulnerabilities
- * @param outputEncoding encoding used by the javadoc tool (-docencoding parameter).
- * If {@code null}, the platform's default encoding is used (like javadoc does).
- * @return the number of patched files
- */
- private int fixFrameInjectionBug(File javadocOutputDirectory, String outputEncoding) throws IOException {
- final String fixData;
-
- try (InputStream in = this.getClass().getResourceAsStream("frame-injection-fix.txt")) {
- if (in == null) {
- throw new FileNotFoundException("Missing resource 'frame-injection-fix.txt' in classpath.");
- }
- fixData = org.codehaus.plexus.util.StringUtils.unifyLineSeparators(IOUtil.toString(in, "US-ASCII"))
- .trim();
- }
-
- final DirectoryScanner ds = new DirectoryScanner();
- ds.setBasedir(javadocOutputDirectory);
- ds.setCaseSensitive(false);
- ds.setIncludes(new String[] {"**/index.html", "**/index.htm", "**/toc.html", "**/toc.htm"});
- ds.addDefaultExcludes();
- ds.scan();
- int patched = 0;
- for (String f : ds.getIncludedFiles()) {
- final File file = new File(javadocOutputDirectory, f);
- // we load the whole file as one String (toc/index files are
- // generally small, because they only contain frameset declaration):
- final String fileContents = FileUtils.fileRead(file, outputEncoding);
- // check if file may be vulnerable because it was not patched with "validURL(url)":
- if (!StringUtils.contains(fileContents, "function validURL(url) {")) {
- // we need to patch the file!
- final String patchedFileContents =
- StringUtils.replaceOnce(fileContents, "function loadFrames() {", fixData);
- if (!patchedFileContents.equals(fileContents)) {
- FileUtils.fileWrite(file, outputEncoding, patchedFileContents);
- patched++;
- }
- }
- }
- return patched;
- }
-
- /**
- * @param outputFile not nul
+ * @param outputFile not null
* @param inputResourceName a not null resource in <code>src/main/java</code>, <code>src/main/resources</code> or
* <code>src/main/javadoc</code> or in the Javadoc plugin dependencies.
* @return the resource file absolute path as String