In Fortify code scan, we have a privacy violation in below Java code, which converts a byte[]
to ZipOutputStream
, which is later converted to another byte[]
. The exact sink line is zos.write(arr);
private byte[] zipFile(String filename, byte[] arr) throws UnableToZipException, IOException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
ZipOutputStream zos = new ZipOutputStream(baos)) {
ZipEntry entry = new ZipEntry(filename);
entry.setSize(arr.length);
zos.putNextEntry(entry);
zos.write(arr);
zos.closeEntry();
zos.close();
return baos.toByteArray();
} catch (Exception e) {
e.printStackTrace();
}
}
Is it a valid violation or a false positive? I am not writing the ZipOutputStream
to the local directory. If it is a valid privacy violation, how to resolve it?