private static String downloadFile()

in amazon-inspector-image-scanner/amazon-inspector-image-scanner-agent/src/main/java/com/amazon/inspector/teamcity/sbomgen/SbomgenDownloader.java [43:60]


    private static String downloadFile(String url) throws IOException {
        String tmpdir = Files.createTempDirectory("sbomgen").toFile().getAbsolutePath();
        String sbomgenPath = tmpdir + "/inspector_sbomgen.zip";

        try (BufferedInputStream in = new BufferedInputStream(new URL(url).openStream());
             FileOutputStream fileOutputStream = new FileOutputStream(sbomgenPath)) {
            byte dataBuffer[] = new byte[1024];
            int bytesRead;
            while ((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
                fileOutputStream.write(dataBuffer, 0, bytesRead);
            }
        } catch (IOException e) {
            throw new IOException("There was an issue downloading the SBOMGen utility, please run the plugin by " +
                    "providing the utility manually.");
        }

        return sbomgenPath;
    }