Fix disposeKeys logic in aws_kms KeyManager plugin
#6525
Merged
+14
−7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change updates the disposeKeys function
aws_kmsKeyManager plugin to use prefix matching instead of exact equality when checking if a key belongs to the trust domain.The previous logic (Description != prefix) only matched keys with descriptions exactly equal to SPIRE_SERVER_KEY/{trust_domain}, excluding keys with additional path components. The new logic (!strings.HasPrefix(Description, prefix)) correctly identifies all keys belonging to the trust domain, including those with extra path segments like SPIRE_SERVER_KEY/{trust_domain}/extra.
Thanks @moe-omar for pointing this in #5497.
The test suite was updated to fix a data race where the test directly accessed the key entries map without proper synchronization, now using the thread-safe ListKeyEntries() method instead, and adjusted to wait for all expected deletion signals before asserting results.