|
4 | 4 | // Note that new passive scripts will initially be disabled |
5 | 5 | // Right click the script in the Scripts tree and select "enable" |
6 | 6 |
|
| 7 | +var ScanRuleMetadata = Java.type( |
| 8 | + "org.zaproxy.addon.commonlib.scanrules.ScanRuleMetadata" |
| 9 | +); |
| 10 | + |
| 11 | +function getMetadata() { |
| 12 | + return ScanRuleMetadata.fromYaml(` |
| 13 | +id: 100017 |
| 14 | +name: Non Static Site Detected |
| 15 | +description: > |
| 16 | + A query string or form has been detected in the HTTP response body. |
| 17 | + This indicates that this may not be a static site. |
| 18 | +solution: > |
| 19 | + If this is not a static site then ignore or disable this rule. |
| 20 | +risk: info |
| 21 | +confidence: medium |
| 22 | +status: alpha |
| 23 | +codeLink: https://github.com/zaproxy/community-scripts/blob/main/passive/Report%20non%20static%20sites.js |
| 24 | +helpLink: https://www.zaproxy.org/docs/desktop/addons/community-scripts/ |
| 25 | +`); |
| 26 | +} |
| 27 | + |
7 | 28 | /** |
8 | 29 | * Passively scans an HTTP message. The scan function will be called for |
9 | 30 | * request/response made via ZAP, actual messages depend on the function |
10 | 31 | * "appliesToHistoryType", defined below. |
11 | 32 | * |
12 | | - * @param ps - the PassiveScan parent object that will do all the core interface tasks |
| 33 | + * @param helper - the PassiveScan parent object that will do all the core interface tasks |
13 | 34 | * (i.e.: providing access to Threshold settings, raising alerts, etc.). |
14 | 35 | * This is an ScriptsPassiveScanner object. |
15 | 36 | * @param msg - the HTTP Message being scanned. This is an HttpMessage object. |
16 | 37 | * @param src - the Jericho Source representation of the message being scanned. |
17 | 38 | */ |
18 | | -function scan(ps, msg, src) { |
19 | | - // Test the request and/or response here |
| 39 | +function scan(helper, msg, src) { |
20 | 40 | if (msg.getRequestHeader().getURI().getEscapedQuery() != null) { |
21 | | - // raiseAlert(risk, int confidence, String name, String description, String uri, |
22 | | - // String param, String attack, String otherInfo, String solution, String evidence, |
23 | | - // int cweId, int wascId, HttpMessage msg) |
24 | | - // risk: 0: info, 1: low, 2: medium, 3: high |
25 | | - // confidence: 0: falsePositive, 1: low, 2: medium, 3: high, 4: confirmed |
26 | | - ps.raiseAlert( |
27 | | - 3, |
28 | | - 2, |
29 | | - "Non static site (query present)", |
30 | | - "A query string has been detected in one of the sites URLs. This indicates that this might well not be a static site", |
31 | | - msg.getRequestHeader().getURI().toString(), |
32 | | - "", |
33 | | - "", |
34 | | - "", |
35 | | - "If this is not a static site then ignore or disable this script", |
36 | | - msg.getRequestHeader().getURI().getEscapedQuery(), |
37 | | - 0, |
38 | | - 0, |
39 | | - msg |
40 | | - ); |
| 41 | + helper |
| 42 | + .newAlert() |
| 43 | + .setName("Non Static Site Detected (query present)") |
| 44 | + .setDescription( |
| 45 | + "A query string has been detected in the HTTP response body. This indicates that this may not be a static site." |
| 46 | + ) |
| 47 | + .setEvidence(msg.getRequestHeader().getURI().getEscapedQuery()) |
| 48 | + .setMessage(msg) |
| 49 | + .raise(); |
41 | 50 | } |
42 | 51 | if (src != null && !src.getFormFields().isEmpty()) { |
43 | 52 | // There are form fields |
44 | | - ps.raiseAlert( |
45 | | - 3, |
46 | | - 2, |
47 | | - "Non static site (form present)", |
48 | | - "One or more forms have been detected in the response. This indicates that this might well not be a static site", |
49 | | - msg.getRequestHeader().getURI().toString(), |
50 | | - "", |
51 | | - "", |
52 | | - "", |
53 | | - "If this is not a static site then ignore or disable this script", |
54 | | - src.getFormFields().toString(), |
55 | | - 0, |
56 | | - 0, |
57 | | - msg |
58 | | - ); |
| 53 | + helper |
| 54 | + .newAlert() |
| 55 | + .setName("Non Static Site Detected (form present)") |
| 56 | + .setDescription( |
| 57 | + "One or more forms have been detected in the response. This indicates that this may not be a static site." |
| 58 | + ) |
| 59 | + .setEvidence(src.getFormFields().toString()) |
| 60 | + .setMessage(msg) |
| 61 | + .raise(); |
59 | 62 | } |
60 | 63 | } |
61 | 64 |
|
|
0 commit comments