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

Add new PlainTextString type to ensure all passwords are valid UTF-8 #2070

Closed
wants to merge 1 commit into from

Conversation

film42
Copy link

@film42 film42 commented Dec 9, 2020

Issue Addressed

Issue #1205
Feedback from PR #1217
This supersedes my previous PR #1770 .

Proposed Changes

  1. This uses fs::read_to_string to enforce utf8 when dealing with reading passwords from files.
  2. In my previous PR I tried to change the inner value of PlainText(Vec<u8>) to become PlainText(String). This was not possible because I found existing (and valid) instances where PlainText contained invalid utf8. I do like the idea of a PlainTextString though, so this PR introduces a new and more specific type, PlainTextString(String). It might be a little clumsy to have two different PlainText types, but I think it makes sense.
  3. There are a few methods that take a password as a &[u8], and I switched some (but not all) to use the new PlainTextString. Happy to remove what I added if you would like these changed in a followup PR.
  4. The PlainTextString type uses an unsafe block to make as_mut_bytes work. This will panic if the caller of this method changes the internal bytes to become invalid utf8. Any ideas around making this more sound?

Additional Info

I mentioned this in the other PR but I'm relatively new to rust, so don't hesitate to add lots of feedback!

@realbigsean
Copy link
Member

would you mind changing the target branch from stable to unstable ? 🙂

@paulhauner paulhauner changed the base branch from stable to unstable January 14, 2021 22:18
@paulhauner
Copy link
Member

would you mind changing the target branch from stable to unstable ? slightly_smiling_face

Done :)

@film42
Copy link
Author

film42 commented Jan 15, 2021

Thanks @paulhauner !

bors bot pushed a commit that referenced this pull request Mar 14, 2021
## Issue Addressed

#2224

## Proposed Changes

Add a `--password-file` option to the `lighthouse account validator import` command. The flag requires `--reuse-password` and will copy the password over to the `validator_definitions.yml` file. I used #2070 as a guide for validating the password as UTF-8 and stripping newlines.

## Additional Info



Co-authored-by: realbigsean <[email protected]>
bors bot pushed a commit that referenced this pull request Mar 17, 2021
## Issue Addressed

#2224

## Proposed Changes

Add a `--password-file` option to the `lighthouse account validator import` command. The flag requires `--reuse-password` and will copy the password over to the `validator_definitions.yml` file. I used #2070 as a guide for validating the password as UTF-8 and stripping newlines.

## Additional Info



Co-authored-by: realbigsean <[email protected]>
@paulhauner
Copy link
Member

I'm going to close this since it's been open a long time. My apologies for not getting to a review.

This PR will remain and the issue will be tracked at #1205.

Please feel free to pick this up again, if you'd like!

@paulhauner paulhauner closed this Jan 28, 2022
@film42
Copy link
Author

film42 commented Jan 28, 2022

Thanks for all you do, Paul! <3

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