public String convertDocker()

in src/main/java/com/amazon/inspector/jenkins/amazoninspectorbuildstep/csvconversion/CsvConverter.java [86:113]


    public String convertDocker(String imageName, String imageSha, String buildId, SeverityCounts vulnCounts) throws IOException {
        Map<Severity, Integer> countMap = vulnCounts.getCounts();
        String tmpdir = System.getProperty("java.io.tmpdir");
        List<String[]> dataLineArray = new ArrayList<>();

        dataLineArray.add(new String[]{String.format("#image_name: %s; image_sha: %s; build_id: %s", imageName, imageSha, buildId)});
        dataLineArray.add(new String[]{String.format("#low_vulnerabilities: %s; medium_vulnerabilities: %s; high_vulnerabilities: %s; " +
                        "critical_vulnerabilities: %s; other_vulnerabilities: %s", countMap.get(Severity.LOW),
                countMap.get(Severity.MEDIUM), countMap.get(Severity.HIGH), countMap.get(Severity.CRITICAL),
                countMap.get(Severity.OTHER))});

        List<String[]> dataLines = buildDockerDataLines();
        if (dockerData.size() <= 0) {
            return null;
        }

        dataLineArray.addAll(dataLines);

        File file = new File(tmpdir + "/temp.csv");

        FileWriter outputfile = new FileWriter(file, Charset.forName("UTF-8"));
        CSVWriter writer = new CSVWriter(outputfile);

        writer.writeAll(dataLineArray);
        writer.close();

        return new String(Files.readAllBytes(Paths.get(file.getAbsolutePath())), StandardCharsets.UTF_8);
    }