2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: 587d8247367417b2b2512c37
|
2021-07-15 13:04:11 +05:30
|
|
|
title: 使用 helmet.hidePoweredBy() 隐藏潜在的危险信息
|
2018-10-10 18:03:03 -04:00
|
|
|
challengeType: 2
|
2020-09-17 03:53:22 -07:00
|
|
|
forumTopicId: 301580
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: hide-potentially-dangerous-information-using-helmet-hidepoweredby
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
2020-09-17 03:53:22 -07:00
|
|
|
|
2021-07-15 13:04:11 +05:30
|
|
|
请注意,本项目在[这个 Repl.it 项目](https://replit.com/github/freeCodeCamp/boilerplate-infosec)的基础上进行开发。你也可以从 [GitHub](https://github.com/freeCodeCamp/boilerplate-infosec/) 上克隆。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-07-15 13:04:11 +05:30
|
|
|
如果黑客发现你的网站是用 Express 搭建的,那么他们就可以利用 Express 或 Node 现存的漏洞来攻击你的网站。 `X-Powered-By: Express` 默认在来自 Express 的每个请求中被发送。 使用 `helmet.hidePoweredBy()` 中间件来移除 X-Powered-By 头。
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --hints--
|
2018-10-10 18:03:03 -04:00
|
|
|
|
2021-07-15 13:04:11 +05:30
|
|
|
应正确地安装 helmet.hidePoweredBy() 中间件
|
2018-10-10 18:03:03 -04:00
|
|
|
|
|
|
|
```js
|
2020-12-16 00:37:30 -07:00
|
|
|
(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);
|
|
|
|
}
|
|
|
|
);
|
2018-10-10 18:03:03 -04:00
|
|
|
```
|
2020-08-13 17:24:35 +02:00
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --solutions--
|
|
|
|
|
2021-01-13 03:31:00 +01:00
|
|
|
```js
|
|
|
|
/**
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
```
|