Giter Site home page Giter Site logo

Comments (3)

0xdeadbeer avatar 0xdeadbeer commented on June 16, 2024

A few of my additional findings:

  • it does not matter what encryption algorithm you used
  • nor what kind of password you have, whether you generated it or not

I suspect that it comes down to this:

if (!m_passwordEditWidget->isEmpty()
&& m_passwordEditWidget->getPasswordQuality() < PasswordHealth::Quality::Good) {
auto dialogResult = MessageBox::warning(this,
tr("Weak password"),
tr("This is a weak password! For better protection of your secrets, "
"you should choose a stronger password."),
MessageBox::ContinueWithWeakPass | MessageBox::Cancel,
MessageBox::Cancel);
if (dialogResult == MessageBox::Cancel) {
return false;
}
}
// If enforced in the config file, deny users from continuing with a weak password
auto minQuality =
static_cast<PasswordHealth::Quality>(config()->get(Config::Security_DatabasePasswordMinimumQuality).toInt());
if (!m_passwordEditWidget->isEmpty() && m_passwordEditWidget->getPasswordQuality() < minQuality) {
MessageBox::critical(this,
tr("Weak password"),
tr("You must enter a stronger password to protect your database."),
MessageBox::Ok,
MessageBox::Ok);
return false;
}

To my surprise, m_passwordEditWidget->isEmpty() does not return true if the user hasn't clicked on "Change Password" button in the Database Security Settings.. an additional check with m_passwordEditWidget->visiblePage() == KeyComponentWidget::Page::Edit is I hope enough to safe-guard it..? Like so:

diff --git a/src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp b/src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp
index 1de8e6a9..0c26bccb 100644
--- a/src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp
+++ b/src/gui/dbsettings/DatabaseSettingsWidgetDatabaseKey.cpp
@@ -178,7 +178,8 @@ bool DatabaseSettingsWidgetDatabaseKey::save()
     }
 
     // Show warning if database password is weak
-    if (!m_passwordEditWidget->isEmpty()
+    bool isNewPasswordDirty = !m_passwordEditWidget->isEmpty() && m_passwordEditWidget->visiblePage() == KeyComponentWidget::Page::Edit;
+    if (isNewPasswordDirty
         && m_passwordEditWidget->getPasswordQuality() < PasswordHealth::Quality::Good) {
         auto dialogResult = MessageBox::warning(this,
                                                 tr("Weak password"),
@@ -195,7 +196,7 @@ bool DatabaseSettingsWidgetDatabaseKey::save()
     // If enforced in the config file, deny users from continuing with a weak password
     auto minQuality =
         static_cast<PasswordHealth::Quality>(config()->get(Config::Security_DatabasePasswordMinimumQuality).toInt());
-    if (!m_passwordEditWidget->isEmpty() && m_passwordEditWidget->getPasswordQuality() < minQuality) {
+    if (isNewPasswordDirty && m_passwordEditWidget->getPasswordQuality() < minQuality) {
         MessageBox::critical(this,
                              tr("Weak password"),
                              tr("You must enter a stronger password to protect your database."),

from keepassxc.

droidmonkey avatar droidmonkey commented on June 16, 2024

That code won't compile. simply call isVisible() on the password widget.

from keepassxc.

0xdeadbeer avatar 0xdeadbeer commented on June 16, 2024

Strange, it compiles on my machine..? Anyhow, after some checking to me it seems that calling m_passwordEditWidget->isVisible() at that point in time returns true even if the user does not click on "Change Password"..? Even weirder is the fact that the visible property seems to be false at that point when inspected through Gamma Ray.. ->isVisible() still returns true though.. will look further into the source code the coming days

from keepassxc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.