Skip to content

Commit 7a57497

Browse files
authored
Merge pull request #7079 from psiinon/selenium/custom_browsers
2 parents 8b14cca + b98f58e commit 7a57497

19 files changed

Lines changed: 2883 additions & 893 deletions

File tree

addOns/domxss/src/test/java/org/zaproxy/zap/extension/domxss/DomXssScanRuleUnitTest.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,19 @@
3333
import io.github.bonigarcia.wdm.WebDriverManager;
3434
import java.io.IOException;
3535
import java.util.List;
36-
import java.util.Locale;
3736
import java.util.Map;
3837
import java.util.concurrent.atomic.AtomicBoolean;
3938
import java.util.stream.Stream;
4039
import org.hamcrest.Matchers;
4140
import org.junit.jupiter.api.AfterAll;
4241
import org.junit.jupiter.api.AfterEach;
4342
import org.junit.jupiter.api.BeforeAll;
44-
import org.junit.jupiter.api.BeforeEach;
4543
import org.junit.jupiter.api.Disabled;
4644
import org.junit.jupiter.api.Test;
4745
import org.junit.jupiter.params.ParameterizedTest;
4846
import org.junit.jupiter.params.provider.MethodSource;
4947
import org.mockito.ArgumentMatchers;
5048
import org.mockito.quality.Strictness;
51-
import org.parosproxy.paros.Constant;
5249
import org.parosproxy.paros.control.Control;
5350
import org.parosproxy.paros.core.scanner.Alert;
5451
import org.parosproxy.paros.core.scanner.Plugin.AttackStrength;
@@ -63,11 +60,11 @@
6360
import org.zaproxy.addon.network.ExtensionNetwork;
6461
import org.zaproxy.zap.extension.ascan.VariantFactory;
6562
import org.zaproxy.zap.extension.selenium.Browser;
63+
import org.zaproxy.zap.extension.selenium.ExtensionSelenium;
6664
import org.zaproxy.zap.extension.selenium.SeleniumOptions;
6765
import org.zaproxy.zap.model.Context;
6866
import org.zaproxy.zap.testutils.ActiveScannerTestUtils;
6967
import org.zaproxy.zap.testutils.NanoServerHandler;
70-
import org.zaproxy.zap.utils.I18N;
7168
import org.zaproxy.zap.utils.ZapXmlConfiguration;
7269

