eggjs / egg-security

Security plugin for egg, force performance too.
MIT License
238 stars 43 forks source link

fix: fix referrer-policy enum check #50

Closed guoshencheng closed 5 years ago

guoshencheng commented 5 years ago

不知道是不是理解错了,这里的ALLOWED_POLICIES_ENUM是用于校验设定的referrer-policy是否合法的,而源代码

 if (policy in ALLOWED_POLICIES_ENUM) {
     throw new Error('"' + policy + '" is not available."');
 }

只有数组下标才会进入判断

比如 'origin' in ALLOWED_POLICIES_ENUM返回false 'oorigin' in ALLOWED_POLICIES_ENUM也返回false '0' in ALLOWED_POLICIES_ENUM返回true

这就失去了判断的意义

jtyjty99999 commented 5 years ago

我的坑。。这个是bug

codecov[bot] commented 5 years ago

Codecov Report

Merging #50 into master will increase coverage by 0.2%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #50     +/-   ##
=========================================
+ Coverage   95.92%   96.13%   +0.2%     
=========================================
  Files          30       30             
  Lines         491      491             
=========================================
+ Hits          471      472      +1     
+ Misses         20       19      -1
Impacted Files Coverage Δ
lib/middlewares/referrerPolicy.js 100% <100%> (+9.09%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6ba7024...0c6634c. Read the comment docs.

codecov[bot] commented 5 years ago

Codecov Report

Merging #50 into master will increase coverage by 0.2%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #50     +/-   ##
=========================================
+ Coverage   95.92%   96.13%   +0.2%     
=========================================
  Files          30       30             
  Lines         491      491             
=========================================
+ Hits          471      472      +1     
+ Misses         20       19      -1
Impacted Files Coverage Δ
lib/middlewares/referrerPolicy.js 100% <100%> (+9.09%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6ba7024...2a26ca4. Read the comment docs.

jtyjty99999 commented 5 years ago

+1

guoshencheng commented 5 years ago

这个PR还有什么问题么?

dead-horse commented 5 years ago

2.4.2