This repository has been archived by the owner on Dec 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 971
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14178 from bsclifton/session-migration-cleanup
Add a session migration for uphold fingerprinting
- Loading branch information
Showing
6 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const compareVersions = require('compare-versions') | ||
|
||
// per https://github.com/brave/browser-laptop/issues/14152 | ||
// add fingerprint exception for existing users for uphold.com | ||
module.exports = (data) => { | ||
// don't apply if: | ||
// - user chooses to block all fingerprinting (global setting) | ||
// - user is not upgrading from 0.22.714 or earlier | ||
if ((data.fingerprintingProtectionAll && data.fingerprintingProtectionAll.enabled) || | ||
!data.lastAppVersion) { | ||
return false | ||
} | ||
|
||
let migrationNeeded = false | ||
|
||
try { | ||
migrationNeeded = compareVersions(data.lastAppVersion, '0.22.714') !== 1 | ||
} catch (e) {} | ||
|
||
if (migrationNeeded) { | ||
const pattern = 'https?://uphold.com' | ||
if (!data.siteSettings) { | ||
data.siteSettings = {} | ||
} | ||
if (!data.siteSettings[pattern]) { | ||
data.siteSettings[pattern] = {} | ||
} | ||
let targetSetting = data.siteSettings[pattern] | ||
if (targetSetting.fingerprintingProtection == null) { | ||
targetSetting.fingerprintingProtection = 'allowAllFingerprinting' | ||
} | ||
} | ||
|
||
return migrationNeeded | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
module.exports = (data) => { | ||
let migrations = [ | ||
require('./20180518_uphold') | ||
// TODO: put additional migrations here | ||
] | ||
|
||
migrations.forEach((migration) => { | ||
migration(data) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
/* global describe, it */ | ||
const assert = require('assert') | ||
|
||
const migration = require('../../../../app/migrations/20180518_uphold') | ||
|
||
require('../../braveUnit') | ||
|
||
describe('20180518_uphold migration', function () { | ||
it('does not run if global fingerprint protection is enabled', function () { | ||
let data = { | ||
fingerprintingProtectionAll: { | ||
enabled: true | ||
}, | ||
lastAppVersion: '0.22.714' | ||
} | ||
assert.equal(migration(data), false) | ||
}) | ||
|
||
it('does not run if last app version is missing (new installs)', function () { | ||
let data = {} | ||
assert.equal(migration(data), false) | ||
}) | ||
|
||
it('does not run if last app version is greater than 0.22.714', function () { | ||
let data = { | ||
lastAppVersion: '0.22.715' | ||
} | ||
assert.equal(migration(data), false) | ||
}) | ||
|
||
it('runs if last app version is 0.22.714', function () { | ||
let data = { | ||
lastAppVersion: '0.22.714' | ||
} | ||
assert.equal(migration(data), true) | ||
}) | ||
|
||
it('runs if last app version is older than 0.22.714', function () { | ||
let data = { | ||
lastAppVersion: '0.22.13' | ||
} | ||
assert.equal(migration(data), true) | ||
}) | ||
|
||
it('sets fingerprintingProtection for the site (if not already set)', function () { | ||
let data = { | ||
lastAppVersion: '0.22.13' | ||
} | ||
migration(data) | ||
assert.equal(data.siteSettings['https?://uphold.com'].fingerprintingProtection, 'allowAllFingerprinting') | ||
}) | ||
|
||
it('does not overwrite an existing fingerprintingProtection setting for the site', function () { | ||
let data = { | ||
lastAppVersion: '0.22.13', | ||
siteSettings: { | ||
'https?://uphold.com': { | ||
fingerprintingProtection: 'blockAllFingerprinting' | ||
} | ||
} | ||
} | ||
migration(data) | ||
assert.equal(data.siteSettings['https?://uphold.com'].fingerprintingProtection, 'blockAllFingerprinting') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters