Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Add a session migration for uphold fingerprinting #14178

Merged
merged 2 commits into from
May 22, 2018
Merged

Add a session migration for uphold fingerprinting #14178

merged 2 commits into from
May 22, 2018

Conversation

bsclifton
Copy link
Member

@bsclifton bsclifton commented May 18, 2018

Fixes #14152
Fixes #14204

Lays down foundation for #10488

Auditors: @diracdeltas, @darkdh

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed. (Ask a Brave employee to help if you cannot access this document.)

Test Plan:

Reviewer Checklist:

  • Request a security/privacy review as needed if one was not already requested.

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header

@bsclifton bsclifton added this to the 0.22.x Release 4 (Beta channel) milestone May 18, 2018
@bsclifton bsclifton self-assigned this May 18, 2018
@bsclifton bsclifton requested review from diracdeltas and darkdh May 18, 2018 22:40
let migrationNeeded = false

try {
migrationNeeded = compareVersions(data.lastAppVersion, '0.22.714') !== 1
Copy link
Member Author

@bsclifton bsclifton May 18, 2018

Choose a reason for hiding this comment

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

compareVersions will return -1 if less than 0.22.714 and 0 for 0.22.714. It can only be 1 if greater than 0.22.714 (and in that case, the migration won't run)

@bsclifton bsclifton requested a review from srirambv May 18, 2018 22:51
@diracdeltas
Copy link
Member

@bsclifton doesn't #14158 already fix the issue for most users? is this PR just so that users who set some non-default value for FP get set to allowAllFingerprinting?

i'm not sure the latter is desirable

@bsclifton
Copy link
Member Author

bsclifton commented May 20, 2018

@diracdeltas good question-

@srirambv can you please verify that our last 0.22.x Release 4 works UNLESS you have a site setting already set? I agree with Yan- I don't think it would be a good decision to overwrite existing settings

1. ex: have profile with live released version- you can visit uphold.com, etc but don't change site settings
2. Copy that same profile to our latest release (BETA)
3. Verify that exception for fingerprint is added

Maybe I mis-understood comment in #14152 (comment). The previous code SHOULD have covered all the cases we wanted

@bsclifton
Copy link
Member Author

I re-reviewed the code- the default site import only runs once actually:

if (!data.defaultSiteSettingsListImported) {
for (var i = 0; i < defaultSiteSettingsList.length; ++i) {
let setting = defaultSiteSettingsList[i]
if (!data.siteSettings[setting.pattern]) {
data.siteSettings[setting.pattern] = {}
}
let targetSetting = data.siteSettings[setting.pattern]
if (!targetSetting.hasOwnProperty[setting.name]) {
targetSetting[setting.name] = setting.value
}
}
data.defaultSiteSettingsListImported = true

@diracdeltas this code is needed... but we shouldn't overwrite the setting if it exists. Let me tweak the code a bit

@bsclifton
Copy link
Member Author

Code updated! Will only set a value if one isn't set... but will run once for any existing users upgrading from 0.22.714 (or earlier)

data.siteSettings[pattern] = {}
}
let targetSetting = data.siteSettings[pattern]
if (targetSetting.fingerprintingProtection == null) {
Copy link
Member

Choose a reason for hiding this comment

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

noting that this will still override the siteSetting if the global setting is set to 'blockAllFingerprinting'.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed with 321b208 😄 👍

@bsclifton
Copy link
Member Author

New commit added fixing #14204 - I forgot to include ? in the hostPattern 🤦‍♂️

// 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.lastAppVersion) {
Copy link
Member

@diracdeltas diracdeltas May 22, 2018

Choose a reason for hiding this comment

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

i think you want to check data.fingerprintingProtectionAll && data.fingerprintingProtectionAll.enabled?

Copy link
Member Author

Choose a reason for hiding this comment

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

After missing this, I fixed this and added some unit tests! 😄 Should cover most of the cases

Copy link
Member

@diracdeltas diracdeltas left a comment

Choose a reason for hiding this comment

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

lgtm thanks!

@NejcZdovc NejcZdovc merged commit ec60238 into brave:master May 22, 2018
NejcZdovc added a commit that referenced this pull request May 22, 2018
Add a session migration for uphold fingerprinting
NejcZdovc added a commit that referenced this pull request May 22, 2018
Add a session migration for uphold fingerprinting
@NejcZdovc
Copy link
Contributor

master ec60238
0.23 7e6a5cc
0.22 66d75eb

@bsclifton bsclifton deleted the session-migration-cleanup branch May 22, 2018 15:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants