mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-11 15:29:51 -05:00
Implement KDBX 4.1 PasswordQuality flag
This commit is contained in:
parent
035757e228
commit
ffaeac130f
BIN
share/demo.kdbx
BIN
share/demo.kdbx
Binary file not shown.
@ -24,7 +24,7 @@ const QString CustomData::LastModified = QStringLiteral("_LAST_MODIFIED");
|
||||
const QString CustomData::Created = QStringLiteral("_CREATED");
|
||||
const QString CustomData::BrowserKeyPrefix = QStringLiteral("KPXC_BROWSER_");
|
||||
const QString CustomData::BrowserLegacyKeyPrefix = QStringLiteral("Public Key: ");
|
||||
const QString CustomData::ExcludeFromReports = QStringLiteral("KnownBad");
|
||||
const QString CustomData::ExcludeFromReportsLegacy = QStringLiteral("KnownBad");
|
||||
|
||||
CustomData::CustomData(QObject* parent)
|
||||
: ModifiableObject(parent)
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
static const QString Created;
|
||||
static const QString BrowserKeyPrefix;
|
||||
static const QString BrowserLegacyKeyPrefix;
|
||||
static const QString ExcludeFromReports;
|
||||
static const QString ExcludeFromReportsLegacy; // Pre-KDBX 4.1
|
||||
|
||||
signals:
|
||||
void aboutToBeAdded(const QString& key);
|
||||
|
@ -46,6 +46,7 @@ Entry::Entry()
|
||||
m_data.iconNumber = DefaultIconNumber;
|
||||
m_data.autoTypeEnabled = true;
|
||||
m_data.autoTypeObfuscation = 0;
|
||||
m_data.excludeFromReports = false;
|
||||
|
||||
connect(m_attributes, &EntryAttributes::modified, this, &Entry::updateTotp);
|
||||
connect(m_attributes, &EntryAttributes::modified, this, &Entry::modified);
|
||||
@ -219,13 +220,14 @@ const QSharedPointer<PasswordHealth>& Entry::passwordHealth()
|
||||
|
||||
bool Entry::excludeFromReports() const
|
||||
{
|
||||
return customData()->contains(CustomData::ExcludeFromReports)
|
||||
&& customData()->value(CustomData::ExcludeFromReports) == TRUE_STR;
|
||||
return m_data.excludeFromReports
|
||||
|| (customData()->contains(CustomData::ExcludeFromReportsLegacy)
|
||||
&& customData()->value(CustomData::ExcludeFromReportsLegacy) == TRUE_STR);
|
||||
}
|
||||
|
||||
void Entry::setExcludeFromReports(bool state)
|
||||
{
|
||||
customData()->set(CustomData::ExcludeFromReports, state ? TRUE_STR : FALSE_STR);
|
||||
set(m_data.excludeFromReports, state);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1433,6 +1435,9 @@ bool EntryData::equals(const EntryData& other, CompareItemOptions options) const
|
||||
// The existance of TOTP has changed between these entries
|
||||
return false;
|
||||
}
|
||||
if (::compare(excludeFromReports, other.excludeFromReports, options) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -65,6 +65,7 @@ struct EntryData
|
||||
TimeInfo timeInfo;
|
||||
QSharedPointer<Totp::Settings> totpSettings;
|
||||
QSharedPointer<PasswordHealth> passwordHealth;
|
||||
bool excludeFromReports;
|
||||
|
||||
bool operator==(const EntryData& other) const;
|
||||
bool operator!=(const EntryData& other) const;
|
||||
|
@ -726,6 +726,10 @@ Entry* KdbxXmlReader::parseEntry(bool history)
|
||||
parseEntryString(entry);
|
||||
continue;
|
||||
}
|
||||
if (m_xml.name() == "QualityCheck") {
|
||||
entry->setExcludeFromReports(!readBool());
|
||||
continue;
|
||||
}
|
||||
if (m_xml.name() == "Binary") {
|
||||
QPair<QString, QString> ref = parseEntryBinary(entry);
|
||||
if (!ref.first.isEmpty() && !ref.second.isEmpty()) {
|
||||
@ -747,6 +751,13 @@ Entry* KdbxXmlReader::parseEntry(bool history)
|
||||
}
|
||||
if (m_xml.name() == "CustomData") {
|
||||
parseCustomData(entry->customData());
|
||||
|
||||
// Upgrade pre-KDBX-4.1 password report exclude flag
|
||||
if (entry->customData()->contains(CustomData::ExcludeFromReportsLegacy)) {
|
||||
entry->setExcludeFromReports(entry->customData()->value(CustomData::ExcludeFromReportsLegacy)
|
||||
== TRUE_STR);
|
||||
entry->customData()->remove(CustomData::ExcludeFromReportsLegacy);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
skipCurrentElement();
|
||||
|
@ -344,6 +344,9 @@ void KdbxXmlWriter::writeEntry(const Entry* entry)
|
||||
writeString("OverrideURL", entry->overrideUrl());
|
||||
writeString("Tags", entry->tags());
|
||||
writeTimes(entry->timeInfo());
|
||||
if (entry->excludeFromReports()) {
|
||||
writeBool("QualityCheck", false);
|
||||
}
|
||||
|
||||
const QList<QString> attributesKeyList = entry->attributes()->keys();
|
||||
for (const QString& key : attributesKeyList) {
|
||||
|
Loading…
Reference in New Issue
Block a user