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

chore: bulletproofing crypto box to cc migration (WPB-14250) 🍒 #3129

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Nov 26, 2024

StoryWPB-14250 [Android] implement fall guards for CC migration

This PR was automatically cherry-picked based on the following PR:

Original PR description:



PR Submission Checklist for internal contributors

  • The PR Title

    • conforms to the style of semantic commits messages¹ supported in Wire's Github Workflow²
    • contains a reference JIRA issue number like SQPIT-764
    • answers the question: If merged, this PR will: ... ³
  • The PR Description

    • is free of optional paragraphs and you have filled the relevant parts to the best of your ability

What's new in this PR?

Issues

When enabling core crypto storage, if there are any Proteus clients, we need to migrate them from CryptoBox.
Things usually don't go as planned, so we need to have a recovery plan in place.

Causes (Optional)

There might be some errors while migrating.

Solutions

Implement a recovery plan for this case:

  • Catch possible exceptions from migration, we were not handling it and assuming success
  • Perform logout, using a new LogoutReason, so we can act (cleanup) accordingly
    • Cleanup local crypto files
    • Cleanup from Metadata all related client info (retained id, current id, prekeys, etc.)
    • Set the refresh token to needs update.

If everything goes smoothly, the user will be prompted to login again, preserving their local history.

Dependencies (Optional)

Needs releases with:

  • GitHub link to other pull request

Testing

Test Coverage (Optional)

  • I have added automated test to this contribution

Notes (Optional)

Note

This approach seems "more correct", since if we try to create a new device only -as the ticket suggested- we will run into the issue of the refresh token not being valid anymore, since it was associated with the broken client that we were trying to migrate. And we can't associate the previous refresh token with a different client, we get a 403.

  • We will avoid other edge cases that we might not sure.
  • All login cases will be covered (2FA, SCIM, etc.)
  • We can expand this handling in the future (if we want) to other cases that we want to recover.

PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

* feat: cleaning all data if failure

* feat: cleaning all data if failure

* feat: clean up code

* feat: clean up code

* chore: add plan b, logout user

* chore: add plan b, logout user, cleanup code

* chore: cleanup code

* chore: cleanup code

* chore: cleanup code detekt

* chore: cleanup code detekt

* chore: remove exception for testing

* chore: tests for new branches

* chore: tests for new branches

* chore: solve layer issue

* chore: more test covereage

* chore: layering

* chore: solve missing reference

* fix: deadlock while cleanup

* fix: tests

* fix: tests detekt
@github-actions github-actions bot added cherry-pick PR is cherry-picking changes from another banch echoes/initiative: federation-wire-cloud Activate Federation with MLS on Wire Cloud type: chore 🧹 👕 size: L 🚨 Potential breaking changes labels Nov 26, 2024
Copy link
Contributor Author

github-actions bot commented Nov 27, 2024

Test Results

3 330 tests  +3   3 223 ✅ +3   5m 5s ⏱️ ±0s
  571 suites +2     107 💤 ±0 
  571 files   +2       0 ❌ ±0 

Results for commit c1eac7e. ± Comparison against base commit 786a7b8.

♻️ This comment has been updated with latest results.

Copy link
Contributor Author

@yamilmedina yamilmedina added this pull request to the merge queue Nov 27, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 69.23077% with 16 lines in your changes missing coverage. Please review.

Project coverage is 54.21%. Comparing base (786a7b8) to head (c1eac7e).

Files with missing lines Patch % Lines
.../kalium/logic/data/client/ProteusClientProvider.kt 60.00% 8 Missing ⚠️
...ture/client/ProteusMigrationRecoveryHandlerImpl.kt 72.72% 3 Missing ⚠️
.../com/wire/kalium/logic/data/logout/LogoutReason.kt 0.00% 2 Missing ⚠️
...om/wire/kalium/logic/data/session/SessionMapper.kt 0.00% 2 Missing ⚠️
...kalium/logic/sync/slow/SlowSyncCriteriaProvider.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3129      +/-   ##
===========================================
+ Coverage    54.14%   54.21%   +0.06%     
===========================================
  Files         1249     1250       +1     
  Lines        36281    36328      +47     
  Branches      3658     3658              
===========================================
+ Hits         19646    19695      +49     
+ Misses       15223    15220       -3     
- Partials      1412     1413       +1     
Files with missing lines Coverage Δ
...kalium/cryptography/exceptions/ProteusException.kt 50.00% <100.00%> (+2.00%) ⬆️
...om/wire/kalium/logic/feature/auth/LogoutUseCase.kt 95.52% <100.00%> (+2.41%) ⬆️
...lium/logic/feature/client/RegisterClientUseCase.kt 86.11% <100.00%> (+0.12%) ⬆️
.../com/wire/kalium/persistence/model/LogoutReason.kt 100.00% <100.00%> (ø)
...kalium/logic/sync/slow/SlowSyncCriteriaProvider.kt 80.55% <0.00%> (-2.31%) ⬇️
.../com/wire/kalium/logic/data/logout/LogoutReason.kt 0.00% <0.00%> (ø)
...om/wire/kalium/logic/data/session/SessionMapper.kt 48.10% <0.00%> (-1.25%) ⬇️
...ture/client/ProteusMigrationRecoveryHandlerImpl.kt 72.72% <72.72%> (ø)
.../kalium/logic/data/client/ProteusClientProvider.kt 38.33% <60.00%> (+38.33%) ⬆️

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 786a7b8...c1eac7e. Read the comment docs.

@datadog-wireapp
Copy link

Datadog Report

Branch report: chore/bulletproofing-cc-migration-rc-cherry-pick
Commit report: e52a1c3
Test service: kalium-jvm

✅ 0 Failed, 3223 Passed, 107 Skipped, 35.86s Total Time

Merged via the queue into develop with commit b7b4bd2 Nov 27, 2024
22 checks passed
@yamilmedina yamilmedina deleted the chore/bulletproofing-cc-migration-rc-cherry-pick branch November 27, 2024 10:52
yamilmedina added a commit that referenced this pull request Nov 27, 2024
yamilmedina added a commit that referenced this pull request Nov 28, 2024
…3136)

* chore: manual cherry pick of #3129

* fix: detekt

* chore: test mockative older version

* chore: empty commit bump

* chore: test mockative older version

* chore: update lib

* chore: empty commit bump

* chore: fix kalium ref

* chore: fix test

* chore: fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick PR is cherry-picking changes from another banch echoes/initiative: federation-wire-cloud Activate Federation with MLS on Wire Cloud 🚨 Potential breaking changes 👕 size: L type: chore 🧹
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants