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

[PM-14911] Fix DDG IPC errors where big messages are split #11987

Merged
merged 3 commits into from
Nov 20, 2024

Conversation

dani-garcia
Copy link
Member

@dani-garcia dani-garcia commented Nov 13, 2024

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-14911

📔 Objective

The IPC connection code was assuming that each call to read in the IPC socket would return one and only one message. This is incorrect for multiple reasons:

  • The call is allowed to not fill the buffer completely, which could split the messages into multiple read calls if they're too big. This is the problem we're having with DDG: when trying to load a page with more than 16 entries or so, the message would go over the 8192 byte size, which seems to be the maximum for a single read, regardless of the provided buffer size (1MB)
  • The call can return more than one message if they were sent very close together and under the size limit, and we'd process them as one single message. The issues with connection reliability that we had might be related to this, as on account setup we send a fair amount of messages.

We haven't noticed this before as the messages we send for biometrics are well under the limit, plus we don't send them very frequently.

To fix this, we can wrap the IPC stream in a LengthDelimitedCodec, this codec will send each message with their length as a prefix, and make sure to split the messages correctly, independently of how the multiple read calls might split them. We're already using this codec for the stdin/stdout of desktop_proxy as that is what the Native Messaging Host spec requires, so might as well do it here too. Big points to tokio for how flexible and easy to use the codec implementation is.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@dani-garcia dani-garcia marked this pull request as ready for review November 13, 2024 16:53
@dani-garcia dani-garcia requested a review from a team as a code owner November 13, 2024 16:53
Copy link

codecov bot commented Nov 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 33.48%. Comparing base (d875ded) to head (3451a35).
Report is 28 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11987      +/-   ##
==========================================
- Coverage   33.49%   33.48%   -0.01%     
==========================================
  Files        2846     2846              
  Lines       89197    89197              
  Branches    17003    17003              
==========================================
- Hits        29874    29867       -7     
- Misses      56970    56977       +7     
  Partials     2353     2353              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Contributor

github-actions bot commented Nov 13, 2024

Logo
Checkmarx One – Scan Summary & Details5f865b46-5a43-4841-8cd0-856c880ed990

Fixed Issues

