Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,19 @@ public void testWhitelistMatchingAgainstBaseURL() throws MalformedURLException {
"https://google.com/https://KNOX_GW_DOMAIN"));
}

@Test
public void testMaliciousOriginalUrl() throws Exception {
String whitelist = "^(?!.*([<>\"'`{}|\\\\^]|<script|%3cscript|javascript:|data:|alert\\(|onclick=))(^https?://.*example.com/.*)$";

// make sure it is malicious and therefore does NOT match
assertFalse(RegExUtils.checkWhitelist(whitelist, "https://example.com/path?param=%3e%3cscript%3e"));
// make sure it matches because it is not malicious
assertTrue(RegExUtils.checkWhitelist(whitelist, "https://example.com/path"));
}

@Test(expected = MalformedURLException.class)
public void testMalformedOriginalUrl() throws MalformedURLException {
RegExUtils.checkBaseUrlAgainstWhitelist(".*", "https://localhost:5003gateway/homepage/home/");
RegExUtils.checkBaseUrlAgainstWhitelist(".*", "https://localhost:5003gateway/homepage/home/");
}

private void configureCommonExpectations(Map<String, String> contextExpectations) throws Exception {
Expand Down
Loading