Skip to content

Add advanced password generator features#1841

Merged
droidmonkey merged 4 commits intokeepassxreboot:developfrom
matsievskiysv:develop
Jun 11, 2018
Merged

Add advanced password generator features#1841
droidmonkey merged 4 commits intokeepassxreboot:developfrom
matsievskiysv:develop

Conversation

@matsievskiysv
Copy link
Copy Markdown
Contributor

@matsievskiysv matsievskiysv commented Apr 12, 2018

Description

Added options to increase control over the character groups used for password generation.

Special characters group has been split into 6 subgroups (see screenshot below). Buttons controlling these groups and extended ASCII button were moved to fineTuneBar widget and are visible only when Fine Tune button is pressed.

Motivation and context

A lot of sites have very particular set of characters allowed in password. This change allows to generate a password in compliance with character restrictions simply by selecting character groups.

fineTuneBar is initially hidden so additional information will not overload the UI.

Extended ASCII button was moved inside fineTuneBar because firstly, it makes sense, secondly, so UI would not change a lot.

How has this been tested?

  • It has been tested by hand.
  • Automated tests were run and passed.
  • Program was build and run with -DWITH_ASAN=ON before and after alterations. No new memory leaks were introduced (BTW there are some memory leaks on development brunch).

Screenshots (if appropriate):

Before changes

selection_206

After changes

selection_207

After changes with fine tune button pressed

selection_208

Types of changes

  • ✅ New feature (non-breaking change which adds functionality)

Checklist:

  • ✅ I have read the CONTRIBUTING document. [REQUIRED]
  • ✅ My code follows the code style of this project. [REQUIRED]
  • ✅ All new and existing tests passed. [REQUIRED]
  • ✅ I have compiled and verified my code with -DWITH_ASAN=ON. [REQUIRED]

@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented Apr 13, 2018

Oh i like this, although i think a label of "Advanced..." or "Extended ASCII..." would be more appropriate.

The ... indicates the button opens/reveals some more features.

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

Replaced FineTune button with Advanced button on the side. When clicked, it reveals advanced configurations. User can get back to simple configurations by clicking Simple button.

Added ability to create hexadecimal passwords, proposed in #1248 by splitting characters is subgroups.

Simple mode

selection_209

Advanced mode

selection_210

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Apr 16, 2018

I really like this new UI, I will review in the next few days

@glubsy
Copy link
Copy Markdown

glubsy commented May 4, 2018

What if I only want some specific characters among <*+!?= and only some characters among \_|-/ (as required by some programs / websites)?

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

If it is a frequent issue, groups should be adjusted. If it is just a couple of sites/programs, manual password edit is fine. I don't think adding more buttons would be a good idea. It would be too messy.

@glubsy
Copy link
Copy Markdown

glubsy commented May 4, 2018

But what if I generate a lot of passwords, and they need to be 500+ characters (ie. encryption keys or something like that)?

Wouldn't a filter be more appropriate? Like a blacklist / whitelist pair or small input fields perhaps?

@droidmonkey
Copy link
Copy Markdown
Member

There was discussion of including a textbox where a white/black list could be applied.

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

Do you need this in GUI? Could this just be a CLI feature?

@droidmonkey
Copy link
Copy Markdown
Member

Yes it absolutely must be in the GUI

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

selection_234

selection_235

@droidmonkey @glubsy I've added "do not include" text input to gui and cli.
Buttons have precedence over this input. If all characters form some group are mentioned in "do not include" field, then all characters from this group may appear in generated password. It is done like that to ensure that there's no inconsistency between selected groups and generated password.

@glubsy
Copy link
Copy Markdown

glubsy commented May 9, 2018

@seregaxvm this is looking great in my opinion! Thank you!

I'm still not sure about the purpose of A-F / G-Z filters though, sounds arbitrary and probably leads to less security in a sense. Perhaps it would be wise to replace those with something else... what about Unicode characters and non printable characters? That is, if it's at all possible without breaking things, since Unicode is multi-byte character encoding.

@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented May 9, 2018

@glubsy Those are for hex passwords.

I don't understand the purpose of overriding the "do not include" entries if it covers the whole spectrum of a button. My opinion is if you put it in the do not include box, you mean it.

I would add a clear button similar to what we have in the search box to quickly remove the do not include entries.

If you hide the advanced fields, does it revert back to normal behavior?

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

selection_236

selection_237

