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

[SM-1371] Expose a new generate_secret function #936

Closed
wants to merge 6 commits into from

Conversation

coltonhurst
Copy link
Member

@coltonhurst coltonhurst commented Aug 3, 2024

๐ŸŽŸ๏ธ Tracking

https://bitwarden.atlassian.net/browse/SM-1371

๐Ÿ“” Objective

Adds a new function to the bitwarden-sm crate, allowing the user to generate a secret value. This is just a wrapper around the internal password generation functionality from bitwarden-generators.

This PR also fixes typos in crates/bitwarden-generators/src/password.rs.

Alternate solution without the abstraction layer: #986

โฐ 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

@coltonhurst coltonhurst self-assigned this Aug 3, 2024
Copy link
Contributor

github-actions bot commented Aug 3, 2024

Logo
Checkmarx One โ€“ Scan Summary & Details โ€“ e46ed826-107a-4abb-8555-16ee68cab1b6

No New Or Fixed Issues Found

Copy link

codecov bot commented Aug 3, 2024

Codecov Report

Attention: Patch coverage is 0% with 43 lines in your changes missing coverage. Please review.

Project coverage is 57.80%. Comparing base (723ef32) to head (7dc4bb1).
Report is 1 commits behind head on main.

Files Patch % Lines
...es/bitwarden-sm/src/generators/secret_generator.rs 0.00% 27 Missing โš ๏ธ
crates/bitwarden-sm/src/client_generators.rs 0.00% 12 Missing โš ๏ธ
crates/bitwarden-json/src/client.rs 0.00% 3 Missing โš ๏ธ
crates/bitwarden-json/src/command.rs 0.00% 1 Missing โš ๏ธ
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #936      +/-   ##
==========================================
- Coverage   57.98%   57.80%   -0.19%     
==========================================
  Files         197      199       +2     
  Lines       13647    13690      +43     
==========================================
  Hits         7913     7913              
- Misses       5734     5777      +43     

โ˜” View full report in Codecov by Sentry.
๐Ÿ“ข Have feedback on the report? Share it here.

@coltonhurst coltonhurst marked this pull request as ready for review August 8, 2024 23:02
@coltonhurst coltonhurst requested a review from a team as a code owner August 8, 2024 23:02
Copy link
Contributor

@Thomas-Avery Thomas-Avery left a comment

Choose a reason for hiding this comment

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

Looks good, one thing to take a look at.


/// When set to true, the generated secret will not contain ambiguous characters.
/// The ambiguous characters are: I, O, l, 0, 1
pub avoid_ambiguous: bool, // TODO: Should we rename this to include_all_characters?
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
pub avoid_ambiguous: bool, // TODO: Should we rename this to include_all_characters?
pub avoid_ambiguous: bool,

๐Ÿ’ญ
If I'm understanding this comment correctly, include_all_characters would be the inverse of avoid_ambigous?

If include_all_characters is set to true I would expect I, O, l, 0, 1 to be used.
If avoid_ambigous is set to true I would expect I, O, l, 0, 1 NOT to be used.

My thought is to leave it the same as the PasswordGeneratorRequest.

Regardless of what we go with, the TODO should be removed to avoid future confusion.

Copy link
Member

@Hinton Hinton left a comment

Choose a reason for hiding this comment

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

I would propose just exposing the password and passphrase generator with the same API as the password manager. That removes the maintenance burden of this functionality from the SM team and ensures it will accurately match what's available in the password manager.

coltonhurst added a commit that referenced this pull request Aug 23, 2024
## ๐ŸŽŸ๏ธ Tracking

https://bitwarden.atlassian.net/browse/SM-1371

## ๐Ÿ“” Objective

Exposes the `password` generator function for generating secrets.

This PR also fixes typos in
`crates/bitwarden-generators/src/password.rs`.

Alternate solution with an abstraction layer between SM and Bitwarden
core generation functionality: #936

## โฐ 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

<!-- Suggested interactions but feel free to use (or not) as you desire!
-->

- ๐Ÿ‘ (`:+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
@coltonhurst
Copy link
Member Author

Closing due to alternate solution we are going with here:

#986

@coltonhurst coltonhurst deleted the sm/sm-1371_part1 branch August 26, 2024 13:30
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