Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Correctly detect insecure CSP when default-src is missing. #4594

Merged
merged 1 commit into from
Nov 15, 2022

Conversation

Rob--W
Copy link
Member

@Rob--W Rob--W commented Nov 15, 2022

Fixes #4578.

@Rob--W Rob--W force-pushed the csp-fix-5 branch 2 times, most recently from bab37e0 to 214a7b4 Compare November 15, 2022 14:21
Copy link
Member

@willdurand willdurand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+wc

@@ -1922,12 +1919,13 @@ describe('ManifestJSONParser', () => {

const keys = Object.keys(contentSecurityPolicy);
for (let i = 0; i < keys.length; i++) {
expect(warningsV3[i].code).toEqual(messages.MANIFEST_CSP_UNSAFE_EVAL);
expect(warningsV3[i].message).toContain(
expect(warningsV3[i * 2].code).toEqual(messages.MANIFEST_CSP_UNSAFE_EVAL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe mention that we expect two codes for each key, and so first warning is MANIFEST_CSP_UNSAFE_EVAL and second warning is MANIFEST_CSP.

@@ -1888,6 +1883,8 @@ describe('ManifestJSONParser', () => {
expect(warnings[0].message).toEqual(
messages.manifestCspUnsafeEval('content_security_policy').message
);
expect(warnings[1].code).toEqual(messages.MANIFEST_CSP);
expect(warnings.length).toBe(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(warnings.length).toBe(2);
expect(warnings.length).toEqual(2);

}
expect(warningsV3.length).toBe(3);
expect(warningsV3.length).toBe(6);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(warningsV3.length).toBe(6);
expect(warningsV3.length).toEqual(6);

@codecov
Copy link

codecov bot commented Nov 15, 2022

Codecov Report

Base: 98.74% // Head: 98.74% // No change to project coverage 👍

Coverage data is based on head (89ec2a9) compared to base (aff320e).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4594   +/-   ##
=======================================
  Coverage   98.74%   98.74%           
=======================================
  Files          54       54           
  Lines        2859     2859           
  Branches      859      859           
=======================================
  Hits         2823     2823           
  Misses         36       36           
Impacted Files Coverage Δ
src/parsers/manifestjson.js 99.22% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Rob--W Rob--W merged commit 6d02796 into mozilla:master Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSP without default-src is incorrectly detected as secure
2 participants