Skip to content

Commit

Permalink
Update codebase to ZAP 2.15
Browse files Browse the repository at this point in the history
Change all add-ons and `testutils` to use 2.15 (SNAPSHOT).
Update code accordingly (e.g. address deprecations).

Signed-off-by: thc202 <thc202@gmail.com>
  • Loading branch information
thc202 committed May 7, 2024
1 parent 7457b4b commit 6bfaef0
Show file tree
Hide file tree
Showing 163 changed files with 338 additions and 413 deletions.
3 changes: 2 additions & 1 deletion addOns/accessControl/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Changed
- Update minimum ZAP version to 2.15.0.

## [10] - 2024-03-25
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ private static void assertAlert(
assertThat(alert.getCweId(), is(equalTo(cweId)));
assertThat(alert.getWascId(), is(equalTo(wascId)));
Map<String, String> tags = alert.getTags();
assertThat(tags.size(), is(equalTo(2)));
assertThat(
tags,
allOf(
hasEntry(
"CWE-" + cweId,
"https://cwe.mitre.org/data/definitions/" + cweId + ".html"),
hasEntry(
CommonAlertTag.OWASP_2021_A01_BROKEN_AC.getTag(),
CommonAlertTag.OWASP_2021_A01_BROKEN_AC.getValue()),
Expand Down
4 changes: 2 additions & 2 deletions addOns/addOns.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ subprojects {
}
}

val zapGav = "org.zaproxy:zap:2.14.0"
val zapGav = "org.zaproxy:zap:2.15.0-SNAPSHOT"
dependencies {
"zap"(zapGav)
}
Expand All @@ -159,7 +159,7 @@ subprojects {
releaseLink.set(project.provider { "https://github.com/zaproxy/zap-extensions/releases/${zapAddOn.addOnId.get()}-v@CURRENT_VERSION@" })

manifest {
zapVersion.set("2.14.0")
zapVersion.set("2.15.0")

changesFile.set(tasks.named<ConvertMarkdownToHtml>("generateManifestChanges").flatMap { it.html })
repo.set("https://github.com/zaproxy/zap-extensions/")
Expand Down
3 changes: 2 additions & 1 deletion addOns/alertFilters/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Changed
- Update minimum ZAP version to 2.15.0.

## [20] - 2024-04-02
### Added
Expand Down
2 changes: 1 addition & 1 deletion addOns/allinonenotes/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased
### Changed
- Update minimum ZAP version to 2.14.0.
- Update minimum ZAP version to 2.15.0.
- Maintenance changes.

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion addOns/ascanrules/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Changed
- Update minimum ZAP version to 2.15.0.

## [65] - 2024-03-28
### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@
import org.parosproxy.paros.core.scanner.Alert;
import org.parosproxy.paros.core.scanner.Category;
import org.parosproxy.paros.network.HttpMessage;
import org.parosproxy.paros.network.HttpStatusCode;
import org.zaproxy.addon.commonlib.CommonAlertTag;
import org.zaproxy.zap.extension.custompages.CustomPage;
import org.zaproxy.zap.model.Context;

/**
* Attempts to retrieve cloud metadata by forging the host header and requesting a specific URL. See
Expand Down Expand Up @@ -104,22 +101,6 @@ public AlertBuilder createAlert(HttpMessage newRequest, String host) {
.setMessage(newRequest);
}

/** FIXME Remove this call after 2.15.0 to call the fixed version in the parent. */
@Override
public boolean isSuccess(HttpMessage msg) {
Context context = getParent().getContext();
if (context != null) {
if (context.isCustomPage(msg, CustomPage.Type.NOTFOUND_404)
|| context.isCustomPage(msg, CustomPage.Type.ERROR_500)) {
return false;
}
if (context.isCustomPage(msg, CustomPage.Type.OK_200)) {
return true;
}
}
return HttpStatusCode.isSuccess(msg.getResponseHeader().getStatusCode());
}

@Override
public void scan() {
HttpMessage newRequest = getNewMsg();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import org.parosproxy.paros.network.HttpStatusCode;
import org.zaproxy.addon.commonlib.CommonAlertTag;
import org.zaproxy.addon.commonlib.http.HttpFieldsNames;
import org.zaproxy.zap.extension.custompages.CustomPage;
import org.zaproxy.zap.model.Context;

/**
* Active scan rule which checks whether various URL paths are exposed.
Expand Down Expand Up @@ -143,22 +141,6 @@ && doesMatch(responseBody, file.getContent())
}
}

/** FIXME Remove this call after 2.15.0 to call the fixed version in the parent. */
@Override
protected boolean isPage200(HttpMessage msg) {
Context context = getParent().getContext();
if (context != null) {
if (context.isCustomPage(msg, CustomPage.Type.NOTFOUND_404)
|| context.isCustomPage(msg, CustomPage.Type.ERROR_500)) {
return false;
}
if (context.isCustomPage(msg, CustomPage.Type.OK_200)) {
return true;
}
}
return HttpStatusCode.isSuccess(msg.getResponseHeader().getStatusCode());
}

private static String generatePath(String baseUriPath, String hiddenFile) {
String newPath = "";
if (baseUriPath == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ void shouldReturnExpectedExampleAlert() {
assertThat(alerts.size(), is(equalTo(1)));
Alert alert = alerts.get(0);
Map<String, String> tags = alert.getTags();
assertThat(tags.size(), is(equalTo(2)));
assertThat(tags.size(), is(equalTo(3)));
assertThat(tags, hasKey("CWE-548"));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2021_A01_BROKEN_AC.getTag()));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2017_A05_BROKEN_AC.getTag()));
assertThat(alert.getRisk(), is(equalTo(Alert.RISK_MEDIUM)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ void shouldReturnExpectedExampleAlert() {
assertThat(alerts.size(), is(equalTo(1)));
Alert alert = alerts.get(0);
Map<String, String> tags = alert.getTags();
assertThat(tags.size(), is(equalTo(2)));
assertThat(tags.size(), is(equalTo(3)));
assertThat(tags, hasKey("CWE-134"));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2017_A01_INJECTION.getTag()));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2021_A03_INJECTION.getTag()));
assertThat(alert.getRisk(), is(equalTo(Alert.RISK_MEDIUM)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,8 @@ void shouldReturnExpectedExampleAlert() {
Map<String, String> tags = alert.getTags();
// Then
assertThat(alerts.size(), is(equalTo(1)));
assertThat(tags.size(), is(equalTo(4)));
assertThat(tags.size(), is(equalTo(5)));
assertThat(tags, hasKey("CWE-538"));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2021_A05_SEC_MISCONFIG.getTag()));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2017_A06_SEC_MISCONFIG.getTag()));
assertThat(tags, hasKey(CommonAlertTag.WSTG_V42_CONF_05_ENUMERATE_INFRASTRUCTURE.getTag()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static fi.iki.elonen.NanoHTTPD.newFixedLengthResponse;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -133,12 +134,14 @@ void shouldReturnExpectedExampleAlerts() {
// Then
assertThat(alerts.size(), is(equalTo(2)));
assertThat(alert1.getAlertRef(), is(equalTo("40043-1")));
assertThat(alert1.getTags().size(), is(equalTo(5)));
assertThat(alert1.getTags().size(), is(equalTo(6)));
assertThat(alert1.getTags(), hasKey("CWE-117"));
assertThat(alert1.getTags().containsKey("CVE-2021-44228"), is(equalTo(true)));
assertThat(alert1.getName(), is(equalTo("Log4Shell (CVE-2021-44228)")));
assertThat(alert2.getAlertRef(), is(equalTo("40043-2")));
assertThat(alert2.getTags().containsKey("CVE-2021-45046"), is(equalTo(true)));
assertThat(alert2.getTags().size(), is(equalTo(5)));
assertThat(alert2.getTags().size(), is(equalTo(6)));
assertThat(alert2.getTags(), hasKey("CWE-117"));
assertThat(alert2.getName(), is(equalTo("Log4Shell (CVE-2021-45046)")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;

Expand Down Expand Up @@ -259,8 +260,9 @@ void shouldReturnExpectedExampleAlert() {

Alert alert = alerts.get(0);
Map<String, String> tags1 = alert.getTags();
assertThat(tags1.size(), is(equalTo(2)));
assertThat(tags1.size(), is(equalTo(3)));
assertThat(alert.getConfidence(), is(equalTo(Alert.CONFIDENCE_MEDIUM)));
assertThat(tags1, hasKey("CWE-472"));
assertThat(
tags1.containsKey(CommonAlertTag.OWASP_2017_A01_INJECTION.getTag()),
is(equalTo(true)));
Expand Down
3 changes: 2 additions & 1 deletion addOns/ascanrulesAlpha/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Changed
- Update minimum ZAP version to 2.15.0.

## [47] - 2024-03-28
### Changed
Expand Down
1 change: 1 addition & 0 deletions addOns/ascanrulesBeta/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased
### Changed
- Update minimum ZAP version to 2.15.0.
- Maintenance changes.

## [53] - 2024-03-28
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ void shouldReturnExpectedExampleAlert() {
Alert alert = alerts.get(0);

Map<String, String> tags = alert.getTags();
assertThat(tags.size(), is(equalTo(3)));
assertThat(tags.size(), is(equalTo(4)));
assertThat(tags, hasKey("CWE-311"));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2017_A06_SEC_MISCONFIG.getTag()));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2021_A05_SEC_MISCONFIG.getTag()));
assertThat(tags, hasKey(CommonAlertTag.WSTG_V42_SESS_02_COOKIE_ATTRS.getTag()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ void shouldReturnExpectedExampleAlert() {
Alert alert = alerts.get(0);

Map<String, String> tags = alert.getTags();
assertThat(tags.size(), is(equalTo(2)));
assertThat(tags.size(), is(equalTo(3)));
assertThat(tags, hasKey("CWE-541"));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2017_A06_SEC_MISCONFIG.getTag()));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2021_A05_SEC_MISCONFIG.getTag()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ void shouldReturnExpectedExampleAlert() {
assertThat(alerts.size(), is(equalTo(1)));
Alert alert = alerts.get(0);
Map<String, String> tags = alert.getTags();
assertThat(tags.size(), is(equalTo(2)));
assertThat(tags.size(), is(equalTo(3)));
assertThat(tags, hasKey("CWE-541"));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2017_A06_SEC_MISCONFIG.getTag()));
assertThat(tags, hasKey(CommonAlertTag.OWASP_2021_A05_SEC_MISCONFIG.getTag()));
assertThat(alert.getRisk(), is(equalTo(Alert.RISK_HIGH)));
Expand Down
1 change: 1 addition & 0 deletions addOns/authhelper/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased
### Changed
- Update minimum ZAP version to 2.15.0.
- Maintenance changes.

## [0.12.0] - 2024-02-06
Expand Down
2 changes: 1 addition & 1 deletion addOns/authstats/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased
### Changed
- Update minimum ZAP version to 2.14.0.
- Update minimum ZAP version to 2.15.0.
- Maintenance changes.

## [2] - 2021-10-07
Expand Down
3 changes: 2 additions & 1 deletion addOns/automation/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ All notable changes to this add-on will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Changed
- Update minimum ZAP version to 2.15.0.

## [0.39.0] - 2024-04-23
### Added
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Zed Attack Proxy (ZAP) and its related class files.
*
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
*
* Copyright 2024 The ZAP Development Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.parosproxy.paros.core.scanner;

public final class PluginFactoryTestHelper extends PluginFactory {

private PluginFactoryTestHelper() {}

public static void init() {
PluginFactory.init(false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Zed Attack Proxy (ZAP) and its related class files.
*
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
*
* Copyright 2024 The ZAP Development Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.parosproxy.paros.core.scanner;

public class PluginTestHelper extends AbstractPlugin {

@Override
public int getId() {
return 50000;
}

@Override
public String getName() {
return "PluginTestHelper";
}

@Override
public String getDescription() {
return "";
}

@Override
public void scan() {}

@Override
public int getCategory() {
return 0;
}

@Override
public String getSolution() {
return "";
}

@Override
public String getReference() {
return "";
}

@Override
public void notifyPluginCompleted(HostProcess parent) {}
}
Loading

0 comments on commit 6bfaef0

Please sign in to comment.