-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set
content-security-policy
, x-content-type-options
, and `x-frame…
…-options` headers for console assets (#5545) `content-security-policy` tells a web browser what type of content, and from which origins, may be loaded on a page. The primary use is to help guard against cross-site scripting attacks and other kinds of novel attacks on web applications. `x-content-type-options: nosniff` tells the web browser to disallow content sniffing that can cause a browser to decide that responses with non-executable content types (e.g. `image/png`) can in fact be used as executable content types (e.g. `text/javascript`). This needs to be set for all console assets. `x-frame-options: DENY` disallows embedding the console within another page, which helps to prevent click-jacking attacks. (This is obsoleted by the `frame-ancestors 'none'` CSP directive, but no harm in adding it.) `content-security-policy` only needs to be set for the console index page, but there's no harm in setting it for the console assets as well. As part of this change I did some refactoring: - The common code between the `asset` function and the `serve_console_index` function are now in a single common function. This allows us to ship a gzip-compressed console index in the future. - Assets are now streamed instead of read completely into memory. - I removed the dependency on `mime_guess`; we only have a small list of file extensions we're willing to serve, so it doesn't make sense to compile a huge list of content types we'll never use into Nexus. There may be other headers from https://owasp.org/www-project-secure-headers/ (see the Best Practices tab) that we want but these are probably the most urgent.
- Loading branch information
Showing
7 changed files
with
228 additions
and
128 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.