Skip to content

Commit b099000

Browse files
authored
Merge pull request #324 from nahsra/upgradeCyberNekoHTMLUnit
Upgrade cyber neko html unit
2 parents ce7e4f0 + 9e34cb6 commit b099000

File tree

7 files changed

+137
-151
lines changed

7 files changed

+137
-151
lines changed

SECURITY.md

+1
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ These are the known CVEs reported for AntiSamy:
3737
CVEs in AntiSamy dependencies:
3838
* AntiSamy prior to 1.6.6 used the old CyberNeko HTML library v1.9.22, which is subject to https://www.cvedetails.com/cve/CVE-2022-28366 and no longer maintained. AntiSamy 1.6.6 upgraded to an active fork of CyberNeko called HtmlUnit-Neko which fixed this CVE in v2.27 of that library. AntiSamy 1.6.6 upgraded to version 2.60.0 of HtmlUnit-Neko.
3939
* AntiSamy 1.6.8 upgraded to HtmlUnit-Neko v2.61.0 because v2.60.0 is subject to https://www.cvedetails.com/cve/CVE-2022-29546
40+
* AntiSamy 1.7.3 upgraded to HtmlUnit-Neko v3.1.0 because all versions prior to 3.0.0 are subject to https://www.cvedetails.com/cve/CVE-2023-26119

pom.xml

+12-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>org.owasp.antisamy</groupId>
66
<artifactId>antisamy</artifactId>
77
<packaging>jar</packaging>
8-
<version>1.7.3-SNAPSHOT</version>
8+
<version>1.7.3</version>
99

1010
<distributionManagement>
1111
<snapshotRepository>
@@ -52,12 +52,12 @@
5252
<fluido.version>2.0.0-M5</fluido.version>
5353
<gpg.skip>true</gpg.skip><!-- by default skip gpg -->
5454
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
55-
<project.build.outputTimestamp>2022-11-18T14:32:45Z</project.build.outputTimestamp>
55+
<project.build.outputTimestamp>2022-04-12T11:03:14Z</project.build.outputTimestamp>
5656
<project.java.target>1.8</project.java.target>
5757
<version.findsecbugs>1.12.0</version.findsecbugs>
5858
<version.io>2.11.0</version.io>
5959
<version.slf4j>2.0.7</version.slf4j>
60-
<version.spotbugs.maven>4.7.3.3</version.spotbugs.maven>
60+
<version.spotbugs.maven>4.7.3.4</version.spotbugs.maven>
6161
<version.spotbugs>4.7.3</version.spotbugs>
6262
</properties>
6363

@@ -72,20 +72,24 @@
7272

7373
<dependencies>
7474
<dependency>
75-
<groupId>net.sourceforge.htmlunit</groupId>
75+
<groupId>org.htmlunit</groupId>
7676
<artifactId>neko-htmlunit</artifactId>
77-
<version>2.70.0</version>
77+
<version>3.1.0</version>
7878
</dependency>
7979
<dependency>
8080
<groupId>org.apache.httpcomponents.client5</groupId>
8181
<artifactId>httpclient5</artifactId>
8282
<version>5.2.1</version>
8383
<exclusions>
84-
<!-- exclude this old version of slf4j-api as newer can be used -->
84+
<!-- exclude old versions of slf4j-api and httpcore5 as newer versions can be used -->
8585
<exclusion>
8686
<groupId>org.slf4j</groupId>
8787
<artifactId>slf4j-api</artifactId>
8888
</exclusion>
89+
<exclusion>
90+
<groupId>org.apache.httpcomponents.core5</groupId>
91+
<artifactId>httpcore5</artifactId>
92+
</exclusion>
8993
</exclusions>
9094
</dependency>
9195
<dependency>
@@ -263,7 +267,7 @@
263267
<plugin>
264268
<groupId>org.apache.maven.plugins</groupId>
265269
<artifactId>maven-enforcer-plugin</artifactId>
266-
<version>3.2.1</version>
270+
<version>3.3.0</version>
267271
<dependencies>
268272
<dependency>
269273
<groupId>org.codehaus.mojo</groupId>
@@ -403,7 +407,7 @@
403407
<plugin>
404408
<groupId>org.apache.maven.plugins</groupId>
405409
<artifactId>maven-site-plugin</artifactId>
406-
<version>4.0.0-M6</version>
410+
<version>4.0.0-M7</version>
407411
<dependencies>
408412
<!-- Explicitly declare these dependencies so the versions plugin and library bots will flag available updates. The fluido-skin
409413
plugin is referenced in src/site/site.xml using the same fluido version property. -->

