From c2e57cefe274a376cfd5d526d755d1bbd5e0d8e8 Mon Sep 17 00:00:00 2001 From: Ruud Senden <8635138+rsenden@users.noreply.github.com> Date: Tue, 24 Jan 2023 13:59:00 +0100 Subject: [PATCH] chore: Remove Debricked HTTP response work-around as this was fixed on Debricked side --- ...ionArtifactImportFromDebrickedCommand.java | 25 ------------------- 1 file changed, 25 deletions(-) diff --git a/fcli-ssc/src/main/java/com/fortify/cli/ssc/appversion_artifact/cli/cmd/imprt/debricked/SSCAppVersionArtifactImportFromDebrickedCommand.java b/fcli-ssc/src/main/java/com/fortify/cli/ssc/appversion_artifact/cli/cmd/imprt/debricked/SSCAppVersionArtifactImportFromDebrickedCommand.java index 4ec93b183b..bddc467d80 100644 --- a/fcli-ssc/src/main/java/com/fortify/cli/ssc/appversion_artifact/cli/cmd/imprt/debricked/SSCAppVersionArtifactImportFromDebrickedCommand.java +++ b/fcli-ssc/src/main/java/com/fortify/cli/ssc/appversion_artifact/cli/cmd/imprt/debricked/SSCAppVersionArtifactImportFromDebrickedCommand.java @@ -25,12 +25,7 @@ package com.fortify.cli.ssc.appversion_artifact.cli.cmd.imprt.debricked; import java.io.File; -import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.StandardCopyOption; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Stream; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -210,26 +205,6 @@ private void waitSbomGeneration(UnirestInstance debrickedUnirest, String reportU .queryString("reportUuid", reportUuid) .asFile(outputFile.getAbsolutePath(), StandardCopyOption.REPLACE_EXISTING) .getStatus(); - // Work-around for debricked not returning proper HTTP status code - status = status!=200 ? status : checkResponse(outputFile); - } - } - - @SneakyThrows - private int checkResponse(File file) { - Pattern p = Pattern.compile(".*\\\"statusCode\\\":([\\d]+).*"); - Path path = file.toPath(); - try ( Stream lines = Files.lines(path) ) { - String statusCode = lines.map(p::matcher) - .filter(Matcher::matches) - .findFirst() - .map(m->m.group(1)) - .orElse(null); - int status = statusCode==null ? 200 : Integer.parseInt(statusCode); - if ( status!=200 && status!=202 ) { - throw new IllegalStateException("Unexpected Debricked response: "+Files.readString(path)); - } - return status; } } }