Skip to content

Commit 1ea458a

Browse files
authored
Fix exceptions with newer option (#21)
Load the option with the method that defaults to a given value when it does not exist, otherwise this will lead to `NoSuchElementException` until the option is set. Also, use the primitive boolean which is the most appropriate type and prevents `NullPointerException`s as it was null by default. Signed-off-by: thc202 <thc202@gmail.com>
1 parent 63ec7ba commit 1ea458a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ All notable changes to this add-on will be documented in this file.
33

44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
55
## Unreleased
6+
### Fixed
7+
- Fix exceptions using option introduced in previous version.
68

79
## [1.2.0] - 2023-10-19
810
- Ensure i18n resources are always initialized.

src/main/java/org/sasanlabs/fileupload/attacks/FileUploadAttackExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public FileUploadAttackExecutor(
7272

7373
public boolean executeAttack() throws FileUploadException {
7474

75-
Boolean shouldSendRequestsAfterFindingVulnerability =
75+
boolean shouldSendRequestsAfterFindingVulnerability =
7676
FileUploadConfiguration.getInstance().getSendRequestsAfterFindingVulnerability();
7777

7878
for (AttackVector attackVector : attackVectors) {

src/main/java/org/sasanlabs/fileupload/configuration/FileUploadConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class FileUploadConfiguration extends VersionedAbstractParam {
4747
private String parseResponseStartIdentifier;
4848
private String parseResponseEndIdentifier;
4949

50-
private Boolean sendRequestsAfterFindingVulnerability;
50+
private boolean sendRequestsAfterFindingVulnerability;
5151

5252
private static volatile FileUploadConfiguration fileUploadConfiguration;
5353

@@ -109,7 +109,7 @@ public void setParseResponseEndIdentifier(String parseResponseEndIdentifier) {
109109
parseResponseEndIdentifier);
110110
}
111111

112-
public Boolean getSendRequestsAfterFindingVulnerability() {
112+
public boolean getSendRequestsAfterFindingVulnerability() {
113113
return sendRequestsAfterFindingVulnerability;
114114
}
115115

@@ -142,7 +142,7 @@ protected void parseImpl() {
142142
this.setParseResponseEndIdentifier(
143143
getConfig().getString(PARAM_PARSE_RESPONSE_CONFIGURATION_END_IDENTIFIER));
144144
this.setSendRequestsAfterFindingVulnerability(
145-
getConfig().getBoolean(PARAM_SEND_REQUESTS_AFTER_FINDING_VULNERABILITY_IDENTIFIER));
145+
getBoolean(PARAM_SEND_REQUESTS_AFTER_FINDING_VULNERABILITY_IDENTIFIER, false));
146146
}
147147

148148
@Override

0 commit comments

Comments
 (0)