-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This imports the [x-xss-protection package][0] into this repo as part of my effort to make Helmet a monorepo. You can find its prior history in the old repo. Similar to: * df561bb which imported `helmet-csp` * 936cd27 which imported `referrer-policy` * 141f131 which imported `crossdomain` * ff12fb7 which imported `dont-sniff-mimetype` * 2b64d11 which imported `hide-powered-by` * 7906601 which imported `frameguard` * d03c555 which imported `expect-ct` * e933c28 which imported `dns-prefetch-control` * 13b496f which imported `ienoopen` [0]: https://github.com/helmetjs/x-xss-protection
- Loading branch information
Showing
11 changed files
with
106 additions
and
12 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Changelog | ||
|
||
## 2.0.0 - Unreleased | ||
|
||
### Changed | ||
|
||
- XSS filtering is now disabled by default. See [#230](https://github.com/helmetjs/helmet/issues/230) | ||
|
||
### Removed | ||
|
||
- No longer accepts options. Read ["How to disable blocking with X–XSS–Protection"](https://github.com/helmetjs/helmet/wiki/How-to-disable-blocking-with-X%E2%80%93XSS%E2%80%93Protection) and ["How to enable the `report` directive with X–XSS–Protection"](https://github.com/helmetjs/helmet/wiki/How-to-enable-the-%60report%60-directive-with-X%E2%80%93XSS%E2%80%93Protection) if you need the legacy behavior. | ||
- Dropped support for old Node versions. Node 10+ is now required | ||
|
||
## 1.3.0 - 2019-09-01 | ||
|
||
### Added | ||
|
||
- Added `mode: null` to disable `mode=block` | ||
|
||
### Changed | ||
|
||
- Minor performance improvements with Internet Explorer <9 detection | ||
|
||
## 1.2.0 - 2019-06-15 | ||
|
||
### Added | ||
|
||
- Added TypeScript type definitions. See [#8](https://github.com/helmetjs/x-xss-protection/pull/8) | ||
- Created a changelog | ||
- Added some additional package metadata | ||
|
||
### Changed | ||
|
||
- Updated documentation | ||
- Excluded some files from npm package | ||
|
||
Changes in versions 1.1.0 and below can be found in [Helmet's changelog](https://github.com/helmetjs/helmet/blob/master/CHANGELOG.md). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# X-XSS-Protection middleware | ||
|
||
The `X-XSS-Protection` HTTP header aimed to offer a basic protection against cross-site scripting (XSS) attacks. _However, you probably should disable it_, which is what this middleware does. | ||
|
||
Many browsers have chosen to remove it because of the unintended security issues it creates. Generally, you should protect against XSS with sanitization and a Content Security Policy. For more, read [this GitHub issue](https://github.com/helmetjs/helmet/issues/230). | ||
|
||
This middleware sets the `X-XSS-Protection` header to `0`. For example: | ||
|
||
```javascript | ||
const xXssProtection = require("x-xss-protection"); | ||
|
||
// Set "X-XSS-Protection: 0" | ||
app.use(xXssProtection()); | ||
``` | ||
|
||
If you truly need the legacy behavior, you can write your own simple middleware and avoid installing this module. For example: | ||
|
||
```javascript | ||
// NOTE: This is probably insecure! | ||
app.use((req, res, next) => { | ||
res.setHeader("X-XSS-Protection", "1; mode=block"); | ||
next(); | ||
}); | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { IncomingMessage, ServerResponse } from "http"; | ||
|
||
function xXssProtectionMiddleware( | ||
_req: IncomingMessage, | ||
res: ServerResponse, | ||
next: () => void | ||
) { | ||
res.setHeader("X-XSS-Protection", "0"); | ||
next(); | ||
} | ||
|
||
function xXssProtection() { | ||
return xXssProtectionMiddleware; | ||
} | ||
|
||
module.exports = xXssProtection; | ||
export default xXssProtection; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["index.js", "index.d.ts"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "x-xss-protection", | ||
"description": "Middleware to disable the X-XSS-Protection header", | ||
"version": "1.3.0", | ||
"keywords": ["express", "security", "x-xss-protection"], | ||
"homepage": "https://helmetjs.github.io/docs/xss-filter/" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { check } from "./helpers"; | ||
import xXssProtection from "../middlewares/x-xss-protection"; | ||
|
||
describe("X-XSS-Protection middleware", () => { | ||
it('sets "X-XSS-Protection: 0"', async () => { | ||
await check(xXssProtection(), { | ||
"x-xss-protection": "0", | ||
}); | ||
}); | ||
}); |