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

[PS-11868] Require key for enc string decryption #10981

Merged
merged 9 commits into from
Sep 30, 2024

Conversation

MGibson1
Copy link
Member

🎟️ Tracking

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

📔 Objective

Adds a new interface to enc string that requires a key and EncryptService to encrypt, rather than trying to determine keys and grabbing services from a global container.

Additionally uses this interface through the base Domain class that also requires a key and encrypt service. Additionally, this new interface is type safe to decrypt only EncStrings on the object and avoids mutation of a passed in object.

⏰ 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

Copy link
Member Author

Choose a reason for hiding this comment

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

These folder updates are example usages. We can remove from this PR to limit scope.

encryptedProperties: TEncryptedKeys[],
key: SymmetricCryptoKey,
encryptService: EncryptService,
_: Constructor<TThis> = this.constructor as Constructor<TThis>,
Copy link
Member Author

@MGibson1 MGibson1 Sep 10, 2024

Choose a reason for hiding this comment

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

The type inferrer has a lot of trouble with this type on derived classes. It seems to always resolve to the parent class when using in the derived class. This pattern allows us to specify the specific Domain implementation by providing a constructor as an optional 5th argument. See the Folder changes for an example of its value.

Copy link

codecov bot commented Sep 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.16%. Comparing base (3be5c48) to head (d47b2ae).
Report is 134 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10981      +/-   ##
==========================================
+ Coverage   35.14%   35.16%   +0.02%     
==========================================
  Files        2690     2690              
  Lines       83666    83692      +26     
  Branches    15887    15890       +3     
==========================================
+ Hits        29403    29429      +26     
  Misses      53297    53297              
  Partials      966      966              

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

Copy link
Contributor

github-actions bot commented Sep 10, 2024

Logo
Checkmarx One – Scan Summary & Details24d8846a-96ae-4a55-895e-de047b0bf12a

New Issues

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Client_Privacy_Violation /apps/web/src/connectors/webauthn-fallback.ts: 116 Attack Vector

Fixed Issues

Severity Issue Source File / Package
LOW Client_DOM_Open_Redirect /apps/browser/src/vault/popup/components/vault/attachments.component.ts: 33

Copy link
Member

@justindbaur justindbaur left a comment

Choose a reason for hiding this comment

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

Just one question on if we should throw an error sooner in one place.

Copy link
Member

@gbubemismith gbubemismith left a comment

Choose a reason for hiding this comment

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

This looks good 🚀

@MGibson1 MGibson1 added needs-qa Marks a PR as requiring QA approval and removed needs-qa Marks a PR as requiring QA approval labels Sep 26, 2024
@MGibson1 MGibson1 merged commit a6b9088 into main Sep 30, 2024
67 of 68 checks passed
@MGibson1 MGibson1 deleted the ps-11868/require-key-for-enc-strings branch September 30, 2024 13:34
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.

3 participants