sethvargo / go-password

A Golang library for generating high-entropy random passwords similar to 1Password or LastPass.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Randomly has (MISSING) inserted into the password.

TerminalFi opened this issue · comments

Issues generating passwords. Appears that occasionally the password is generated incorrectly.

Can't determine issue. I've tried with bash, sh, zsh

Alt

Hi @TheSecEng

Thank you for opening an issue. Can you help me understand what this image is showing? Are you referring to 12:24:04 line 2? Can you share your script with me please?

My best guess is that you're doing this:

log.Printf(myPassword)

When the generator generates a password, it might include special characters depending on your settings, including the % character, which has a special meaning in string formatting. If you get unlucky and get a password like:

abcd%sdajkl

The %s in that is interpreted as string interpolation and expects a value to the variadic Printf function. Since no value is given, it inserts (MISSING).

This is not a bug in go-password, this is how string formatting works in Go (and other languages).

You should either use Print instead of Printf, or use Printf like this:

log.Printf("%s", myPassword)