1.6 KiB
1.6 KiB
id | challengeType | forumTopicId | localeTitle |
---|---|---|---|
587d8247367417b2b2512c37 | 2 | 301580 | 使用 helmet.hidePoweredBy() 隐藏潜在的危险信息 |
Description
X-Powered-By: Express
默认情况下会添加到所有响应的 header。不过 helmet.hidePoweredBy()
中间件可以帮你把 header 中的 X-Powered-By 字段移除。你甚至可以把它设置成其它的值来骗过黑客,比如 app.use(helmet.hidePoweredBy({ setTo: 'PHP 4.2.0' }))
Instructions
Tests
tests:
- text: 应正确地加载 helmet.hidePoweredBy() 中间件
testString: getUserInput => $.get(getUserInput('url') + '/_api/app-info').then(data => { assert.include(data.appStack, 'hidePoweredBy'); assert.notEqual(data.headers['x-powered-by'], 'Express')}, xhr => { throw new Error(xhr.responseText); })
Challenge Seed
Solution
/**
Backend challenges don't need solutions,
because they would need to be tested against a full working project.
Please check our contributing guidelines to learn more.
*/