@droidmonkey @glubsy

  • Hexadecimal character buttons removed. One can generate hexadecimal passwords using "do not include" field. This is not very convenient but, as I understand, this feature is not so frequently used anyway.
  • Clear button added to "do not include" field.
  • "do not include" entries only applied when the field is visible. They are ignored in simple mode.
  • "do not include" has precedence over buttons. Characters from this field are never in the password.
  • When all characters, selected with buttons, are in "do not include" field, input is invalidated and no password will be generated.
  • Added --exclude_similar and --every_group options to CLI generator.
  • Conversion toLatin1 is used to calculate entropy so Unicode characters were not added.

@glubsy
Copy link
Copy Markdown

glubsy commented May 9, 2018

Well this is looking very good.

Perhaps the only thing that might confuse the user is when clicking Advanced, the a-z button is shifting below, and the 0-9 button is shifting left.

Also it might be a good opportunity to add examples in the Exclude look-alike characters. I, for one, don't know which characters are targeted by this.

@droidmonkey
Copy link
Copy Markdown
Member

Awesome update!

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

selection_039

@glubsy added tool-tip description with list of excluded look-alike characters.
The last one is from Extended ASCII group. Should "." from special group also be excluded?
a-z, A-Z and 0-9 are grouped like so, firstly, to move related buttons closer to each other, secondly, to have columns of buttons with roughly same width.

@glubsy
Copy link
Copy Markdown

glubsy commented May 10, 2018

Fantastic! Thank you very much!

@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented May 13, 2018

BTW, you are going to have to put all your commits into a branch. Recommend you do the following steps:

  1. Create branch: "feature/finetune-password" at your current develop head
  2. Rebase the new branch onto keepassxc/develop
  3. Push to your fork
  4. Change the base of this PR to your new branch

@droidmonkey droidmonkey changed the title Add fineTune bar for password generator Add advanced password generator features May 13, 2018
@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented May 13, 2018

I tried this out and it worked perfectly. Recommend the following additions/changes:

adv_pwgen

The HEX button (oft requested feature) would very simply set the "exclude characters" textbox to GHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz it is up to the user to select the A-Z (or a-z) and 0-9 buttons, but perhaps the HEX button could auto select the A-Z and 0-9 automatically on first press while also setting the exclude characters text field.

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

@droidmonkey, please create branch feature/finetune-password so I could rebase to it?

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

keepassxc_238
keepassxc_239

Checkboxes are hidden in simple mode. Added Hex shortcut. When clicked, it fills "exclude characters" textbox with predefined string GHIJKLMNOPQRSTUVWXYZghijklmnopqrstuvwxyz

@matsievskiysv matsievskiysv reopened this May 13, 2018
@droidmonkey
Copy link
Copy Markdown
Member

@seregaxvm you create the branch on your own fork.

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

@droidmonkey I did but I'm not able to change the brunch to pull from. I only can change base brunch to commit into, but it should exist.

@droidmonkey
Copy link
Copy Markdown
Member

Crap true, you cannot change the base branch. That is fine, I can merge it right now without much issue. In the future make sure you make PR using a branch off develop.

QByteArray result3 = CryptoHash::hash(source2, CryptoHash::Sha512);
QCOMPARE(result3, QByteArray::fromHex("0d41b612584ed39ff72944c29494573e40f4bb95283455fae2e0be1e3565aa9f48057d59e6ff"
"d777970e282871c25a549a2763e5b724794f312c97021c42f91d"));
QCOMPARE(result3,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert these changes, your code formatter got a little happy.

QString expectedResult =
QString().append(ExpectedHeaderLine).append("\"Test Group Name\",\"Test Entry Title\",\"Test Username\",\"Test "
"Password\",\"http://test.url\",\"Test Notes\"\n");
QString expectedResult = QString()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert these changes, your code formatter got a little happy.

QTest::newRow("Upgrade (implicit): public-customdata") << QString("public-customdata") << KeePass2::FILE_VERSION_4;
QTest::newRow("Upgrade (implicit): rootgroup-customdata") << QString("rootgroup-customdata")
<< KeePass2::FILE_VERSION_4;
QTest::newRow("Upgrade (implicit): rootgroup-customdata")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert these changes, your code formatter got a little happy.

QTest::newRow("Upgrade (implicit): group-customdata") << QString("group-customdata") << KeePass2::FILE_VERSION_4;
QTest::newRow("Upgrade (implicit): rootentry-customdata") << QString("rootentry-customdata")
<< KeePass2::FILE_VERSION_4;
QTest::newRow("Upgrade (implicit): rootentry-customdata")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Revert these changes, your code formatter got a little happy.

@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented May 14, 2018

I can change the target branch (ie keepassxc/develop) but not the base, GitHub doesnt even give me the option to try.

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

selection_065

These are all my options. If it's possible I would prefer not to complicate things and to merge into develop. If it's not desirable, I will open another pull request.

@droidmonkey
Copy link
Copy Markdown
Member

@seregaxvm you want to merge INTO develop, so your current selection is accurate. The issue is the branch to the right cannot be changed (its locked with the PR). Its not that big of a deal, but sometimes rebasing and other actions get ugly when you don't have your PR in a new branch. IMO this is GitHubs fault for not enforcing that behavior.

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented May 15, 2018

I really like this PR and the new UI (my 2 cent)

@droidmonkey
Copy link
Copy Markdown
Member

This is ready for merge. Any more changes requested? I'm very happy with the results as well.

}

