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

Firefox data import improvements #622

Merged
merged 8 commits into from
Jun 24, 2022
Merged

Conversation

samsymons
Copy link
Collaborator

@samsymons samsymons commented Jun 22, 2022

Task/Issue URL: https://app.asana.com/0/1199230911884351/1202491428238974/f
Tech Design URL:
CC: @ayoy

Description:

This PR makes three changes:

  1. Adds new test databases for Firefox 70 and updates the key reader to understand them. This involved checking whether 3DES can be used to decrypt the keys before falling back to AES.
  2. Updated the Firefox bookmarks reader to not enforce a specific set of directories. Now if one of these directories is missing, the bookmark importer will still read from the others.
  3. When reading Firefox bookmarks, the importer now looks for the root folder's GUID instead of guessing that it has an ID of 0.

Steps to test this PR:

  1. Run Firefox import against your local install and check that it succeeds; try a few different options, such as with and without a Primary Password set on your logins database
  2. Run the other browser importers to verify that they haven't regressed

Testing checklist:

  • Test with Release configuration
  • Test proper deallocation of tabs
  • Make sure committed submodule changes are desired

Internal references:

Software Engineering Expectations
Technical Design Template
When ready for review, remember to post the PR in MM

@samsymons samsymons requested a review from ayoy June 22, 2022 22:42
Copy link
Collaborator

@ayoy ayoy left a comment

Choose a reason for hiding this comment

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

Hey @samsymons! This code looks stellar and does the job. I tested with Firefox 101 and the import works flawlessly with and without a password. Also tested Chrome import and it still works as it should. Not approving the PR yet due to our private chat about little UI/UX issues (not caused by your patch) that you offered to have a look at.

Comment on lines +301 to +303
if newChildViewController === currentChildViewController {
return
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is to fix some cases where we were trying to add a child view controller repeatedly. You can still see this warning when navigating back and forth in the import flow, but this check improves it.

@@ -66,6 +66,8 @@ final class FirefoxDataImporter: DataImporter {
case .decryptionFailed: completion(.failure(.logins(.cannotDecryptFile)))
case .failedToTemporarilyCopyFile: completion(.failure(.logins(.failedToTemporarilyCopyFile)))
}

return
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without this return, the import data call continues ahead and hits the completion block at the end.

To be honest: I'm not happy with this API at all any more. 🙂 All of the code in here is synchronous, yet this function uses an async callback, so I would eventually like to replace this to use a return value instead of a callback. That would make it impossible to have bugs like this where callbacks are able to be called repeatedly by one invocation of this function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

(The other thing I don't like is that an error with login import stops the function in its tracks, instead of allowing it to try to at least import bookmarks too. But, that's an improvement for another day... along with a SwiftUI rewrite of the UI 😬)

@samsymons
Copy link
Collaborator Author

Added some tests to the FirefoxDataImporter, but it's missing the login path entirely – I've just run out of time for the day unfortunately. To add tests for the login case, we'll need to dependency inject the FirefoxLoginReader and then use it in tandem with the MockLoginImporter.

I also took a look at converting this function from asynchronous to synchronous, but realized we have the HTML import case that does perform login in the background. Instead, it would be better to convert this class to Swift Concurrency in the future. Next Special Days I'd like to take a proper pass and fix all of these issues.

Copy link
Collaborator

@ayoy ayoy left a comment

Choose a reason for hiding this comment

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

Thanks a lot @samsymons! I noticed that the newly added tests were failing because they relied on the real Firefox data directory (not present in the CI). I updated the tests to take fake data directory which fixed tests 👍

@ayoy ayoy merged commit e682167 into develop Jun 24, 2022
@ayoy ayoy deleted the sam/firefox-data-import-improvements branch June 24, 2022 07:52
samsymons added a commit that referenced this pull request Jun 29, 2022
* develop:
  Update sparkle-sandbox.sh README to highlight proper usage
  Replace altool with notarytool in release build script (#623)
  Update embedded data
  Bump version to 0.26.4
  Update homepage history feed after burning (#620)
  Firefox data import improvements (#622)
  Set version to 0.26.3
  Microsoft logo for address bar animation (#618)
  Google spreadsheets login fix (#616)
samsymons added a commit that referenced this pull request Jul 4, 2022
# By Dominik Kapusta (5) and others
# Via Dominik Kapusta (1) and GitHub (1)
* develop:
  Use updated BSK branch (#627)
  Version 0.26.5
  Embedded files updated
  Update BSK for iOS app group (#630)
  Recently Closed Menu Item (#617)
  Close dashboard when closing tab with cmd + w (#628)
  chore(deps): bump Autofill to 4.7.0 (#631)
  Handle legacy crash logs and use proper architecture in symbolicate.js (#621)
  Detect when Chrome login fails due to keychain prompt denial (#633)
  Correctly display unprotected sites on dashboard (#624)
  Update homefavicon (#625)
  Update sparkle-sandbox.sh README to highlight proper usage
  Replace altool with notarytool in release build script (#623)
  Update embedded data
  Bump version to 0.26.4
  Update homepage history feed after burning (#620)
  Firefox data import improvements (#622)
  Set version to 0.26.3

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants