Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uses the Title of the entry as key Comment if key Comment is not available. #355

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions KeeAgent/KeeAgentExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -1083,6 +1085,11 @@ public ISshKey AddEntry(PwEntry entry,

try {
var key = entry.GetSshKey(this.Options.DisableKeyDecryptionProgressBar);

if (Options.UseTitleAsComment || String.IsNullOrEmpty(key.Comment)) {
key.Comment = entry.Strings.GetSafe("Title").ReadString();
}

string db_name = "<Unknown database>";

try {
Expand Down
5 changes: 5 additions & 0 deletions KeeAgent/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,10 @@ public Options()
/// When <c>true</c>, we will not display a progress bar during SSH key decryption.
/// </summary>
public bool DisableKeyDecryptionProgressBar { get; set; }

/// <summary>
/// When <c>true</c>, use the entry's title as the key's comment.
/// </summary>
public static bool UseTitleAsComment { get; set; }
}
}
9 changes: 9 additions & 0 deletions KeeAgent/Translatable.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions KeeAgent/Translatable.resx
Original file line number Diff line number Diff line change
Expand Up @@ -221,4 +221,7 @@
<data name="OptionUseWindowsOpenSshPipe" xml:space="preserve">
<value>Enable agent for Windows OpenSSH</value>
</data>
<data name="OptionUseTitleAsComment" xml:space="preserve">
<value>Use entry Title as key Comment</value>
</data>
</root>
3 changes: 3 additions & 0 deletions KeeAgent/UI/OptionsPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down