From c5dfb68851956bb4ebdf3e8604395476ed37068e Mon Sep 17 00:00:00 2001 From: Alan Reyes Date: Wed, 3 Jan 2024 19:44:44 -0600 Subject: [PATCH] Adds option to force using entry Title as key Comment --- KeeAgent/KeeAgentExt.cs | 4 +++- KeeAgent/Options.cs | 5 +++++ KeeAgent/Translatable.Designer.cs | 9 +++++++++ KeeAgent/Translatable.resx | 3 +++ KeeAgent/UI/OptionsPanel.cs | 3 +++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/KeeAgent/KeeAgentExt.cs b/KeeAgent/KeeAgentExt.cs index 17c9e28..28df490 100644 --- a/KeeAgent/KeeAgentExt.cs +++ b/KeeAgent/KeeAgentExt.cs @@ -64,6 +64,7 @@ public sealed partial class KeeAgentExt : Plugin pluginNamespace + ".UserPicksKeyOnRequestIdentities"; const string ignoreMissingExternalKeyFilesName = pluginNamespace + ".IgnoreMissingExternalKeyFilesName"; const string disableKeyDecryptionProgressBarName = pluginNamespace + ".DisableKeyDecryptionProgressBar"; + const string useTitleAsComment = pluginNamespace + ".UseTitleAsComment"; const string keyFilePathSprPlaceholder = @"{KEEAGENT:KEYFILEPATH}"; const string identFileOptSprPlaceholder = @"{KEEAGENT:IDENTFILEOPT}"; const string groupMenuItemName = "KeeAgentGroupMenuItem"; @@ -672,6 +673,7 @@ private void LoadOptions() config.GetBool(userPicksKeyOnRequestIdentitiesOptionName, false); Options.IgnoreMissingExternalKeyFiles = config.GetBool(ignoreMissingExternalKeyFilesName, false); Options.DisableKeyDecryptionProgressBar = config.GetBool(disableKeyDecryptionProgressBarName, false); + Options.UseTitleAsComment = config.GetBool(useTitleAsComment, false); string defaultLogFileNameValue = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @@ -1084,7 +1086,7 @@ public ISshKey AddEntry(PwEntry entry, try { var key = entry.GetSshKey(this.Options.DisableKeyDecryptionProgressBar); - if (String.IsNullOrEmpty(key.Comment)) { + if (Options.UseTitleAsComment || String.IsNullOrEmpty(key.Comment)) { key.Comment = entry.Strings.GetSafe("Title").ReadString(); } diff --git a/KeeAgent/Options.cs b/KeeAgent/Options.cs index 814780d..818257c 100644 --- a/KeeAgent/Options.cs +++ b/KeeAgent/Options.cs @@ -112,5 +112,10 @@ public Options() /// When true, we will not display a progress bar during SSH key decryption. /// public bool DisableKeyDecryptionProgressBar { get; set; } + + /// + /// When true, use the entry's title as the key's comment. + /// + public static bool UseTitleAsComment { get; set; } } } diff --git a/KeeAgent/Translatable.Designer.cs b/KeeAgent/Translatable.Designer.cs index 6c99420..4f01bbe 100644 --- a/KeeAgent/Translatable.Designer.cs +++ b/KeeAgent/Translatable.Designer.cs @@ -302,6 +302,15 @@ internal static string OptionUserPicksKeyOnRequestIdentities { } } + /// + /// Looks up a localized string similar to Use entry Title as key Comment. + /// + internal static string OptionUseTitleAsComment { + get { + return ResourceManager.GetString("OptionUseTitleAsComment", resourceCulture); + } + } + /// /// Looks up a localized string similar to Enable agent for Windows OpenSSH. /// diff --git a/KeeAgent/Translatable.resx b/KeeAgent/Translatable.resx index 602c2fd..98b6b58 100644 --- a/KeeAgent/Translatable.resx +++ b/KeeAgent/Translatable.resx @@ -221,4 +221,7 @@ Enable agent for Windows OpenSSH + + Use entry Title as key Comment + diff --git a/KeeAgent/UI/OptionsPanel.cs b/KeeAgent/UI/OptionsPanel.cs index 536be9e..3eb4618 100644 --- a/KeeAgent/UI/OptionsPanel.cs +++ b/KeeAgent/UI/OptionsPanel.cs @@ -65,6 +65,9 @@ public OptionsPanel(KeeAgentExt ext) optionsList.CreateItem(ext.Options, "DisableKeyDecryptionProgressBar", optionsGroup, Translatable.OptionDisableKeyDecryptionProgressBar); + optionsList.CreateItem(ext.Options, "UseTitleAsComment", + optionsGroup, Translatable.OptionUseTitleAsComment); + var agentModeOptionsGroup = new ListViewGroup("agentMode", "Agent Mode Options (no effect in Client Mode)"); customListViewEx.Groups.Add(agentModeOptionsGroup);