Skip to content

Commit

Permalink
fix bug with db not enough chars for components, imrpoved logging for…
Browse files Browse the repository at this point in the history
… SCA
  • Loading branch information
siewer committed Aug 22, 2024
1 parent 4b1eca9 commit 6c5f9f3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
9 changes: 5 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
/frontend/node_modules
.idea
.DS_Store
frontend/.DS_Store
frontend/src/.DS_Store
frontend/src/assets/.DS_Store
backend/MixewayFlowAPI.iml
/frontend/.DS_Store
/frontend/src/.DS_Store
/frontend/src/assets/.DS_Store
/backend/MixewayFlowAPI.iml
/frontend/src/environments
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.mixeway.mixewayflowapi.exceptions;

public class ScanException
extends Exception {
public ScanException(String errorMessage) {
super(errorMessage);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import io.mixeway.mixewayflowapi.db.entity.Settings;
import io.mixeway.mixewayflowapi.domain.coderepo.UpdateCodeRepoService;
import io.mixeway.mixewayflowapi.domain.dtrack.ProcessDTrackVulnDataService;
import io.mixeway.mixewayflowapi.exceptions.ScanException;
import io.mixeway.mixewayflowapi.integrations.scanner.sca.dto.*;
import io.mixeway.mixewayflowapi.utils.Constants;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -248,12 +249,23 @@ private void sendBomToDTrack(CodeRepo codeRepo, String bomPath, Settings setting
Mono<ResponseEntity<String>> responseMono = webClient.method(HttpMethod.PUT)
.bodyValue(new SendBomRequestDto(codeRepo.getScaUUID(), encodeFileToBase64Binary(bomPath)))
.retrieve()
.onStatus(status -> status.is4xxClientError() || status.is5xxServerError(), clientResponse ->
clientResponse.bodyToMono(String.class)
.flatMap(errorBody -> {
log.error("[Dependency Track] Error uploading SBOM: {}", errorBody);
return Mono.error(new ScanException("Failed to upload SBOM: " + errorBody));
})
)
.toEntity(String.class);

ResponseEntity<String> response = responseMono.block();
try {
ResponseEntity<String> response = responseMono.block();

if (response != null && response.getStatusCode().equals(HttpStatus.OK)) {
log.info("[Dependency Track] Uploaded SBOM to Dependency Track for {}", codeRepo.getRepourl());
if (response != null && response.getStatusCode().equals(HttpStatus.OK)) {
log.info("[Dependency Track] Uploaded SBOM to Dependency Track for {}", codeRepo.getRepourl());
}
} catch (Exception e ){
log.error("[Dependency Track] Error for uploading SBOM - {}", e.getMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ ADD CONSTRAINT fk_default_branch FOREIGN KEY (default_branch_id) REFERENCES code
--changeset siewer:add_finding_vuln_component
CREATE TABLE component (
id SERIAL PRIMARY KEY,
groupid VARCHAR(60),
name VARCHAR(60) NOT NULL,
version VARCHAR(20) NOT NULL,
groupid VARCHAR(160),
name VARCHAR(160) NOT NULL,
version VARCHAR(120) NOT NULL,
inserted_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

Expand Down

0 comments on commit 6c5f9f3

Please sign in to comment.