SecretManagement icon indicating copy to clipboard operation
SecretManagement copied to clipboard

Sort the results of `Get-SecretInfo` correctly

Open andyleejordan opened this issue 1 year ago • 7 comments

Instead of using a SortedDictionary which introduced a bug because it required the keys (secret names) to be unique, we just sort the array directly using a comparer that sorts by name. Fixes #95.

andyleejordan avatar Feb 16 '24 23:02 andyleejordan

@andyleejordan are there any potential regressions with, say, piping two secretinfo results with the same name to get-secret?

JustinGrote avatar Feb 20 '24 15:02 JustinGrote

I am unsure and need to get some more folks to look at this. Also, I had a thought that it probably doesn't even need to build a set, I don't see why we can't just sort the array with the comparer I added.

andyleejordan avatar Feb 20 '24 20:02 andyleejordan

Yup, that's better. No idea why this had a dictionary in the first place, all it needed was a comparer.

andyleejordan avatar Feb 20 '24 21:02 andyleejordan

@andyleejordan are there any potential regressions with, say, piping two secretinfo results with the same name to get-secret?

Well, instead of erroring because of the duplicate names it should now correctly print them both.

andyleejordan avatar Feb 20 '24 21:02 andyleejordan

It's too bad we didn't catch this sooner and make the secret name case-insensitive, but it would be a breaking change now.

SteveL-MSFT avatar Feb 21 '24 00:02 SteveL-MSFT

Fair 😆 I'll figure that out...I need to make another PR setting up build/test tasks because that's been the slowest part of this.

andyleejordan avatar Feb 21 '24 00:02 andyleejordan

It's too bad we didn't catch this sooner and make the secret name case-insensitive, but it would be a breaking change now.

My understanding of it is that secret names aren't necessarily case-sensitive, at least as far as SecretManagement is concerned. It's up to the vault implementations to decide their case sensitivity...which is what revealed this bug. I think SecretStore is case-sensitive, but that shouldn't really matter here.

andyleejordan avatar Feb 21 '24 01:02 andyleejordan