@Test public void client_reads_scan_code_yellow_with_findings() throws Exception { File file = new File("src/test/resources/scan_code_yellow_with_findings.json"); SecHubReport report = SecHubClient.importSecHubJsonReport(file); assertReport(report). hasJobUUID("6cf02ccf-da13-4dee-b529-0225ed9661bd"). hasFindings(2). hasTrafficLight(TrafficLight.YELLOW). finding(0). hasId(1). hasSeverity(Severity.MEDIUM). hasNoHostnames(). hasNoReferences(). hasName("Absolute Path Traversal"). hasDescription(""). codeCall(0). hasLine(28). hasLocation("java/com/daimler/sechub/docgen/AsciidocGenerator.java"). codeCall(1). hasLine(33). hasRelevantPart("args"). hasLocation("java/com/daimler/sechub/docgen/AsciidocGenerator.java"). codeCall(2). hasLine(33). hasRelevantPart("path"). hasLocation("java/com/daimler/sechub/docgen/AsciidocGenerator.java"). codeCall(3). hasLocation("java/com/daimler/sechub/docgen/AsciidocGenerator.java"). finding(1). hasId(2). hasSeverity(Severity.LOW). hasName("Improper Exception Handling"). hasDescription(""). hasNoReferences(). hasNoHostnames(). codeCall(0). hasLocation("java/com/daimler/sechub/docgen/usecase/UseCaseRestDocModelAsciiDocGenerator.java"). hasLine(112). hasColumn(53). hasSource("\t\tFile[] files = entry.copiedRestDocFolder.listFiles();"). hasRelevantPart("listFiles"); }
public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; }
SecHubClient { public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; } }
SecHubClient { public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; } private  SecHubClient(String username, String apiToken, URI hostUri, int hostPort, boolean trustAll); }
SecHubClient { public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; } private  SecHubClient(String username, String apiToken, URI hostUri, int hostPort, boolean trustAll); static SecHubClient create(String username, String apiToken, String hostUri, int hostPort); static SecHubClient create(String username, String apiToken, String hostUri, int hostPort, boolean trustAll); String getUsername(); String getSealedApiToken(); URI getHostUri(); int getHostPort(); boolean isTrustAll(); static SecHubReport importSecHubJsonReport(File file); }
SecHubClient { public static SecHubReport importSecHubJsonReport(File file) throws SecHubReportException { SecHubReport report = null; ObjectMapper mapper = new ObjectMapper(); try { mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); report = mapper.readValue(file, SecHubReport.class); } catch (JsonParseException | JsonMappingException e) { throw new SecHubReportException("Content is not valid JSON", e); } catch (IOException e) { throw new SecHubReportException("Wasn't able to read report file", e); } return report; } private  SecHubClient(String username, String apiToken, URI hostUri, int hostPort, boolean trustAll); static SecHubClient create(String username, String apiToken, String hostUri, int hostPort); static SecHubClient create(String username, String apiToken, String hostUri, int hostPort, boolean trustAll); String getUsername(); String getSealedApiToken(); URI getHostUri(); int getHostPort(); boolean isTrustAll(); static SecHubReport importSecHubJsonReport(File file);  }