|
19 | 19 | package org.apache.maven.plugins.javadoc;
|
20 | 20 |
|
21 | 21 | import java.io.File;
|
22 |
| -import java.io.FileNotFoundException; |
23 | 22 | import java.io.IOException;
|
24 | 23 | import java.io.InputStream;
|
25 | 24 | import java.io.Writer;
|
|
118 | 117 | import org.codehaus.plexus.languages.java.jpms.ResolvePathsRequest;
|
119 | 118 | import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult;
|
120 | 119 | import org.codehaus.plexus.languages.java.version.JavaVersion;
|
121 |
| -import org.codehaus.plexus.util.DirectoryScanner; |
122 | 120 | import org.codehaus.plexus.util.FileUtils;
|
123 |
| -import org.codehaus.plexus.util.IOUtil; |
124 | 121 | import org.codehaus.plexus.util.WriterFactory;
|
125 | 122 | import org.codehaus.plexus.util.cli.CommandLineException;
|
126 | 123 | import org.codehaus.plexus.util.cli.CommandLineUtils;
|
@@ -735,6 +732,7 @@ public AbstractJavadocMojo(
|
735 | 732 | /**
|
736 | 733 | * This option creates documentation with the appearance and functionality of documentation generated by
|
737 | 734 | * Javadoc 1.1. This is no longer supported since Javadoc 1.4 (shipped with JDK 1.4)
|
| 735 | + * |
738 | 736 | * @see <a href="https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#a1.1">Javadoc option 1.1</a>.
|
739 | 737 | */
|
740 | 738 | @Parameter(property = "old", defaultValue = "false")
|
@@ -1567,10 +1565,13 @@ public AbstractJavadocMojo(
|
1567 | 1565 | private List<String> sourceFileExcludes;
|
1568 | 1566 |
|
1569 | 1567 | /**
|
1570 |
| - * To apply a security fix on generated javadoc, see |
1571 |
| - * <a href="https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2013-1571>CVE-2013-157</a>. |
| 1568 | + * No-op. |
| 1569 | + * |
| 1570 | + * @deprecated the security fix this applied is not needed in Java 8+ or the most recent |
| 1571 | + * versions of JDK 6 and 7. |
1572 | 1572 | * @since 2.9.1
|
1573 | 1573 | */
|
| 1574 | + @Deprecated |
1574 | 1575 | @Parameter(defaultValue = "true", property = "maven.javadoc.applyJavadocSecurityFix")
|
1575 | 1576 | private boolean applyJavadocSecurityFix = true;
|
1576 | 1577 |
|
@@ -2079,20 +2080,6 @@ protected void executeReport(Locale unusedLocale) throws MavenReportException {
|
2079 | 2080 | scriptFile.delete();
|
2080 | 2081 | }
|
2081 | 2082 | }
|
2082 |
| - if (applyJavadocSecurityFix) { |
2083 |
| - // finally, patch the Javadoc vulnerability in older Javadoc tools (CVE-2013-1571): |
2084 |
| - try { |
2085 |
| - final int patched = fixFrameInjectionBug(javadocOutputDirectory, getDocencoding()); |
2086 |
| - if (patched > 0) { |
2087 |
| - getLog().info(String.format( |
2088 |
| - "Fixed Javadoc frame injection vulnerability (CVE-2013-1571) in %d files.", patched)); |
2089 |
| - } |
2090 |
| - } catch (IOException e) { |
2091 |
| - throw new MavenReportException("Failed to patch javadocs vulnerability: " + e.getMessage(), e); |
2092 |
| - } |
2093 |
| - } else { |
2094 |
| - getLog().info("applying javadoc security fix has been disabled"); |
2095 |
| - } |
2096 | 2083 | }
|
2097 | 2084 |
|
2098 | 2085 | /**
|
@@ -5197,53 +5184,7 @@ private boolean isInformationalOutput(String str) {
|
5197 | 5184 | }
|
5198 | 5185 |
|
5199 | 5186 | /**
|
5200 |
| - * Patches the given Javadoc output directory to work around CVE-2013-1571 |
5201 |
| - * (see http://www.kb.cert.org/vuls/id/225657). |
5202 |
| - * |
5203 |
| - * @param javadocOutputDirectory directory to scan for vulnerabilities |
5204 |
| - * @param outputEncoding encoding used by the javadoc tool (-docencoding parameter). |
5205 |
| - * If {@code null}, the platform's default encoding is used (like javadoc does). |
5206 |
| - * @return the number of patched files |
5207 |
| - */ |
5208 |
| - private int fixFrameInjectionBug(File javadocOutputDirectory, String outputEncoding) throws IOException { |
5209 |
| - final String fixData; |
5210 |
| - |
5211 |
| - try (InputStream in = this.getClass().getResourceAsStream("frame-injection-fix.txt")) { |
5212 |
| - if (in == null) { |
5213 |
| - throw new FileNotFoundException("Missing resource 'frame-injection-fix.txt' in classpath."); |
5214 |
| - } |
5215 |
| - fixData = org.codehaus.plexus.util.StringUtils.unifyLineSeparators(IOUtil.toString(in, "US-ASCII")) |
5216 |
| - .trim(); |
5217 |
| - } |
5218 |
| - |
5219 |
| - final DirectoryScanner ds = new DirectoryScanner(); |
5220 |
| - ds.setBasedir(javadocOutputDirectory); |
5221 |
| - ds.setCaseSensitive(false); |
5222 |
| - ds.setIncludes(new String[] {"**/index.html", "**/index.htm", "**/toc.html", "**/toc.htm"}); |
5223 |
| - ds.addDefaultExcludes(); |
5224 |
| - ds.scan(); |
5225 |
| - int patched = 0; |
5226 |
| - for (String f : ds.getIncludedFiles()) { |
5227 |
| - final File file = new File(javadocOutputDirectory, f); |
5228 |
| - // we load the whole file as one String (toc/index files are |
5229 |
| - // generally small, because they only contain frameset declaration): |
5230 |
| - final String fileContents = FileUtils.fileRead(file, outputEncoding); |
5231 |
| - // check if file may be vulnerable because it was not patched with "validURL(url)": |
5232 |
| - if (!StringUtils.contains(fileContents, "function validURL(url) {")) { |
5233 |
| - // we need to patch the file! |
5234 |
| - final String patchedFileContents = |
5235 |
| - StringUtils.replaceOnce(fileContents, "function loadFrames() {", fixData); |
5236 |
| - if (!patchedFileContents.equals(fileContents)) { |
5237 |
| - FileUtils.fileWrite(file, outputEncoding, patchedFileContents); |
5238 |
| - patched++; |
5239 |
| - } |
5240 |
| - } |
5241 |
| - } |
5242 |
| - return patched; |
5243 |
| - } |
5244 |
| - |
5245 |
| - /** |
5246 |
| - * @param outputFile not nul |
| 5187 | + * @param outputFile not null |
5247 | 5188 | * @param inputResourceName a not null resource in <code>src/main/java</code>, <code>src/main/resources</code> or
|
5248 | 5189 | * <code>src/main/javadoc</code> or in the Javadoc plugin dependencies.
|
5249 | 5190 | * @return the resource file absolute path as String
|
|
0 commit comments