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

New-KeePassPassword throws exception if CharacterSet is Empty #164

Open
kdmhorn opened this issue May 2, 2019 · 0 comments
Open

New-KeePassPassword throws exception if CharacterSet is Empty #164

kdmhorn opened this issue May 2, 2019 · 0 comments
Assignees

Comments

@kdmhorn
Copy link

kdmhorn commented May 2, 2019

When issuing New-KeePassPassword, if switches or parameters are passed to the function that do not affect the characterset, the underlying library throws an exception of TooFewCharacters

For example New-KeePassPassword -Length 16 will throw and exception, whereas New-KeePassPassword -UpperCase -Length 16 works.

A proposed solution - define a variable where $defaultCharSet with a value "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" early in the function then replace line 229 ($PassProfile.CharSet.Add($NewProfileObject.CharacterSet)) as follows - note that the proposed solution allows for a minimum number of characters needed to select from for generation (in this case looking for empty "-lt 1") but minimum length could be set higher. This could prevent from just sending something like New-KeePassPassword -Minus which would, by default, generate 20 dashes as the password.

                #Check if a minimum of characters available to process otherwise set computed character set
                If ($NewProfileObject.CharacterSet.Length -lt 1)
                {
                    $NewProfileObject.CharacterSet = $NewProfileObject.CharacterSet + $defaultCharSet
                    $PassProfile.CharSet.Add($NewProfileObject.CharacterSet)
                }
@jkdba jkdba self-assigned this May 6, 2019
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

No branches or pull requests

2 participants