2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
id: 587d8248367417b2b2512c3b
|
2021-07-15 13:04:11 +05:30
|
|
|
title: 使用 helment.ieNoOpen() 防止 IE 打开不受信任的 HTML
|
2018-10-10 18:03:03 -04:00
|
|
|
challengeType: 2
|
2020-09-17 03:53:22 -07:00
|
|
|
forumTopicId: 301584
|
2021-01-13 03:31:00 +01:00
|
|
|
dashedName: prevent-ie-from-opening-untrusted-html-with-helmet-ienoopen
|
2018-10-10 18:03:03 -04:00
|
|
|
---
|
|
|
|
|
2020-12-16 00:37:30 -07:00
|
|
|
# --description--
|
2018-10-10 18:03:03 -04: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
|
|
|
有些网站会下载不安全的 HTML 文件。 某些版本的 IE 默认情况下还会在你网站的作用域下打开这些 HTML 文件。 换句话说,这些不安全的 HTML 页面可以在你的网站做恶意行为。 我们可以通过中间件来设置 header 中的 X-Download-Options 字段,让它的值为 noopen。 这样就可以防止 IE 在不信任的网站下执行下载的文件。
|
2021-02-06 04:42:36 +00:00
|
|
|
|
|
|
|
# --instructions--
|
|
|
|
|
2021-07-15 13:04:11 +05:30
|
|
|
应正确加载 `helmet.ieNoOpen()` 中间件
|
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.ieNoOpen() 中间件应正确安装。
|
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, 'ienoopen');
|
|
|
|
assert.equal(data.headers['x-download-options'], 'noopen');
|
|
|
|
},
|
|
|
|
(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.
|
|
|
|
*/
|
|
|
|
```
|