Skip to content

Fix/workaround secret leak2#898

Merged
garloff merged 7 commits intomainfrom
fix/workaround-secret-leak2
Apr 4, 2025
Merged

Fix/workaround secret leak2#898
garloff merged 7 commits intomainfrom
fix/workaround-secret-leak2

Conversation

@garloff
Copy link
Member

@garloff garloff commented Apr 2, 2025

Fixes #896

garloff added 2 commits April 3, 2025 00:16
This introduces two changes:
(1) If there are many matches, we delete all matching secrets.
    Due to a previous issue, we may have many ...
(2) We extract the UUID from the id string and pass it to
    delete_secret(). This is a workaround to something that looks
    like a bug in the SDK to me.

Signed-off-by: Kurt Garloff <kurt@garloff.de>
Let's comment on the SDK issue here.

If it should change to return a UUID in the id attribute, we would now
still work, so we are robust against a possible direction that a fix
might take.

Signed-off-by: Kurt Garloff <kurt@garloff.de>
@garloff garloff added the bug Something isn't working label Apr 2, 2025
@garloff garloff self-assigned this Apr 2, 2025
Copy link
Contributor

@gtema gtema left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I knew this is very awkward on the barbican side (not supporting I'd as such), but also on SDK side I never worked with the service

garloff added 2 commits April 4, 2025 08:36
Improve comment explaining the SDK (and possibly API) misbehavior.
Also add comment on chosen workaround with robustness in mind,
but without taking it to the extreme of adding 5 additional API calls.

Signed-off-by: Kurt Garloff <kurt@garloff.de>
This keeps the code cleaner.

Signed-off-by: Kurt Garloff <kurt@garloff.de>
each time checking whether it was effective. But that's three delete
plus list calls and very ugly.)
"""
uuid_part = secret.id.rfind('/') + 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.python.org/3/library/stdtypes.html#str.rsplit

I think the case distinction can be dropped by using rsplit with maxsplit=1

uuid = secret.id.rsplit('/', 1)[0]

Should work in both cases

Copy link
Member Author

@garloff garloff Apr 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except that it should be secret.id.split('/')[-1].

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... which is the same as secret.id.rsplit('/',1)[-1], except that the latter might be slightly cheaper as it creates a list with max 2 elements.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, you're right, I wrote this in a hurry 🙈

... based on suggestion by @mbuechse.

Signed-off-by: Kurt Garloff <kurt@garloff.de>
@garloff garloff merged commit d2fb97e into main Apr 4, 2025
8 checks passed
@garloff garloff deleted the fix/workaround-secret-leak2 branch April 4, 2025 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Secrets are not cleaned up in compliance test

3 participants