|
43 | 43 | *
|
44 | 44 | * @author psiinon
|
45 | 45 | */
|
46 |
| -public class ExampleFileActiveScanRule extends AbstractAppParamPlugin { |
| 46 | +public class ExampleFileActiveScanRule extends AbstractAppParamPlugin |
| 47 | + implements CommonActiveScanRuleInfo { |
47 | 48 |
|
48 | 49 | /** Prefix for internationalized messages used by this rule */
|
49 | 50 | private static final String MESSAGE_PREFIX = "ascanalpha.examplefile.";
|
@@ -80,7 +81,7 @@ public String getDescription() {
|
80 | 81 | return Constant.messages.getString(MESSAGE_PREFIX + "desc");
|
81 | 82 | }
|
82 | 83 |
|
83 |
| - private String getOtherInfo() { |
| 84 | + private static String getOtherInfo() { |
84 | 85 | return Constant.messages.getString(MESSAGE_PREFIX + "other");
|
85 | 86 | }
|
86 | 87 |
|
@@ -155,14 +156,7 @@ public void scan(HttpMessage msg, String param, String value) {
|
155 | 156 | String evidence;
|
156 | 157 | if ((evidence = doesResponseContainString(msg.getResponseBody(), attack)) != null) {
|
157 | 158 | // Raise an alert
|
158 |
| - newAlert() |
159 |
| - .setConfidence(Alert.CONFIDENCE_MEDIUM) |
160 |
| - .setParam(param) |
161 |
| - .setAttack(attack) |
162 |
| - .setOtherInfo(getOtherInfo()) |
163 |
| - .setEvidence(evidence) |
164 |
| - .setMessage(testMsg) |
165 |
| - .raise(); |
| 159 | + createAlert(param, attack, evidence).setMessage(testMsg).raise(); |
166 | 160 | return;
|
167 | 161 | }
|
168 | 162 | }
|
@@ -194,7 +188,16 @@ private String doesResponseContainString(HttpBody body, String str) {
|
194 | 188 | return null;
|
195 | 189 | }
|
196 | 190 |
|
197 |
| - private List<String> loadFile(String file) { |
| 191 | + private AlertBuilder createAlert(String param, String attack, String evidence) { |
| 192 | + return newAlert() |
| 193 | + .setConfidence(Alert.CONFIDENCE_MEDIUM) |
| 194 | + .setParam(param) |
| 195 | + .setAttack(attack) |
| 196 | + .setOtherInfo(getOtherInfo()) |
| 197 | + .setEvidence(evidence); |
| 198 | + } |
| 199 | + |
| 200 | + private static List<String> loadFile(String file) { |
198 | 201 | /*
|
199 | 202 | * ZAP will have already extracted the file from the add-on and put it underneath the 'ZAP home' directory
|
200 | 203 | */
|
@@ -244,4 +247,9 @@ public int getWascId() {
|
244 | 247 | // The WASC ID
|
245 | 248 | return 0;
|
246 | 249 | }
|
| 250 | + |
| 251 | + @Override |
| 252 | + public List<Alert> getExampleAlerts() { |
| 253 | + return List.of(createAlert("foo", "<SCRIPT>a=/XSS/", "<SCRIPT>a=/XSS/").build()); |
| 254 | + } |
247 | 255 | }
|
0 commit comments