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

Check if we can load a surrogate even if the integrity mismatches. #43

Merged
merged 2 commits into from
Jul 16, 2021
Merged
Changes from all 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
12 changes: 12 additions & 0 deletions privacy-protections/surrogates/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ const surrogates = {
test: () => { return !!(window.ga && Object.keys(window.ga.create()).length === 0); },
cleanUp: () => { delete window.ga; }
},
'google-analytics.com/analytics.js broken integrity': {
url: 'https://google-analytics.com/analytics.js',
crossOrigin: 'anonymous',
integrity: 'sha512-1xNTXD/ZeaKg/Xjb6De9la7CXo5gC1lMk+beyKo691KJrjlj0HbZG6frzK0Wo6bm96i9Cp6w/WB4vSN/8zDBLQ==',
notes: 'Surrogate will fail to load due to integrity check. We think this check should not apply to extensions.',
shouldFail: false,
test: () => { return !!(window.ga && Object.keys(window.ga.create()).length === 0); },
Copy link
Member

Choose a reason for hiding this comment

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

This will be green if surrogate successfully loads, right? It will still be red if extension is disabled and original loads?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, although the integrity isn't valid also so shouldn't pass either.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AKA this should only pass if the extension redirecting to a local extension resource is carved out within the browser code

cleanUp: () => { delete window.ga; }
},
'google-analytics.com/analytics.js': {
url: 'https://google-analytics.com/analytics.js',
shouldFail: false,
Expand All @@ -77,6 +86,9 @@ const surrogates = {
if (testData.crossOrigin) {
s.crossOrigin = testData.crossOrigin;
}
if (testData.integrity) {
s.integrity = testData.integrity;
}

s.onload = () => {
updateTable({ name, testData });
Expand Down