int i = 0;
while (1) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's not very clear at first look what this piece of code is suppose to do, insert a comment or move it into a function

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

How about that :"Loop over character groups and remove excluded characters from them; remove empty groups"? Also break condition should be moved from if to while

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also, you should use while(true) instead. You are implicitly converting 1 to bool in this case.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@seregaxvm I think that can do it. 😉

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@droidmonkey
Copy link
Copy Markdown
Member

I will do a formal review very soon

@codecov-io
Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (develop@8391729). Click here to learn what that means.
The diff coverage is 30.76%.

Impacted file tree graph

@@            Coverage Diff             @@
##             develop    #1841   +/-   ##
==========================================
  Coverage           ?   62.44%           
==========================================
  Files              ?      269           
  Lines              ?    17887           
  Branches           ?        0           
==========================================
  Hits               ?    11170           
  Misses             ?     6717           
  Partials           ?        0
Impacted Files Coverage Δ
src/gui/EditWidgetIcons.cpp 23.47% <ø> (ø)
src/gui/DatabaseWidget.cpp 67.66% <ø> (ø)
src/gui/PasswordGeneratorWidget.h 100% <ø> (ø)
src/core/PasswordGenerator.h 100% <ø> (ø)
src/autotype/AutoType.cpp 62.74% <0%> (ø)
src/browser/BrowserSettings.cpp 2.39% <0%> (ø)
src/core/PasswordGenerator.cpp 56.25% <32.89%> (ø)
src/gui/PasswordGeneratorWidget.cpp 64.74% <41.46%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8391729...9c81867. Read the comment docs.

@droidmonkey droidmonkey merged commit e124f17 into keepassxreboot:develop Jun 11, 2018
@Gittyperson
Copy link
Copy Markdown

Gittyperson commented Aug 4, 2018

It's great that these features are coming. Many, many sites happily accept the password during registration (containing the more unusual, non-allowed characters) but when it's time to log in, they will report "invalid password" with no further details.

@lordloh
Copy link
Copy Markdown

lordloh commented Aug 11, 2018

I would like to suggest adding a check box called "SQL safe" that would remove things like "--" and ";" from the password. I am not sure how developers handle them. I have had trouble logging into websites after using a password generated by Keepassxc. The password is accepted at change password time, but not during login :-(

I had to tweak out certain sets of characters to get it working. This is completely the websites fault. But it would be ages before they fix it. I discovered at one site that the desktop site accepts longer passwords than the mobile version of the site. I had to use a shorter password :-(

@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented Aug 11, 2018

Omg, if you are running into websites that can't handle those characters that means they are ripe for SQL injection attacks. RUN!

It is also a good indicator that the password is being stored as plain text in the database. RUN!

@lordloh
Copy link
Copy Markdown

lordloh commented Aug 12, 2018 via email

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

@lordloh You can just type ;-) or something like that into the do not include line.

@TheZ3ro
Copy link
Copy Markdown
Contributor

TheZ3ro commented Aug 13, 2018

You can just type ;-) or something like that into the do not include line.

The wink emoji of SQLi doom

@sebast889
Copy link
Copy Markdown

sebast889 commented Jan 10, 2019

@seregaxvm @droidmonkey Sorry I couldn't find anywhere the reason so I'm asking here. Why are the character types in the group that they are in? Seems they are arbitrarily chosen or at least I couldn't spot any real pattern. Is there any rationale behind what characters are in what group? (apart from A-Z, a-z and 0-9 which makes sense to me)

@droidmonkey
Copy link
Copy Markdown
Member

This is already merged. If you have a suggested grouping(s) please out them in a new issue.

@sebast889
Copy link
Copy Markdown

I don't have any particular grouping suggestions. I was just wondering if there was any reason they were grouped in the way there are.

@matsievskiysv
Copy link
Copy Markdown
Contributor Author

@sebast889 They are based on the personal experience with different sites password restrictions. The idea was to split Special Characters group into smaller ones. Their names are Braces, Punctuation, Quotes, Math, Dashes and Logograms.

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.

9 participants