-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
tests(smoke): verify CSP violations caused by lighthouse #12391
Conversation
}, | ||
SourceMaps: [{ | ||
// TODO: Fix frame-src violation when using iframe fetcher. | ||
// Doesn't trigger a CSP violation because iframe is injected after InspectorIssues gatherer finishes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we move InspectorIssues
earlier in the config so CSP violations caused by Lighthouse aren't in the report.
Conversely, we could move InspectorIssues
to the end so it catches issues caused by SourceMaps
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that even work since InspectorIssues
stops listening in afterPass
, and some (all?) of these issues come from snapshot
?
... so it catches issues caused by SourceMaps.
nbd if this is just the iframe fetcher, which will be removed soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that even work since InspectorIssues stops listening in afterPass, and some (all?) of these issues come from snapshot?
In current LH flow, snapshot
isn't a special phase it's just immediately called by the afterPass
. You have an astute observation though that in FR this isn't actually a problem because snapshot is always called after afterTimespan
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sweeeet, nice work!
lighthouse-cli/test/smokehouse/test-definitions/csp/csp-expectations.js
Outdated
Show resolved
Hide resolved
}, | ||
SourceMaps: [{ | ||
// TODO: Fix frame-src violation when using iframe fetcher. | ||
// Doesn't trigger a CSP violation because iframe is injected after InspectorIssues gatherer finishes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that even work since InspectorIssues stops listening in afterPass, and some (all?) of these issues come from snapshot?
In current LH flow, snapshot
isn't a special phase it's just immediately called by the afterPass
. You have an astute observation though that in FR this isn't actually a problem because snapshot is always called after afterTimespan
;)
const blockAllExceptInlineScriptCsp = headersParam([[ | ||
'Content-Security-Policy', | ||
'default-src \'none\'; script-src \'unsafe-inline\'', | ||
`default-src 'none'; script-src 'sha256-qZLV55/xxILbIrha9pgX0OdkZMhOlaIgfpEo/6Dly2U='`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide instructions on how to generate this hash. Or, generate it dynamically based on csp.html.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added instructions. We could also use a hardcoded "nonce" for this test case.
// https://github.com/GoogleChrome/lighthouse/pull/12044#issuecomment-788274938 | ||
// | ||
// Fixed with new fetcher using M92. | ||
_maxChromiumMilestone: 91, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the new fetcher, we have our first fixed case 🎉 !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I think we'd benefit from doing the same with the dbw tester page. Making the CSP that works for that would be more work, but would allow Lighthouse gatherers that depend on certain junk on the page to do their thing and expose other CSP issues.
Part of #12378