src/main/java/org/owasp/validator/html/scan/AbstractAntiSamyScanner.java

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
/*
2-
* Copyright (c) 2007-2022, Arshan Dabirsiaghi, Jason Li
2+
* Copyright (c) 2007-2023, Arshan Dabirsiaghi, Jason Li
33
*
44
* All rights reserved.
55
*
6-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6+
* Redistribution and use in source and binary forms, with or without modification, are permitted
7+
* provided that the following conditions are met:
78
*
8-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10-
* Neither the name of OWASP nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9+
* Redistributions of source code must retain the above copyright notice, this list of conditions
10+
* and the following disclaimer. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the documentation and/or other
12+
* materials provided with the distribution. Neither the name of OWASP nor the names of its
13+
* contributors may be used to endorse or promote products derived from this software without
14+
* specific prior written permission.
1115
*
12-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
16-
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18-
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
17+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18+
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22+
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
23+
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2324
*/
2425

2526
package org.owasp.validator.html.scan;

src/main/java/org/owasp/validator/html/scan/AntiSamyDOMScanner.java

+20-24
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
/*
2-
* Copyright (c) 2007-2022, Arshan Dabirsiaghi, Jason Li
2+
* Copyright (c) 2007-2023, Arshan Dabirsiaghi, Jason Li
33
*
44
* All rights reserved.
55
*
6-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6+
* Redistribution and use in source and binary forms, with or without modification, are permitted
7+
* provided that the following conditions are met:
78
*
8-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10-
* Neither the name of OWASP nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9+
* Redistributions of source code must retain the above copyright notice, this list of conditions
10+
* and the following disclaimer. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the documentation and/or other
12+
* materials provided with the distribution. Neither the name of OWASP nor the names of its
13+
* contributors may be used to endorse or promote products derived from this software without
14+
* specific prior written permission.
1115
*
12-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
16-
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18-
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
17+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18+
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22+
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
23+
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2324
*/
25+
2426
package org.owasp.validator.html.scan;
2527

2628
import java.io.IOException;
@@ -32,9 +34,9 @@
3234
import java.util.concurrent.ConcurrentLinkedQueue;
3335
import java.util.regex.Matcher;
3436
import java.util.regex.Pattern;
35-
import net.sourceforge.htmlunit.cyberneko.parsers.DOMFragmentParser;
36-
import net.sourceforge.htmlunit.xerces.dom.DocumentImpl;
3737
import org.apache.batik.css.parser.ParseException;
38+
import org.htmlunit.cyberneko.parsers.DOMFragmentParser;
39+
import org.htmlunit.cyberneko.xerces.dom.DocumentImpl;
3840
import org.owasp.validator.css.CssScanner;
3941
import org.owasp.validator.html.CleanResults;
4042
import org.owasp.validator.html.Policy;
@@ -224,12 +226,6 @@ static DOMFragmentParser getDomParser()
224226
parser.setFeature("http://cyberneko.org/html/features/scanner/style/strip-cdata-delims", false);
225227
parser.setFeature("http://cyberneko.org/html/features/scanner/cdata-sections", true);
226228

227-
try {
228-
parser.setFeature("http://cyberneko.org/html/features/enforce-strict-attribute-names", true);
229-
} catch (SAXNotRecognizedException se) {
230-
// this indicates that the patched nekohtml is not on the
231-
// classpath
232-
}
233229
return parser;
234230
}
235231

