Skip to content

Commit 231a33d

Browse files
committed
Reduce usage of error level logging in ascan rules
- Add change note. - Update logging in scan rules. Signed-off-by: kingthorin <[email protected]>
1 parent 8c1132e commit 231a33d

36 files changed

+171
-121
lines changed

addOns/ascanrules/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1717
- The Remote OS Command Injection scan rule has been broken into two rules; one feedback based, and one time based (Issue 7341). This includes assigning the time based rule ID 90037.
1818
- The External Redirect scan rule payload were slightly re-ordered to prioritize HTTPS variants.
1919
- For Alerts raised by the SQL Injection scan rules the Attack field values are now simply the payload, not an assembled description.
20+
- Reduced usage of error level logging.
2021

2122
### Added
2223
- Rules (as applicable) have been tagged in relation to HIPAA and PCI DSS.

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/BufferOverflowScanRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void scan(HttpMessage msg, String param, String value) {
156156
} catch (URIException e) {
157157
LOGGER.debug("Failed to send HTTP message, cause: {}", e.getMessage());
158158
} catch (IOException e) {
159-
LOGGER.error(e.getMessage(), e);
159+
LOGGER.debug(e.getMessage(), e);
160160
}
161161
}
162162

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/CrossSiteScriptingScanRule.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import static org.zaproxy.zap.extension.ascanrules.utils.Constants.NULL_BYTE_CHARACTER;
2323

24+
import java.io.IOException;
2425
import java.net.UnknownHostException;
2526
import java.util.Arrays;
2627
import java.util.Collections;
@@ -257,8 +258,8 @@ private List<HtmlContext> performAttack(
257258
// Not an error, just means we probably attacked the redirect
258259
// location
259260
return null;
260-
} catch (Exception e) {
261-
LOGGER.error(e.getMessage(), e);
261+
} catch (IOException e) {
262+
LOGGER.debug(e.getMessage(), e);
262263
}
263264

264265
if (isStop()) {
@@ -994,8 +995,8 @@ public void scan(HttpMessage msg, String param, String value) {
994995
attackHeader(msg, param, appendedValue ? value : "");
995996
}
996997

997-
} catch (Exception e) {
998-
LOGGER.error(e.getMessage(), e);
998+
} catch (IOException e) {
999+
LOGGER.debug(e.getMessage(), e);
9991000
}
10001001
}
10011002

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/FormatStringScanRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ && isPage200(verificationMsg)) {
272272
} catch (URIException e) {
273273
LOGGER.debug("Failed to send HTTP message, cause: {}", e.getMessage());
274274
} catch (IOException e) {
275-
LOGGER.error(e.getMessage(), e);
275+
LOGGER.debug(e.getMessage(), e);
276276
}
277277
}
278278

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/HeartBleedActiveScanRule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,9 +1042,9 @@ public void scan() {
10421042
if (os != null) os.close();
10431043
}
10441044
}
1045-
} catch (Exception e) {
1045+
} catch (IOException e) {
10461046
// needed to catch exceptions from the "finally" statement
1047-
LOGGER.error("Error scanning a node for HeartBleed: {}", e.getMessage(), e);
1047+
LOGGER.debug("Error scanning a node for HeartBleed: {}", e.getMessage(), e);
10481048
}
10491049
}
10501050

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/HiddenFilesScanRule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -383,13 +383,13 @@ private static List<String> getOptionalList(JSONObject jsonObj, String key) {
383383
private String readPayloadsFile(String path) {
384384
File f = new File(path);
385385
if (!f.exists()) {
386-
LOGGER.error("No such file: {}", f.getAbsolutePath());
386+
LOGGER.warn("No such file: {}", f.getAbsolutePath());
387387
return "";
388388
}
389389
try {
390390
return new String(Files.readAllBytes(f.toPath()), StandardCharsets.UTF_8);
391391
} catch (IOException e) {
392-
LOGGER.error(
392+
LOGGER.warn(
393393
"Error on opening/reading {} payload file. Error: {}",
394394
getName(),
395395
e.getMessage(),

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/Log4ShellScanRule.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public void scan(HttpMessage msg, String param, String value) {
156156
scanWithPayloads(param, ATTACK_PATTERNS_CVE44228, PREFIX_CVE44228);
157157
scanWithPayloads(param, ATTACK_PATTERNS_CVE45046, PREFIX_CVE45046);
158158
} catch (Exception e) {
159-
LOGGER.error(e.getMessage(), e);
159+
LOGGER.warn(e.getMessage(), e);
160160
}
161161
}
162162

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/PersistentXssPrimeScanRule.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.zaproxy.zap.extension.ascanrules;
2121

22+
import java.io.IOException;
2223
import java.util.Collections;
2324
import java.util.HashMap;
2425
import java.util.Map;
@@ -95,8 +96,8 @@ public void scan(HttpMessage msg, String param, String value) {
9596
this.setParameter(msg1, param, SourceSinkUtils.getUniqueValue(msg1, param));
9697
LOGGER.debug("Prime msg={} param={}", msg1.getRequestHeader().getURI(), param);
9798
sendAndReceive(msg1, false);
98-
} catch (Exception e) {
99-
LOGGER.error(e.getMessage(), e);
99+
} catch (IOException e) {
100+
LOGGER.debug(e.getMessage(), e);
100101
}
101102
}
102103

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/PersistentXssScanRule.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.zaproxy.zap.extension.ascanrules;
2121

22+
import java.io.IOException;
2223
import java.util.Arrays;
2324
import java.util.Collections;
2425
import java.util.HashMap;
@@ -146,8 +147,8 @@ private List<HtmlContext> performAttack(
146147
setParameter(sourceMsg2, param, attack);
147148
try {
148149
sendAndReceive(sourceMsg2);
149-
} catch (Exception e) {
150-
LOGGER.error(e.getMessage(), e);
150+
} catch (IOException e) {
151+
LOGGER.debug(e.getMessage(), e);
151152
}
152153

153154
if (isStop()) {
@@ -157,8 +158,8 @@ private List<HtmlContext> performAttack(
157158
HttpMessage sinkMsg2 = sinkMsg.cloneRequest();
158159
try {
159160
sendAndReceive(sinkMsg2);
160-
} catch (Exception e) {
161-
LOGGER.error(e.getMessage(), e);
161+
} catch (IOException e) {
162+
LOGGER.debug(e.getMessage(), e);
162163
}
163164

164165
if (isStop()) {
@@ -690,8 +691,8 @@ public void scan(HttpMessage sourceMsg, String param, String value) {
690691
}
691692
}
692693
}
693-
} catch (Exception e) {
694-
LOGGER.error(e.getMessage(), e);
694+
} catch (IOException e) {
695+
LOGGER.debug(e.getMessage(), e);
695696
}
696697
}
697698

addOns/ascanrules/src/main/java/org/zaproxy/zap/extension/ascanrules/PersistentXssSpiderScanRule.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.zaproxy.zap.extension.ascanrules;
2121

22+
import java.io.IOException;
2223
import java.util.Collections;
2324
import java.util.HashMap;
2425
import java.util.Map;
@@ -102,8 +103,8 @@ public void scan() {
102103
sendAndReceive(msg1, false);
103104
SourceSinkUtils.testForSink(msg1);
104105

105-
} catch (Exception e) {
106-
LOGGER.error(e.getMessage(), e);
106+
} catch (IOException e) {
107+
LOGGER.debug(e.getMessage(), e);
107108
}
108109
}
109110

0 commit comments

Comments
 (0)