Skip to content

Commit 130a695

Browse files
committed
Improve Error Message on Failed attachment of Finding
The original code does not provide the causing error, which makes it dificult to debug the problem. - Add first adding loggign capabilities via SLF4J. - Log the failed attempt of attaching a finding as eror w/ original exception message. - Pass the causing exception to the exception we rethrow to preserve the full stack trace. Signed-off-by: Sven Strittmatter <[email protected]>
1 parent 74aa334 commit 130a695

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@
122122
<version>${com.fasterxml.jackson.version}</version>
123123
</dependency>
124124
<dependency>
125+
<groupId>org.slf4j</groupId>
126+
<artifactId>slf4j-api</artifactId>
127+
<version>2.0.11</version>
128+
</dependency>
129+
130+
<dependency>
125131
<groupId>org.projectlombok</groupId>
126132
<artifactId>lombok</artifactId>
127133
<version>1.18.30</version>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import io.securecodebox.persistence.defectdojo.model.ScanFile;
1212
import lombok.Getter;
1313
import lombok.NonNull;
14+
import lombok.extern.slf4j.Slf4j;
1415
import org.apache.http.HttpHost;
1516
import org.apache.http.auth.AuthScope;
1617
import org.apache.http.auth.UsernamePasswordCredentials;
@@ -40,6 +41,7 @@
4041
/*
4142
* https://defectdojo.security.iteratec.dev/api/v2/oa3/swagger-ui/#operations-tag-import-scan
4243
*/
44+
@Slf4j
4345
class DefaultImportScanService implements ImportScanService {
4446
private static final List<HttpMessageConverter<?>> HTTP_MESSAGE_CONVERTERS = List.of(
4547
new FormHttpMessageConverter(),
@@ -123,7 +125,8 @@ public String getFilename() {
123125
final var payload = new HttpEntity<MultiValueMap<String, Object>>(body, headers);
124126
return exchangeRequest(endpoint, payload);
125127
} catch (HttpClientErrorException e) {
126-
throw new PersistenceException("Failed to attach findings to engagement.");
128+
log.error("Exception while attaching findings to engagement: {}", e.getMessage());
129+
throw new PersistenceException("Failed to attach findings to engagement.", e);
127130
}
128131
}
129132

0 commit comments

Comments
 (0)