Project rename
This commit is contained in:
+2
@@ -0,0 +1,2 @@
|
||||
node_modules/
|
||||
*.log
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.12"
|
||||
- "4.2"
|
||||
- "5"
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014, 2015 Evan Hahn, Adam Baldwin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
Hide X-Powered-By
|
||||
=================
|
||||
[](https://travis-ci.org/helmetjs/hide-powered-by)
|
||||
[](http://standardjs.com/)
|
||||
|
||||
Simple middleware to remove the `X-Powered-By` HTTP header if it's set.
|
||||
|
||||
Hackers can exploit known vulnerabilities in Express/Node if they see that your site is powered by Express (or whichever framework you use). For example, `X-Powered-By: Express` is sent in every HTTP request coming from Express, by default. This won't provide much security benefit ([as discussed here](https://github.com/strongloop/express/pull/2813#issuecomment-159270428)), but might help a tiny bit. It will also improve performance by reducing the number of bytes sent.
|
||||
|
||||
```javascript
|
||||
var hidePoweredBy = require('hide-powered-by')
|
||||
app.use(hidePoweredBy())
|
||||
```
|
||||
|
||||
You can also explicitly set the header to something else, if you want. This could throw people off:
|
||||
|
||||
```javascript
|
||||
app.use(hidePoweredBy({ setTo: 'PHP 4.2.0' }))
|
||||
```
|
||||
|
||||
Note: if you're using Express, you don't need this middleware and can just do this:
|
||||
|
||||
```javascript
|
||||
app.disable('x-powered-by')
|
||||
```
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
module.exports = function hidePoweredBy (options) {
|
||||
var setTo = (options || {}).setTo
|
||||
|
||||
if (setTo) {
|
||||
return function hidePoweredBy (req, res, next) {
|
||||
res.setHeader('X-Powered-By', setTo)
|
||||
next()
|
||||
}
|
||||
} else {
|
||||
return function hidePoweredBy (req, res, next) {
|
||||
res.removeHeader('X-Powered-By')
|
||||
next()
|
||||
}
|
||||
}
|
||||
}
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
{
|
||||
"raw": "hide-powered-by@1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "hide-powered-by",
|
||||
"name": "hide-powered-by",
|
||||
"rawSpec": "1.0.0",
|
||||
"spec": "1.0.0",
|
||||
"type": "version"
|
||||
},
|
||||
"/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp/node_modules/helmet"
|
||||
]
|
||||
],
|
||||
"_from": "hide-powered-by@1.0.0",
|
||||
"_id": "hide-powered-by@1.0.0",
|
||||
"_inCache": true,
|
||||
"_location": "/hide-powered-by",
|
||||
"_nodeVersion": "5.3.0",
|
||||
"_npmUser": {
|
||||
"name": "evanhahn",
|
||||
"email": "me@evanhahn.com"
|
||||
},
|
||||
"_npmVersion": "3.5.3",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"raw": "hide-powered-by@1.0.0",
|
||||
"scope": null,
|
||||
"escapedName": "hide-powered-by",
|
||||
"name": "hide-powered-by",
|
||||
"rawSpec": "1.0.0",
|
||||
"spec": "1.0.0",
|
||||
"type": "version"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/helmet"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/hide-powered-by/-/hide-powered-by-1.0.0.tgz",
|
||||
"_shasum": "4a85ad65881f62857fc70af7174a1184dccce32b",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "hide-powered-by@1.0.0",
|
||||
"_where": "/Users/gerrit/Documents/dev/nodejs/rentfor.camp/html/RentForCamp/node_modules/helmet",
|
||||
"author": {
|
||||
"name": "Adam Baldwin",
|
||||
"email": "baldwin@andyet.net",
|
||||
"url": "http://andyet.net/team/baldwin"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/helmetjs/hide-powered-by/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Evan Hahn",
|
||||
"email": "me@evanhahn.com",
|
||||
"url": "http://evanhahn.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "Middleware to remove the X-Powered-By header.",
|
||||
"devDependencies": {
|
||||
"connect": "^3.3.1",
|
||||
"mocha": "^2.0.1",
|
||||
"standard": "^5.4.1",
|
||||
"supertest": "^1.1.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "4a85ad65881f62857fc70af7174a1184dccce32b",
|
||||
"tarball": "https://registry.npmjs.org/hide-powered-by/-/hide-powered-by-1.0.0.tgz"
|
||||
},
|
||||
"gitHead": "3f6f41a027c3a239243ee74e0b36e5efc2b3eb23",
|
||||
"homepage": "https://github.com/helmetjs/hide-powered-by#readme",
|
||||
"keywords": [
|
||||
"helmet",
|
||||
"security",
|
||||
"express",
|
||||
"connect",
|
||||
"x-powered-by",
|
||||
"powered-by"
|
||||
],
|
||||
"license": "MIT",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "evanhahn",
|
||||
"email": "me@evanhahn.com"
|
||||
}
|
||||
],
|
||||
"name": "hide-powered-by",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/helmetjs/hide-powered-by.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "standard && mocha"
|
||||
},
|
||||
"standard": {
|
||||
"globals": [
|
||||
"describe",
|
||||
"it"
|
||||
]
|
||||
},
|
||||
"version": "1.0.0"
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
var hidePoweredBy = require('..')
|
||||
|
||||
var connect = require('connect')
|
||||
var request = require('supertest')
|
||||
var assert = require('assert')
|
||||
|
||||
describe('hidePoweredBy', function () {
|
||||
function test (name, options) {
|
||||
it(name, function (done) {
|
||||
var app = connect()
|
||||
app.use(function (req, res, next) {
|
||||
res.setHeader('X-Powered-By', 'Computers')
|
||||
next()
|
||||
})
|
||||
app.use(options.middleware)
|
||||
app.use(function (req, res) {
|
||||
res.end('Hello world!')
|
||||
})
|
||||
request(app).get('/')
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
done(err)
|
||||
return
|
||||
}
|
||||
assert.equal(res.header['x-powered-by'], options.shouldBe)
|
||||
done()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
it('works even if no header is set', function (done) {
|
||||
var app = connect()
|
||||
app.use(hidePoweredBy())
|
||||
app.use(function (req, res) {
|
||||
res.end('Hello world!')
|
||||
})
|
||||
request(app).get('/')
|
||||
.end(function (err, res) {
|
||||
if (err) {
|
||||
done(err)
|
||||
return
|
||||
}
|
||||
assert.equal(res.header['x-powered-by'], undefined)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
test('removes the X-Powered-By header', {
|
||||
middleware: hidePoweredBy(),
|
||||
shouldBe: undefined
|
||||
})
|
||||
|
||||
test('allows you to explicitly set the header', {
|
||||
middleware: hidePoweredBy({ setTo: 'steampowered' }),
|
||||
shouldBe: 'steampowered'
|
||||
})
|
||||
|
||||
it('names its function and middleware', function () {
|
||||
assert.equal(hidePoweredBy.name, 'hidePoweredBy')
|
||||
assert.equal(hidePoweredBy().name, 'hidePoweredBy')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user