JustinGrote / JustinGrote/SecretManagement.KeePass

Add a check for $MyInvocation.ScriptName in Test-SecretVault

Open
#74 1 comment 1 reaction 0 assignees View on GitHub
bug help wanted
Dominant language
PowerShell
Stars
123
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Hey Justin,

First off, great work on this! I've made super heavy use of this module and it's been overall great. Something that I've noticed while using it though is that if the databases aren't open while I'm using the SecretManagement module in CommandLine - they ask to be opened even if I'm not looking at the specific database in question.

After digging into this - it looks like SecretManagement has an Autocompleter for both VaultNames and SecretNames. It looks like SecretManagement calls extension's Get-SecretInfo which calls Test-SecretVault which attempts to open up the Database if it's not already open. Now - I can see in most scenarios this isn't an issue because most people are only going to have 1 or 2 databases configured. In my situation though, I've got over 18 Vaults configured - and having to click "cancel" or type in 18 different passwords every time I accidentally trigger this Argument Completer kills me.

I went ahead and poked around and just simply adding a check for $MyInvocation.ScriptName seems to work - although there might be a better way to handle it. I threw it in Test-SecretVault.ps1 at Line 64:
`
elseif (-not [string]::IsNullOrWhiteSpace($MyInvocation.ScriptName)) {
return $false
}
`

Just wrote this up fairly quickly and didn't thoroughly test it - but I'll setup a dev environment and submit a pull request when I can if you'd like.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in Test-SecretVault.ps1 around line 64 and trace how SecretManagement's Get-SecretInfo and argument completion reach it. Verify the command-line completion path does not prompt to open vaults while ordinary vault checks still work, then test the behavior in a development environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.