Skip to content

Replace password string with proper class#2925

Merged
samuel40791765 merged 2 commits intoaws:mainfrom
samuel40791765:clean-up-cli
Jan 5, 2026
Merged

Replace password string with proper class#2925
samuel40791765 merged 2 commits intoaws:mainfrom
samuel40791765:clean-up-cli

Conversation

@samuel40791765
Copy link
Copy Markdown
Contributor

@samuel40791765 samuel40791765 commented Jan 1, 2026

The bssl::UniquePtr<std::string> pattern that we're using for passwords in the CLI tool is a bit confusing. C++ std::string class automatically manages its own memory.

This was an attempt to manage the cleansing of passwords/secrets once they were out of scope, but the existing scheme forces the developer to have to remember to wrap Password strings with these pointers. Replacing the bssl::UniquePtr<std::string> pattern with a proper Password class should enforce correct usage through stronger typing and make the code more readable.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@samuel40791765 samuel40791765 requested a review from a team as a code owner January 1, 2026 02:00
@samuel40791765 samuel40791765 marked this pull request as draft January 1, 2026 02:11
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 1, 2026

Codecov Report

❌ Patch coverage is 97.54601% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.22%. Comparing base (06ad7f9) to head (a068b58).

Files with missing lines Patch % Lines
tool-openssl/pkcs8.cc 75.00% 3 Missing ⚠️
tool-openssl/pass_util.cc 97.56% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2925      +/-   ##
==========================================
+ Coverage   78.21%   78.22%   +0.01%     
==========================================
  Files         690      690              
  Lines      118737   118733       -4     
  Branches    16679    16679              
==========================================
+ Hits        92865    92875      +10     
+ Misses      24983    24970      -13     
+ Partials      889      888       -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samuel40791765 samuel40791765 changed the title Remove redundant memory management of std::string Replace password string with proper class Jan 1, 2026
@samuel40791765 samuel40791765 marked this pull request as ready for review January 1, 2026 02:54
Password& operator=(const Password& other) {
if (this != &other) {
secure_clear();
data_ = other.data_;
Copy link
Copy Markdown
Contributor

@WillChilds-Klein WillChilds-Klein Jan 2, 2026

Choose a reason for hiding this comment

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

making a note, no change requested -- confirmed that std::string's assignment operator ensures that other.data_'s

value is either copied (1) or moved (5) if different from *this (if moved, str is left in an unspecified but valid state).

so no need to worry about duplicate ownership after this assignment

@samuel40791765 samuel40791765 enabled auto-merge (squash) January 5, 2026 22:57
@samuel40791765 samuel40791765 merged commit 9e34107 into aws:main Jan 5, 2026
400 checks passed
@samuel40791765 samuel40791765 deleted the clean-up-cli branch January 6, 2026 05:27
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.

4 participants