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

tests(smoke): verify CSP violations caused by lighthouse #12391

Merged
merged 9 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lighthouse-cli/test/fixtures/csp.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<!--
* Copyright 2021 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-->
<html>
adamraine marked this conversation as resolved.
Show resolved Hide resolved
<head>
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ function headersParam(headers) {
return new URLSearchParams([['extra_header', headerString]]).toString();
}

// Only allow the empty script with the source map.
const blockAllExceptInlineScriptCsp = headersParam([[
'Content-Security-Policy',
'default-src \'none\'; script-src \'unsafe-inline\'',
`default-src 'none'; script-src 'sha256-qZLV55/xxILbIrha9pgX0OdkZMhOlaIgfpEo/6Dly2U='`,
Copy link
Collaborator

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.

Copy link
Member Author

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.

]]);

/**
Expand Down