Files
freeCodeCamp/curriculum/challenges/chinese-traditional/09-information-security/information-security-with-helmetjs/hide-potentially-dangerous-information-using-helmet.hidepoweredby.md

1.3 KiB

id, title, challengeType, forumTopicId, dashedName
id title challengeType forumTopicId dashedName
587d8247367417b2b2512c37 使用 helmet.hidePoweredBy() 隱藏潛在的危險信息 2 301580 hide-potentially-dangerous-information-using-helmet-hidepoweredby

--description--

請注意,本項目在這個 Repl.it 項目的基礎上進行開發。你也可以從 GitHub 上克隆。

如果黑客發現你的網站是用 Express 搭建的,那麼他們就可以利用 Express 或 Node 現存的漏洞來攻擊你的網站。 X-Powered-By: Express 默認在來自 Express 的每個請求中被髮送。 使用 helmet.hidePoweredBy() 中間件來移除 X-Powered-By 頭。

--hints--

應正確地安裝 helmet.hidePoweredBy() 中間件

(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);
    }
  );

--solutions--

/**
  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.
*/