【发布时间】:2021-09-17 09:16:24
【问题描述】:
Veracode 报告我的应用程序在将文件流写入 outputStream 时存在 XXS 风险。我正在尝试使用 ESAPI 来解决这个问题,但仍然报告了同样的问题。我该怎么办?
public static int copyStream(InputStream in, OutputStream out, int buffer)
throws IOException {
byte buf[] = new byte[buffer];
int len;
int ttl = 0;
while ((len = in.read(buf)) != -1) {
try {
buf = ESAPI.validator().getValidFileContent(IOUtil.class.getName(), buf, 50000000, false);
out.write(buf, 0, len);
ttl += len;
} catch (IntrusionException e) {
e.printStackTrace();
} catch (ValidationException e) {
e.printStackTrace();
}
}
out.flush();
in.close();
out.close();
return ttl;
}
【问题讨论】: