-
-
Notifications
You must be signed in to change notification settings - Fork 704
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ascanrulesAlpha: Add example alerts to example rules
- CHANGELOG > Added change note. - Scan Rules > Added example alert handling, updated to conform to the common active scan rule tests. - Scan Rule Unit Tests > Added to assert the example alert and references, as well as common tests. Signed-off-by: kingthorin <kingthorin@users.noreply.github.com>
- Loading branch information
1 parent
89d9023
commit 595a0cd
Showing
7 changed files
with
145 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...est/java/org/zaproxy/zap/extension/ascanrulesAlpha/ExampleFileActiveScanRuleUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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.zaproxy.zap.extension.ascanrulesAlpha; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.endsWith; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.parosproxy.paros.core.scanner.Alert; | ||
|
||
class ExampleFileActiveScanRuleUnitTest | ||
extends ActiveScannerTest<ExampleFileActiveScanRule> { | ||
|
||
@Override | ||
protected ExampleFileActiveScanRule createScanner() { | ||
return new ExampleFileActiveScanRule(); | ||
} | ||
|
||
@Test | ||
void shouldHaveExpectedExample() { | ||
// Given / When | ||
List<Alert> alerts = rule.getExampleAlerts(); | ||
// Then | ||
assertThat(alerts, hasSize(1)); | ||
Alert alert = alerts.get(0); | ||
assertThat(alert.getParam(), is(equalTo("foo"))); | ||
} | ||
|
||
@Test | ||
@Override | ||
public void shouldHaveValidReferences() { | ||
super.shouldHaveValidReferences(); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...t/java/org/zaproxy/zap/extension/ascanrulesAlpha/ExampleSimpleActiveScanRuleUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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.zaproxy.zap.extension.ascanrulesAlpha; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.endsWith; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.hasSize; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
import java.util.List; | ||
import org.junit.jupiter.api.Test; | ||
import org.parosproxy.paros.core.scanner.Alert; | ||
|
||
class ExampleSimpleActiveScanRuleUnitTest | ||
extends ActiveScannerTest<ExampleSimpleActiveScanRule> { | ||
|
||
@Override | ||
protected ExampleSimpleActiveScanRule createScanner() { | ||
return new ExampleSimpleActiveScanRule(); | ||
} | ||
|
||
@Test | ||
void shouldHaveExpectedExample() { | ||
// Given / When | ||
List<Alert> alerts = rule.getExampleAlerts(); | ||
// Then | ||
assertThat(alerts, hasSize(1)); | ||
Alert alert = alerts.get(0); | ||
assertThat(alert.getParam(), is(equalTo("foo"))); | ||
} | ||
|
||
@Test | ||
@Override | ||
public void shouldHaveValidReferences() { | ||
super.shouldHaveValidReferences(); | ||
} | ||
} |