Skip to content

Commit 5eec807

Browse files
committed
Update codebase to ZAP 2.17
Change all add-ons and `testutils` to use 2.17 (SNAPSHOT). Update code accordingly (e.g. address deprecations). Signed-off-by: thc202 <[email protected]>
1 parent 34f1060 commit 5eec807

File tree

30 files changed

+134
-474
lines changed

30 files changed

+134
-474
lines changed

addOns/addOns.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ subprojects {
174174
}
175175
}
176176

177-
val zapGav = "org.zaproxy:zap:2.16.0"
177+
val zapGav = "org.zaproxy:zap:2.17.0-SNAPSHOT"
178178
dependencies {
179179
"zap"(zapGav)
180180
}
@@ -187,7 +187,7 @@ subprojects {
187187
)
188188

189189
manifest {
190-
zapVersion.set("2.16.0")
190+
zapVersion.set("2.17.0")
191191

192192
changesFile.set(tasks.named<ConvertMarkdownToHtml>("generateManifestChanges").flatMap { it.html })
193193
repo.set("https://github.com/zaproxy/zap-extensions/")

addOns/alertFilters/src/main/java/org/zaproxy/zap/extension/alertFilters/ExtensionAlertFilters.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ private void updateAlert(Alert alert, AlertFilter filter) {
452452
alert.getPluginId(),
453453
filter.getNewRisk());
454454
getExtAlert().updateAlert(updAlert);
455-
getExtAlert().updateAlertInTree(origAlert, updAlert);
455+
getExtAlert().updateAlertInTree(updAlert);
456456
if (alert.getHistoryRef() != null) {
457457
alert.getHistoryRef().updateAlert(updAlert);
458458
if (alert.getHistoryRef().getSiteNode() != null) {
@@ -472,10 +472,7 @@ private Alert getAlert(RecordAlert recordAlert) {
472472
int historyId = recordAlert.getHistoryId();
473473
if (historyId > 0) {
474474
HistoryReference href = this.getExtHistory().getHistoryReference(historyId);
475-
Alert alert = new Alert(recordAlert, href);
476-
// TODO remove once targeting 2.17+
477-
alert.setHistoryId(recordAlert.getHistoryId());
478-
return alert;
475+
return new Alert(recordAlert, href);
479476
} else {
480477
// Not ideal :/
481478
return new Alert(recordAlert);

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/CrossSiteScriptingScanRule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import java.util.List;
3030
import java.util.Map;
3131
import org.apache.commons.httpclient.URIException;
32-
import org.apache.commons.lang3.StringUtils;
32+
import org.apache.commons.lang3.Strings;
3333
import org.apache.logging.log4j.LogManager;
3434
import org.apache.logging.log4j.Logger;
3535
import org.parosproxy.paros.Constant;
@@ -748,7 +748,7 @@ private boolean processContexts(
748748
.raise();
749749
} else if (AlertThreshold.LOW.equals(this.getAlertThreshold())) {
750750
HttpMessage ctx2Message = contexts.get(0).getMsg();
751-
if (StringUtils.containsIgnoreCase(
751+
if (Strings.CI.contains(
752752
ctx.getMsg()
753753
.getResponseHeader()
754754
.getHeader(HttpFieldsNames.CONTENT_TYPE),

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/ExternalRedirectScanRule.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import net.htmlparser.jericho.Source;
3636
import org.apache.commons.httpclient.URI;
3737
import org.apache.commons.httpclient.URIException;
38-
import org.apache.commons.lang3.StringUtils;
38+
import org.apache.commons.lang3.Strings;
3939
import org.apache.logging.log4j.LogManager;
4040
import org.apache.logging.log4j.Logger;
4141
import org.mozilla.javascript.CompilerEnvirons;
@@ -357,7 +357,7 @@ static String getLocationUrl(String value) {
357357
* @return true if it's a valid open redirect
358358
*/
359359
private static boolean checkPayload(String value) {
360-
if (value == null || !StringUtils.startsWithIgnoreCase(value, HttpHeader.HTTP)) {
360+
if (value == null || !Strings.CI.startsWith(value, HttpHeader.HTTP)) {
361361
return false;
362362
}
363363

@@ -460,7 +460,7 @@ private static RedirectType isRedirected(String payload, HttpMessage msg) {
460460

461461
// (5) Check if redirection occurs by Javascript
462462
// http://code.google.com/p/html5security/wiki/RedirectionMethods
463-
if (StringUtils.indexOfIgnoreCase(content, payload) != -1) {
463+
if (Strings.CI.indexOf(content, payload) != -1) {
464464
List<Element> jsElements = htmlSrc.getAllElements(HTMLElementName.SCRIPT);
465465

466466
for (Element el : jsElements) {
@@ -498,8 +498,7 @@ private static boolean isRedirectPresent(Pattern pattern, String value) {
498498
}
499499

500500
private static boolean isPresent(Matcher matcher) {
501-
return matcher.find()
502-
&& StringUtils.startsWithIgnoreCase(matcher.group(1), HttpHeader.HTTP);
501+
return matcher.find() && Strings.CI.startsWith(matcher.group(1), HttpHeader.HTTP);
503502
}
504503

505504
/** Visibility increased for unit testing purposes only */

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/PaddingOracleScanRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ public byte[] decode(String value) {
345345
// The last letter represents the length
346346
int last = value.length() - 1;
347347
if (((last + (int) value.charAt(last)) % 4) == 0) {
348-
Base64 decoder = new Base64(true);
348+
Base64 decoder = Base64.builder().setUrlSafe(true).get();
349349
return decoder.decode(value.substring(0, last));
350350
}
351351
}

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/PersistentXssScanRule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import java.util.List;
2727
import java.util.Map;
2828
import java.util.Set;
29-
import org.apache.commons.lang3.StringUtils;
29+
import org.apache.commons.lang3.Strings;
3030
import org.apache.logging.log4j.LogManager;
3131
import org.apache.logging.log4j.Logger;
3232
import org.parosproxy.paros.Constant;
@@ -640,7 +640,7 @@ public void scan(HttpMessage sourceMsg, String param, String value) {
640640
.raise();
641641
} else {
642642
HttpMessage ctx2Message = contexts2.get(0).getMsg();
643-
if (StringUtils.containsIgnoreCase(
643+
if (Strings.CI.contains(
644644
ctx.getMsg()
645645
.getResponseHeader()
646646
.getHeader(

addOns/ascanrules/src/test/java/org/zaproxy/zap/extension/ascanrules/CrossSiteScriptingScanRuleUnitTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import java.util.Map;
3939
import java.util.TreeSet;
4040
import org.apache.commons.lang3.StringUtils;
41+
import org.apache.commons.lang3.Strings;
4142
import org.apache.commons.text.StringEscapeUtils;
4243
import org.junit.jupiter.api.Test;
4344
import org.junit.jupiter.params.ParameterizedTest;
@@ -2517,7 +2518,7 @@ void shouldNotReportXssOutsideTagsIfNoParentTag() throws Exception {
25172518
@Override
25182519
protected Response serve(IHTTPSession session) {
25192520
String name = getFirstParamValue(session, "name");
2520-
if (!StringUtils.containsIgnoreCase(name, "0W45pz4p")
2521+
if (!Strings.CI.contains(name, "0W45pz4p")
25212522
&& !name.equals("%3CscrIpt%3Ealert%281%29%3B%3C%2FscRipt%3E")) {
25222523
name = "something else";
25232524
}

addOns/authhelper/src/main/java/org/zaproxy/addon/authhelper/AuthHeaderTracker.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import java.util.Locale;
2525
import java.util.Map;
2626
import org.apache.commons.httpclient.URIException;
27-
import org.apache.commons.lang3.StringUtils;
27+
import org.apache.commons.lang3.Strings;
2828
import org.apache.logging.log4j.LogManager;
2929
import org.apache.logging.log4j.Logger;
3030
import org.parosproxy.paros.network.HttpMessage;
@@ -64,11 +64,11 @@ private boolean isAuthInitiator(int initiator) {
6464
}
6565

6666
private static boolean isTrackedHeader(String header) {
67-
return StringUtils.containsIgnoreCase(header, "auth")
68-
|| StringUtils.containsIgnoreCase(header, "csrf")
67+
return Strings.CI.contains(header, "auth")
68+
|| Strings.CI.contains(header, "csrf")
6969
|| (!"sec-websocket-key".equalsIgnoreCase(header)
70-
&& StringUtils.containsIgnoreCase(header, "key"))
71-
|| StringUtils.startsWithIgnoreCase(header, "x-gwt-");
70+
&& Strings.CI.contains(header, "key"))
71+
|| Strings.CI.contains(header, "x-gwt-");
7272
}
7373

7474
@Override

addOns/authhelper/src/main/java/org/zaproxy/addon/authhelper/AuthTestDialog.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
*/
2020
package org.zaproxy.addon.authhelper;
2121

22-
import java.awt.Component;
2322
import java.awt.Frame;
24-
import java.awt.GridBagConstraints;
2523
import java.awt.GridBagLayout;
2624
import java.awt.Insets;
2725
import java.awt.Toolkit;
@@ -337,21 +335,6 @@ private void setScriptNames() {
337335
}
338336
}
339337

340-
// FIXME use parent method once ZAP 2.17 is released
341-
private static JPanel getSideBySidePanel(Component c1, Component c2) {
342-
JPanel panel = new JPanel();
343-
panel.setLayout(new GridBagLayout());
344-
panel.add(
345-
c1,
346-
LayoutHelper.getGBC(
347-
0, 0, 1, 1.0D, 0.0D, GridBagConstraints.BOTH, new Insets(0, 0, 0, 2)));
348-
panel.add(
349-
c2,
350-
LayoutHelper.getGBC(
351-
1, 0, 1, 0.0D, 0.0D, GridBagConstraints.BOTH, new Insets(0, 2, 0, 0)));
352-
return panel;
353-
}
354-
355338
private void setMethodState() {
356339
boolean isBrowserAuth = isBrowserAuth();
357340

addOns/authhelper/src/main/java/org/zaproxy/addon/authhelper/AuthUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import org.apache.commons.httpclient.URI;
5353
import org.apache.commons.httpclient.URIException;
5454
import org.apache.commons.lang3.StringUtils;
55+
import org.apache.commons.lang3.Strings;
5556
import org.apache.logging.log4j.Level;
5657
import org.apache.logging.log4j.LogManager;
5758
import org.apache.logging.log4j.Logger;
@@ -404,8 +405,8 @@ public static WebElement getPasswordField(List<WebElement> inputElements) {
404405
}
405406

406407
private static boolean hasPasswordAttributes(WebElement element) {
407-
return StringUtils.containsIgnoreCase(getAttribute(element, "id"), PASSWORD)
408-
|| StringUtils.containsIgnoreCase(getAttribute(element, "name"), PASSWORD);
408+
return Strings.CI.contains(getAttribute(element, "id"), PASSWORD)
409+
|| Strings.CI.contains(getAttribute(element, "name"), PASSWORD);
409410
}
410411

411412
/**

0 commit comments

Comments
 (0)