Skip to content

Commit 435440c

Browse files
committed
ascanrulesAlpha: Add Swagger Secret Detector Script
Originally contributed in zaproxy/community-scripts#487. Signed-off-by: ricekot <[email protected]>
1 parent 7eed1ff commit 435440c

File tree

6 files changed

+678
-0
lines changed

6 files changed

+678
-0
lines changed

addOns/ascanrulesAlpha/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
## Unreleased
77
### Added
88
- SYSTEMIC tag to selected rules.
9+
- Swagger Secret Detector Script Scan Rule.
910

1011
### Changed
1112
- The Web Cache Deception scan rule now includes example alert functionality for documentation generation purposes (Issue 6119).

addOns/ascanrulesAlpha/src/main/java/org/zaproxy/zap/extension/ascanrulesAlpha/scripts/ExtensionAscanRulesAlphaScripts.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class ExtensionAscanRulesAlphaScripts extends ExtensionAdaptor {
4141
LogManager.getLogger(ExtensionAscanRulesAlphaScripts.class);
4242
private static final String SCRIPT_SUSPICIOUS_INPUT_TRANSFORMATION =
4343
"SuspiciousInputTransformation.js";
44+
private static final String SCRIPT_SWAGGER_SECRET_DETECTOR = "SwaggerSecretDetector.js";
4445

4546
private ExtensionScript extScript;
4647

@@ -90,6 +91,11 @@ private void addScripts() {
9091
"ascanalpha.scripts.suspiciousInputTransformation.desc"),
9192
extScript.getScriptType(ExtensionActiveScan.SCRIPT_TYPE_ACTIVE),
9293
false);
94+
addScript(
95+
SCRIPT_SWAGGER_SECRET_DETECTOR,
96+
Constant.messages.getString("ascanalpha.scripts.swaggerSecretDetector.desc"),
97+
extScript.getScriptType(ExtensionActiveScan.SCRIPT_TYPE_ACTIVE),
98+
false);
9399
}
94100

95101
private void addScript(String name, String description, ScriptType type, boolean isTemplate) {
@@ -140,6 +146,7 @@ private void removeScripts() {
140146
return;
141147
}
142148
removeScript(SCRIPT_SUSPICIOUS_INPUT_TRANSFORMATION, false);
149+
removeScript(SCRIPT_SWAGGER_SECRET_DETECTOR, false);
143150
}
144151

145152
private void removeScript(String name, boolean isTemplate) {

addOns/ascanrulesAlpha/src/main/javahelp/org/zaproxy/zap/extension/ascanrulesAlpha/resources/help/contents/ascanalpha.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,14 @@ <H2 id="id-40039">Web Cache Deception</H2>
4141
<br>
4242
Alert ID: <a href="https://www.zaproxy.org/docs/alerts/40039/">40039</a>.
4343

44+
<H2 id="id-100043">Swagger Secret & Vulnerability Detector</H2>
45+
This is an active script scan rule. It attempts to find exposed OpenAPI documentation that leaks sensitive secrets such
46+
as API keys, OAuth client secrets, access tokens, or run vulnerable versions.
47+
<p>
48+
Latest code: <a href="https://github.com/zaproxy/zap-extensions/blob/main/addOns/ascanrulesAlpha/src/main/zapHomeFiles/scripts/scripts/active/SwaggerSecretDetector.js">SwaggerSecretDetector.js</a>
49+
<br>
50+
Alert ID: <a href="https://www.zaproxy.org/docs/alerts/100043/">100043</a>.
51+
4452
<H2 id="id-100044">Suspicious Input Transformation</H2>
4553
This is an active script scan rule. It detects various types of suspicious input transformations that may indicate
4654
potential security vulnerabilities such as template injection, expression evaluation, quote consumption, and issues

addOns/ascanrulesAlpha/src/main/resources/org/zaproxy/zap/extension/ascanrulesAlpha/resources/Messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ascanalpha.name = Active Scan Rules - alpha
2828
ascanalpha.scripts.desc = Adds alpha status active scan rule scripts.
2929
ascanalpha.scripts.name = Active Scan Rule Scripts - alpha
3030
ascanalpha.scripts.suspiciousInputTransformation.desc = This script detects suspicious input transformations in web applications.
31+
ascanalpha.scripts.swaggerSecretDetector.desc = This script attempts to find exposed API documentation endpoints that may contain sensitive information.
3132
ascanalpha.scripts.warn.couldNotAddScripts = Could not add alpha active scan rule scripts: {0}.
3233

3334
ascanalpha.webCacheDeception.desc = Web cache deception may be possible. It may be possible for unauthorised user to view sensitive data on this page.

0 commit comments

Comments
 (0)