PowerShell / SecretManagement

PowerShell module to consistent usage of secrets through different extension vaults
MIT License
328 stars 46 forks source link

Should Register-SecretVault lock in the ModulePath where the ModuleName resides? #70

Closed DonPwrShellHunt closed 3 years ago

DonPwrShellHunt commented 3 years ago

While doing development on a SecretManagement extension, a different instance of my module kept getting imported into my session and executed, rather than the one I placed earlier in the $PSModulePath. I finally figured out that the ModulePath property was saved with my registered secret vault, and that instance had priority running.

I did an Unregister-SecretVault & Register-SecretVault, which reset the ModulePath based on $PSModulePath and solved the strange import behavior.

My mindset was that the Register-SecretVault was semi-permanent and would not have to be reissued periodically.

Of course, having discovered this behavior, hopefully I'll recognize the symptoms if it crops up again.

issue-label-bot[bot] commented 3 years ago

Issue Label Bot is not confident enough to auto-label this issue. See dashboard for more details.

PaulHigin commented 3 years ago

Yes, currently Register-SecretVault saves the full path of the ModuleName you provide. It uses PowerShell module loading, so if you provide just a module name it will search for it using $env:PSModulePath, or if you provide a full path/name it will just use that. But when it finds the module it saves the full path in the vault registry. If you change the location of the extension vault module, you have to re-register it.