src/main/java/org/owasp/validator/html/scan/AntiSamySAXScanner.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2007-2022, Arshan Dabirsiaghi, Jason Li
2+
* Copyright (c) 2007-2023, Arshan Dabirsiaghi, Jason Li
33
*
44
* All rights reserved.
55
*
@@ -39,7 +39,7 @@
3939
import javax.xml.transform.TransformerFactory;
4040
import javax.xml.transform.sax.SAXResult;
4141
import javax.xml.transform.sax.SAXSource;
42-
import net.sourceforge.htmlunit.cyberneko.parsers.SAXParser;
42+
import org.htmlunit.cyberneko.parsers.SAXParser;
4343
import org.owasp.validator.html.CleanResults;
4444
import org.owasp.validator.html.Policy;
4545
import org.owasp.validator.html.ScanException;
@@ -267,8 +267,6 @@ private static SAXParser getParser() {
267267
parser.setFeature("http://xml.org/sax/features/namespaces", false);
268268
parser.setFeature("http://cyberneko.org/html/features/balance-tags/document-fragment", true);
269269
parser.setFeature("http://cyberneko.org/html/features/scanner/cdata-sections", true);
270-
parser.setFeature("http://apache.org/xml/features/scanner/notify-char-refs", true);
271-
parser.setFeature("http://apache.org/xml/features/scanner/notify-builtin-refs", true);
272270

273271
parser.setProperty("http://cyberneko.org/html/properties/names/elems", "lower");
274272
return parser;

src/main/java/org/owasp/validator/html/scan/MagicSAXFilter.java

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
/*
2-
* Copyright (c) 2007-2022, Arshan Dabirsiaghi, Jason Li
2+
* Copyright (c) 2007-2023, Arshan Dabirsiaghi, Jason Li
33
*
44
* All rights reserved.
55
*
6-
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6+
* Redistribution and use in source and binary forms, with or without modification, are permitted
7+
* provided that the following conditions are met:
78
*
8-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10-
* Neither the name of OWASP nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9+
* Redistributions of source code must retain the above copyright notice, this list of conditions
10+
* and the following disclaimer. Redistributions in binary form must reproduce the above copyright
11+
* notice, this list of conditions and the following disclaimer in the documentation and/or other
12+
* materials provided with the distribution. Neither the name of OWASP nor the names of its
13+
* contributors may be used to endorse or promote products derived from this software without
14+
* specific prior written permission.
1115
*
12-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13-
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
14-
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
15-
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
16-
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
17-
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
18-
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
19-
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
20-
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21-
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
17+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
18+
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22+
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
23+
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2324
*/
2425

2526
package org.owasp.validator.html.scan;
2627

2728
import java.util.*;
2829
import java.util.regex.Pattern;
29-
import net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter;
30-
import net.sourceforge.htmlunit.xerces.util.AugmentationsImpl;
31-
import net.sourceforge.htmlunit.xerces.util.XMLAttributesImpl;
32-
import net.sourceforge.htmlunit.xerces.util.XMLStringBuffer;
33-
import net.sourceforge.htmlunit.xerces.xni.Augmentations;
34-
import net.sourceforge.htmlunit.xerces.xni.QName;
35-
import net.sourceforge.htmlunit.xerces.xni.XMLAttributes;
36-
import net.sourceforge.htmlunit.xerces.xni.XMLString;
37-
import net.sourceforge.htmlunit.xerces.xni.XNIException;
38-
import net.sourceforge.htmlunit.xerces.xni.parser.XMLDocumentFilter;
30+
import org.htmlunit.cyberneko.filters.DefaultFilter;
31+
import org.htmlunit.cyberneko.xerces.util.XMLAttributesImpl;
32+
import org.htmlunit.cyberneko.xerces.util.XMLStringBuffer;
33+
import org.htmlunit.cyberneko.xerces.xni.Augmentations;
34+
import org.htmlunit.cyberneko.xerces.xni.QName;
35+
import org.htmlunit.cyberneko.xerces.xni.XMLAttributes;
36+
import org.htmlunit.cyberneko.xerces.xni.XMLString;
37+
import org.htmlunit.cyberneko.xerces.xni.XNIException;
38+
import org.htmlunit.cyberneko.xerces.xni.parser.XMLDocumentFilter;
3939
import org.owasp.validator.css.CssScanner;
4040
import org.owasp.validator.html.CleanResults;
4141
import org.owasp.validator.html.InternalPolicy;
@@ -191,9 +191,9 @@ public void endElement(QName element, Augmentations augs) throws XNIException {
191191
// "text/css");
192192
// start the CSS element
193193

194-
super.startElement(element, cssAttributes, new AugmentationsImpl());
194+
super.startElement(element, cssAttributes, augs);
195195
// send the cleaned content
196-
super.characters(new XMLStringBuffer(results.getCleanHTML()), new AugmentationsImpl());
196+
super.characters(new XMLStringBuffer(results.getCleanHTML()), augs);
197197
// end the CSS element
198198
super.endElement(element, augs);
199199
}

0 commit comments

Comments
 (0)