Skip to content

Commit cf6fee1

Browse files
committed
#36 Use of <String,String:> as generic types instead of <String,Object>
Signed-off-by: Sven Strittmatter <sven.strittmatter@iteratec.com>
1 parent 1dee722 commit cf6fee1

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/main/java/io/securecodebox/persistence/defectdojo/service/ImportScanService.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected RestTemplate createRestTemplate() {
8787
/*
8888
* Before version 1.5.4. testName (in DefectDojo _test_type_) must be defectDojoScanName, afterward, you can have something else.
8989
*/
90-
protected ImportScanResponse createFindings(ScanFile scanFile, String endpoint, long lead, String currentDate, ScanType scanType, long testType, MultiValueMap<String, Object> options) {
90+
protected ImportScanResponse createFindings(ScanFile scanFile, String endpoint, long lead, String currentDate, ScanType scanType, long testType, MultiValueMap<String, String> options) {
9191
var restTemplate = this.createRestTemplate();
9292
HttpHeaders headers = createDefectDojoAuthorizationHeaders();
9393
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
@@ -110,7 +110,10 @@ protected ImportScanResponse createFindings(ScanFile scanFile, String endpoint,
110110
body.remove(optionName);
111111
}
112112

113-
body.addAll(options);
113+
// FIXME: Workaround due to type incompatibility of MultiValueMap<String, String> and MultiValueMap<String, Object>.
114+
for (final var option : options.entrySet()) {
115+
body.add(option.getKey(), option.getValue());
116+
}
114117

115118
try {
116119
ByteArrayResource contentsAsResource = new ByteArrayResource(scanFile.getContent().getBytes(StandardCharsets.UTF_8)) {
@@ -133,26 +136,26 @@ public String getFilename() {
133136
}
134137

135138
public ImportScanResponse importScan(ScanFile scanFile, long engagementId, long lead, String currentDate, ScanType scanType, long testType) {
136-
final var options = new LinkedMultiValueMap<String, Object>();
139+
final var options = new LinkedMultiValueMap<String, String>();
137140
options.add("engagement", Long.toString(engagementId)); // FIXME Seems to be duplicated bc it is done again in the overloaded method.
138141

139142
return this.importScan(scanFile, engagementId, lead, currentDate, scanType, testType, options);
140143
}
141144

142-
public ImportScanResponse importScan(ScanFile scanFile, long engagementId, long lead, String currentDate, ScanType scanType, long testType, MultiValueMap<String, Object> options) {
145+
public ImportScanResponse importScan(ScanFile scanFile, long engagementId, long lead, String currentDate, ScanType scanType, long testType, MultiValueMap<String, String> options) {
143146
options.add("engagement", Long.toString(engagementId));
144147

145148
return this.createFindings(scanFile, "import-scan", lead, currentDate, scanType, testType, options);
146149
}
147150

148151
public ImportScanResponse reimportScan(ScanFile scanFile, long testId, long lead, String currentDate, ScanType scanType, long testType) {
149-
final var options = new LinkedMultiValueMap<String, Object>();
152+
final var options = new LinkedMultiValueMap<String, String>();
150153
options.add("test", Long.toString(testId)); // FIXME Seems to be duplicated bc it is done again in the overloaded method.
151154

152155
return this.reimportScan(scanFile, testId, lead, currentDate, scanType, testType, options);
153156
}
154157

155-
public ImportScanResponse reimportScan(ScanFile scanFile, long testId, long lead, String currentDate, ScanType scanType, long testType, MultiValueMap<String, Object> options) {
158+
public ImportScanResponse reimportScan(ScanFile scanFile, long testId, long lead, String currentDate, ScanType scanType, long testType, MultiValueMap<String, String> options) {
156159
options.add("test", Long.toString(testId));
157160

158161
return this.createFindings(scanFile, "reimport-scan", lead, currentDate, scanType, testType, options);

0 commit comments

Comments
 (0)