Skip to content

Commit

Permalink
Add new option to enable date changes for a pwEntry
Browse files Browse the repository at this point in the history
With this option, any change of a breach state changes the last access and last modified date of a password entry.

Resolves #11
  • Loading branch information
kapsiR committed Sep 19, 2020
1 parent 4950b04 commit a38f7b8
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
###
### Added
- Added a new option to enable date changes for the password entries when any breach information gets added or removed

## [0.6.0] - 2020-07-12
### Added
Expand Down
30 changes: 30 additions & 0 deletions HaveIBeenPwnedKeePassPlugin/HaveIBeenPwnedPluginExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ public sealed class HaveIBeenPwnedPluginExt : Plugin
private bool _checkPasswordOnEntryTouched = true;
private bool _isIgnoreExpiredEntriesEnabled = true;
private bool _isShowGoodNewsOnManualEntryCheckEnabled = false;
private bool _isModifyPwEntryDatesEnabled = false;
private const string Option_CheckPasswordOnEntryTouched = "HaveIBeenPwnedPlugin_Option_CheckPasswordOnEntryTouched";
private const string Option_IgnoreExpiredEntries = "HaveIBeenPwnedPlugin_Option_IgnoreExpiredEntries";
private const string Option_ShowGoodNewsOnManualEntryCheck = "HaveIBeenPwnedPlugin_Option_ShowGoodNewsOnManualEntryCheck";
private const string Option_ModifyPwEntryDates = "HaveIBeenPwnedPlugin_Option_ModifyPwEntryDates";
private const string BreachedTag = "pwned";
private const string IgnorePwnedTag = "pwned-ignore";
private const string BreachCountCustomDataName = "pwned-count";
Expand Down Expand Up @@ -77,6 +79,7 @@ private void InitializeCustomConfigSettings()
_checkPasswordOnEntryTouched = _pluginHost.CustomConfig.GetBool(Option_CheckPasswordOnEntryTouched, true);
_isIgnoreExpiredEntriesEnabled = _pluginHost.CustomConfig.GetBool(Option_IgnoreExpiredEntries, true);
_isShowGoodNewsOnManualEntryCheckEnabled = _pluginHost.CustomConfig.GetBool(Option_ShowGoodNewsOnManualEntryCheck, false);
_isModifyPwEntryDatesEnabled = _pluginHost.CustomConfig.GetBool(Option_ModifyPwEntryDates, false);
}

private async void PwEntry_TouchedAsync(object o, ObjectTouchedEventArgs e)
Expand Down Expand Up @@ -175,13 +178,23 @@ private bool UpdateEntryRemoveBreachInformation(PwEntry pwEntry)
{
pwEntry.Tags.Remove(BreachedTag);
pwEntry.CustomData.Remove(BreachCountCustomDataName);
UpdatePwEntryDates(pwEntry);

return true;
}

return false;
}

private void UpdatePwEntryDates(PwEntry pwEntry)
{
if (_isModifyPwEntryDatesEnabled)
{
pwEntry.LastModificationTime = DateTime.Now;
pwEntry.LastAccessTime = DateTime.Now;
}
}

/// <summary>
/// Adds breach tag to entry
/// </summary>
Expand All @@ -199,6 +212,8 @@ private bool UpdateEntryWithBreachInformation(PwEntry pwEntry, int breachCount)
pwEntry.CustomData.Set(BreachCountCustomDataName, breachCount.ToString());
}

UpdatePwEntryDates(pwEntry);

return true;
}

Expand All @@ -223,6 +238,7 @@ private void SaveCurrentCustomConfigSettings()
_pluginHost.CustomConfig.SetBool(Option_CheckPasswordOnEntryTouched, _checkPasswordOnEntryTouched);
_pluginHost.CustomConfig.SetBool(Option_IgnoreExpiredEntries, _isIgnoreExpiredEntriesEnabled);
_pluginHost.CustomConfig.SetBool(Option_ShowGoodNewsOnManualEntryCheck, _isShowGoodNewsOnManualEntryCheckEnabled);
_pluginHost.CustomConfig.SetBool(Option_ModifyPwEntryDates, _isModifyPwEntryDatesEnabled);
}

public override ToolStripMenuItem GetMenuItem(PluginMenuType t)
Expand Down Expand Up @@ -287,9 +303,23 @@ public override ToolStripMenuItem GetMenuItem(PluginMenuType t)
checkBoxMenuItem_Option_ShowGoodNewsOnManualEntryCheck.Click += CheckBoxMenuItem_Option_ShowGoodNewsOnManualEntryCheck_Click;
pluginRootMenuItem.DropDownItems.Add(checkBoxMenuItem_Option_ShowGoodNewsOnManualEntryCheck);

ToolStripMenuItem checkBoxMenuItem_Option_ModifyPwEntryDates = new ToolStripMenuItem
{
Text = "Enable entry date changes when breach information is added/removed",
Checked = _isModifyPwEntryDatesEnabled
};
checkBoxMenuItem_Option_ModifyPwEntryDates.Click += CheckBoxMenuItem_Option_ModifyPwEntryDates_Click;
pluginRootMenuItem.DropDownItems.Add(checkBoxMenuItem_Option_ModifyPwEntryDates);

return pluginRootMenuItem;
}

private void CheckBoxMenuItem_Option_ModifyPwEntryDates_Click(object sender, EventArgs e)
{
_isModifyPwEntryDatesEnabled = !_isModifyPwEntryDatesEnabled;
UIUtil.SetChecked(sender as ToolStripMenuItem, _isModifyPwEntryDatesEnabled);
}

private void CheckBoxMenuItem_Option_ShowGoodNewsOnManualEntryCheck_Click(object sender, EventArgs e)
{
_isShowGoodNewsOnManualEntryCheckEnabled = !_isShowGoodNewsOnManualEntryCheckEnabled;
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.6.0",
"version": "0.7.0-preview",
"publicReleaseRefSpec": [
"^refs/heads/master$"
],
Expand Down

0 comments on commit a38f7b8

Please sign in to comment.