Add x-content-type-options header to fileStreamingUtil (#934)

* Add x-content-type-options header to fileStreamingUtil

Signed-off-by: Sebastian Firsching <sebastian.firsching@bosch-si.com>

* Add comment why the x-content-type-options header has to be set

Signed-off-by: Sebastian Firsching <sebastian.firsching@bosch-si.com>
This commit is contained in:
Sebastian Firsching
2020-02-20 11:09:29 +01:00
committed by GitHub
parent c7e910c9c3
commit a9b4195732

View File

@@ -131,6 +131,10 @@ public final class FileStreamingUtil {
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename);
response.setHeader(HttpHeaders.ETAG, etag);
response.setHeader(HttpHeaders.ACCEPT_RANGES, "bytes");
// set the x-content-type options header to prevent browsers from doing
// MIME-sniffing when downloading an artifact, as this could cause a
// security vulnerability
response.setHeader(com.google.common.net.HttpHeaders.X_CONTENT_TYPE_OPTIONS, "nosniff");
if (lastModified > 0) {
response.setDateHeader(HttpHeaders.LAST_MODIFIED, lastModified);
}