Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EHgXqsEW] Upgraded jsoup to v.1.15.3 to mitigate CVE-2022-36033 (#3305) (#3460) #3461

Merged
merged 1 commit into from
Feb 21, 2023
Merged
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
2 changes: 1 addition & 1 deletion extended/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ dependencies {
// These will be dependencies packaged with the .jar
implementation project(':common')
implementation group: 'com.novell.ldap', name: 'jldap', version: '2009-10-07'
implementation group: 'org.jsoup', name: 'jsoup', version: '1.14.3'
implementation group: 'org.jsoup', name: 'jsoup', version: '1.15.3'
implementation group: 'com.opencsv', name: 'opencsv', version: '5.7.1'
implementation group: 'com.github.javafaker', name: 'javafaker', version: '1.0.2'
implementation group: 'us.fatehi', name: 'schemacrawler', version: '15.04.01'
Expand Down
10 changes: 6 additions & 4 deletions extended/src/main/java/apoc/load/LoadHtml.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import apoc.result.MapResult;
import apoc.util.MissingDependencyException;
import apoc.util.FileUtils;
import java.nio.charset.UnsupportedCharsetException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Attribute;
import org.jsoup.nodes.Document;
Expand All @@ -19,7 +20,6 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -35,6 +35,8 @@ public class LoadHtml {

// public for test purpose
public static final String KEY_ERROR = "errorList";
public static final String INVALID_CONFIG_ERR = "Invalid config: ";
public static final String UNSUPPORTED_CHARSET_ERR = "Unsupported charset: ";

@Context
public GraphDatabaseService db;
Expand Down Expand Up @@ -74,12 +76,12 @@ private Stream<MapResult> readHtmlPage(String url, Map<String, String> query, Ma
}

return Stream.of(new MapResult(output));
} catch ( UnsupportedCharsetException e) {
throw new RuntimeException(UNSUPPORTED_CHARSET_ERR + config.getCharset());
} catch (IllegalArgumentException | ClassCastException e) {
throw new RuntimeException("Invalid config: " + config);
throw new RuntimeException(INVALID_CONFIG_ERR + config);
} catch (FileNotFoundException e) {
throw new RuntimeException("File not found from: " + url);
} catch(UnsupportedEncodingException e) {
throw new RuntimeException("Unsupported charset: " + config.getCharset());
} catch(Exception e) {
throw new RuntimeException("Can't read the HTML from: "+ url, e);
}
Expand Down
9 changes: 5 additions & 4 deletions extended/src/test/java/apoc/load/LoadHtmlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@

import static apoc.ApocConfig.APOC_IMPORT_FILE_ENABLED;
import static apoc.ApocConfig.apocConfig;
import static apoc.load.LoadHtml.INVALID_CONFIG_ERR;
import static apoc.load.LoadHtml.KEY_ERROR;
import static apoc.load.LoadHtml.UNSUPPORTED_CHARSET_ERR;
import static apoc.load.LoadHtmlConfig.FailSilently.WITH_LIST;
import static apoc.load.LoadHtmlConfig.FailSilently.WITH_LOG;
import static apoc.util.MapUtil.map;
Expand Down Expand Up @@ -64,7 +66,6 @@ public class LoadHtmlTest {
"<p class='thirdClass'>My third paragraph. Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p> " +
"<ul><li>Coffee</li><li>Tea</li><li>Milk</li></ul> " +
"</body> </html>";
private static final String INVALID_CONFIG_ERR = "Invalid config";

@Rule
public DbmsRule db = new ImpermanentDbmsRule();
Expand Down Expand Up @@ -435,19 +436,19 @@ public void testQueryWithFailsSilentlyWithListWithExceptionIfIncorrectUrl() {

@Test
public void testQueryWithExceptionIfIncorrectCharset() {
assertWrongConfig(INVALID_CONFIG_ERR,
assertWrongConfig(UNSUPPORTED_CHARSET_ERR,
Map.of("charset", INVALID_CHARSET));
}

@Test
public void testQueryWithFailsSilentlyWithLogWithExceptionIfIncorrectCharset() {
assertWrongConfig(INVALID_CONFIG_ERR,
assertWrongConfig(UNSUPPORTED_CHARSET_ERR,
Map.of("failSilently", WITH_LOG.name(), "charset", INVALID_CHARSET));
}

@Test
public void testQueryWithFailsSilentlyWithListWithExceptionIfIncorrectCharset() {
assertWrongConfig(INVALID_CONFIG_ERR,
assertWrongConfig(UNSUPPORTED_CHARSET_ERR,
Map.of("failSilently", WITH_LIST.name(), "charset", INVALID_CHARSET));
}

Expand Down