Severity Issue Source File / Package
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members.component.html: 50
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members.component.html: 45
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members.component.html: 50
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members.component.html: 55
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 40
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 35
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 40
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health-members-uri.component.html: 45
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 50
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 45
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 40
MEDIUM Client_Privacy_Violation /apps/web/src/app/tools/access-intelligence/password-health.component.html: 45
MEDIUM Client_Privacy_Violation /libs/vault/src/components/totp-countdown/totp-countdown.component.ts: 14
MEDIUM Client_Privacy_Violation /libs/vault/src/components/totp-countdown/totp-countdown.component.ts: 15
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop-beta.yml: 667
MEDIUM Unpinned Actions Full Length Commit SHA /build-cli.yml: 421
MEDIUM Unpinned Actions Full Length Commit SHA /repository-management.yml: 193
MEDIUM Unpinned Actions Full Length Commit SHA /release-browser.yml: 43
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop-beta.yml: 247
MEDIUM Unpinned Actions Full Length Commit SHA /build-web.yml: 204
MEDIUM Unpinned Actions Full Length Commit SHA /release-web.yml: 56
MEDIUM Unpinned Actions Full Length Commit SHA /build-desktop.yml: 1381
MEDIUM Unpinned Actions Full Length Commit SHA /repository-management.yml: 113
MEDIUM Unpinned Actions Full Length Commit SHA /repository-management.yml: 312
MEDIUM Unpinned Actions Full Length Commit SHA /brew-bump-desktop.yml: 25
MEDIUM Unpinned Actions Full Length Commit SHA /repository-management.yml: 378
MEDIUM Unpinned Actions Full Length Commit SHA /build-web.yml: 314
MEDIUM Unpinned Actions Full Length Commit SHA /publish-cli.yml: 140
MEDIUM Unpinned Actions Full Length Commit SHA /retrieve-current-desktop-rollout.yml: 22
MEDIUM Unpinned Actions Full Length Commit SHA /release-cli.yml: 58
MEDIUM Unpinned Actions Full Length Commit SHA /build-desktop.yml: 318
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop.yml: 93
MEDIUM Unpinned Actions Full Length Commit SHA /release-browser.yml: 95
MEDIUM Unpinned Actions Full Length Commit SHA /publish-cli.yml: 103
MEDIUM Unpinned Actions Full Length Commit SHA /crowdin-pull.yml: 34
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop.yml: 70
MEDIUM Unpinned Actions Full Length Commit SHA /deploy-web.yml: 269
MEDIUM Unpinned Actions Full Length Commit SHA /deploy-web.yml: 221
MEDIUM Unpinned Actions Full Length Commit SHA /build-desktop.yml: 1332
MEDIUM Unpinned Actions Full Length Commit SHA /staged-rollout-desktop.yml: 28
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop-beta.yml: 50
MEDIUM Unpinned Actions Full Length Commit SHA /deploy-web.yml: 190
MEDIUM Unpinned Actions Full Length Commit SHA /release-cli.yml: 43
MEDIUM Unpinned Actions Full Length Commit SHA /publish-desktop.yml: 121
MEDIUM Unpinned Actions Full Length Commit SHA /build-desktop.yml: 928
MEDIUM Unpinned Actions Full Length Commit SHA /repository-management.yml: 214
MEDIUM Unpinned Actions Full Length Commit SHA /crowdin-pull.yml: 40
MEDIUM Unpinned Actions Full Length Commit SHA /repository-management.yml: 260
MEDIUM Unpinned Actions Full Length Commit SHA /repository-management.yml: 207
MEDIUM Unpinned Actions Full Length Commit SHA /repository-management.yml: 200
MEDIUM Unpinned Actions Full Length Commit SHA /release-web.yml: 40
MEDIUM Unpinned Actions Full Length Commit SHA /release-desktop.yml: 43
MEDIUM Unpinned Actions Full Length Commit SHA /build-browser.yml: 392
MEDIUM Unpinned Actions Full Length Commit SHA /publish-web.yml: 43
MEDIUM Unpinned Actions Full Length Commit SHA /publish-desktop.yml: 244
MEDIUM Unpinned Actions Full Length Commit SHA /version-auto-bump.yml: 40
MEDIUM Unpinned Actions Full Length Commit SHA /publish-desktop.yml: 195
MEDIUM Unpinned Actions Full Length Commit SHA /build-browser.yml: 436
MEDIUM Unpinned Actions Full Length Commit SHA /publish-cli.yml: 180
MEDIUM Unpinned Actions Full Length Commit SHA /repository-management.yml: 173
MEDIUM Unpinned Actions Full Length Commit SHA /build-web.yml: 283
MEDIUM Unpinned Actions Full Length Commit SHA /build-web.yml: 362
LOW Angular_Usage_of_Unsafe_DOM_Sanitizer /libs/components/src/avatar/avatar.component.ts: 80
LOW Angular_Usage_of_Unsafe_DOM_Sanitizer /apps/desktop/src/app/components/avatar.component.ts: 75
LOW Client_Hardcoded_Domain /apps/web/src/app/billing/shared/payment/payment.component.ts: 73
LOW Client_Hardcoded_Domain /apps/web/src/app/billing/shared/payment/payment.component.ts: 73
LOW Client_JQuery_Deprecated_Symbols /libs/importer/src/services/import.service.ts: 467

@dani-garcia dani-garcia force-pushed the ps/fix-ddg-ipc-big-messages branch from a50a6e5 to 049d51c Compare November 13, 2024 17:50
@dani-garcia dani-garcia changed the title Fix IPC errors with DDG caused by big messages being split [PM-14911] Fix DDG IPC errors where big messages are split Nov 14, 2024
@djsmith85 djsmith85 linked an issue Nov 14, 2024 that may be closed by this pull request
1 task
# Conflicts:
#	apps/desktop/desktop_native/core/src/ipc/server.rs
@dani-garcia dani-garcia merged commit 079f84e into main Nov 20, 2024
38 checks passed
@dani-garcia dani-garcia deleted the ps/fix-ddg-ipc-big-messages branch November 20, 2024 09:55
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.

Cannot connect BitWarden and DuckDuckGo on macOS
2 participants