7370
class DomXssScanRuleUnitTest extends ActiveScannerTestUtils<DomXssScanRule> {
@@ -79,30 +76,10 @@ class DomXssScanRuleUnitTest extends ActiveScannerTestUtils<DomXssScanRule> {
7976

8077
@BeforeAll
8178
static void setupAll() {
82-
Constant.messages = new I18N(Locale.ROOT);
8379
WebDriverManager.firefoxdriver().setup();
8480
WebDriverManager.chromedriver().setup();
8581
}
8682

87-
@BeforeEach
88-
void setupEach() {
89-
model = mock(Model.class, withSettings().strictness(Strictness.LENIENT));
90-
Model.setSingletonForTesting(model);
91-
given(model.getVariantFactory()).willReturn(new VariantFactory());
92-
given(model.getOptionsParam()).willReturn(new OptionsParam());
93-
extensionNetwork = new ExtensionNetwork();
94-
extensionNetwork.initModel(model);
95-
Control.initSingletonForTesting(model, mock(ExtensionLoader.class));
96-
extensionNetwork.init();
97-
extensionNetwork.hook(new ExtensionHook(model, null));
98-
99-
model.getOptionsParam().load(new ZapXmlConfiguration());
100-
model.getOptionsParam().addParamSet(new SeleniumOptions());
101-
102-
session = new Session(model);
103-
given(model.getSession()).willReturn(session);
104-
}
105-
10683
@AfterEach
10784
void tearDown() {
10885
rule.setTimeFinished();
@@ -122,6 +99,32 @@ static void tidyUp() {
12299

123100
@Override
124101
protected DomXssScanRule createScanner() {
102+
// Setup here so that the commonScanRuleTests get initialised correctly as well
103+
104+
mockMessages(new ExtensionDomXSS(), new ExtensionSelenium());
105+
model = mock(Model.class, withSettings().strictness(Strictness.LENIENT));
106+
Model.setSingletonForTesting(model);
107+
given(model.getVariantFactory()).willReturn(new VariantFactory());
108+
given(model.getOptionsParam()).willReturn(new OptionsParam());
109+
extensionNetwork = new ExtensionNetwork();
110+
extensionNetwork.initModel(model);
111+
ExtensionLoader extensionLoader =
112+
mock(ExtensionLoader.class, withSettings().strictness(Strictness.LENIENT));
113+
Control.initSingletonForTesting(model, extensionLoader);
114+
115+
ExtensionSelenium extensionSelenium = new ExtensionSelenium();
116+
given(extensionLoader.getExtension(ExtensionSelenium.class)).willReturn(extensionSelenium);
117+
extensionSelenium.init();
118+
119+
extensionNetwork.init();
120+
extensionNetwork.hook(new ExtensionHook(model, null));
121+
122+
model.getOptionsParam().load(new ZapXmlConfiguration());
123+
model.getOptionsParam().addParamSet(new SeleniumOptions());
124+
125+
session = new Session(model);
126+
given(model.getSession()).willReturn(session);
127+
125128
DomXssScanRule.extensionNetwork = extensionNetwork;
126129
return new DomXssScanRule();
127130
}

addOns/selenium/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## Unreleased
88
### Changed
99
- Update Selenium to version 4.40.0.
10+
### Removed
11+
- Support for IE and disabled Safari.
1012

1113
## [15.43.0] - 2025-12-15
1214
### Changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Zed Attack Proxy (ZAP) and its related class files.
3+
*
4+
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
5+
*
6+
* Copyright 2026 The ZAP Development Team
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package org.zaproxy.zap.extension.selenium;
21+
22+
import java.util.List;
23+
import lombok.Builder;
24+
import lombok.Getter;
25+
26+
@Getter
27+
@Builder
28+
/**
29+
* A browser added by a user or another ZAP add-on.
30+
*
31+
* @since 15.44.0
32+
*/
33+
public class CustomBrowser {
34+
35+
private final String name;
36+
private final String driverPath;
37+
private final String binaryPath;
38+
private final List<String> arguments;
39+
private final String browserType;
40+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Zed Attack Proxy (ZAP) and its related class files.
3+
*
4+
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
5+
*
6+
* Copyright 2026 The ZAP Development Team
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License");
9+
* you may not use this file except in compliance with the License.
10+
* You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing, software
15+
* distributed under the License is distributed on an "AS IS" BASIS,
16+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17+
* See the License for the specific language governing permissions and
18+
* limitations under the License.
19+
*/
20+
package org.zaproxy.zap.extension.selenium;
21+
22+
import java.util.Collections;
23+
import java.util.List;
24+
import java.util.function.Consumer;
25+
import lombok.Builder;
26+
import lombok.Getter;
27+
import org.openqa.selenium.MutableCapabilities;
28+
29+
/**
30+
* Configuration for obtaining a WebDriver.
31+
*
32+
* <p>Allows specifying requester, proxy, browser extensions, and optional capability customisation.
33+
*/
34+
@Builder
35+
@Getter
36+
public class DriverConfiguration {
37+
38+
/** Underlying browser/driver type for driver creation. */
39+
public enum DriverType {
40+
CHROMIUM,
41+
EDGE,
42+
FIREFOX,
43+
HTML_UNIT,
44+
SAFARI
45+
}
46+
47+
private final int requester;
48+
private final String proxyAddress;
49+
private final int proxyPort;
50+
private final boolean enableExtensions;
51+
private final Consumer<MutableCapabilities> consumer;
52+
private final DriverType type;
53+
@Builder.Default private final boolean headless = false;
54+
@Builder.Default private final String binaryPath = null;
55+
@Builder.Default private final String driverPath = "";
56+
@Builder.Default private final List<String> arguments = Collections.emptyList();
57+
}

0 commit comments

Comments
 (0)