mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-05-02 14:46:07 -04:00
First pass at adding age penalty to health check
This commit is contained in:
parent
033dd79c58
commit
9055fb307d
3 changed files with 37 additions and 0 deletions
|
@ -231,6 +231,33 @@ const QSharedPointer<PasswordHealth> Entry::passwordHealth() const
|
|||
return m_data.passwordHealth;
|
||||
}
|
||||
|
||||
int Entry::getPasswordAgeInDays() const
|
||||
{
|
||||
QListIterator<Entry*> i(m_history);
|
||||
i.toBack();
|
||||
Entry* compare = nullptr;
|
||||
Entry* curr = nullptr;
|
||||
|
||||
while (i.hasPrevious()) {
|
||||
curr = i.previous();
|
||||
if (!compare) {
|
||||
compare = curr;
|
||||
continue;
|
||||
}
|
||||
if (*curr->attributes() != *compare->attributes()) {
|
||||
if (curr->password() != compare->password()) {
|
||||
// Found most recent password change; break out.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!curr) {
|
||||
// If no change in history, password is from creation time
|
||||
return this->timeInfo().creationTime().daysTo(QDateTime::currentDateTime());
|
||||
}
|
||||
return curr->timeInfo().lastModificationTime().daysTo(QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
bool Entry::excludeFromReports() const
|
||||
{
|
||||
return m_data.excludeFromReports
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue