Skip to content

consumer_key: trim an explicit /* or / suffix in add_recursive_rules - #150

Open
Occansey wants to merge 1 commit into
ovh:masterfrom
Occansey:fix/recursive-rules-suffix
Open

consumer_key: trim an explicit /* or / suffix in add_recursive_rules#150
Occansey wants to merge 1 commit into
ovh:masterfrom
Occansey:fix/recursive-rules-suffix

Conversation

@Occansey

@Occansey Occansey commented Sep 8, 2026

Copy link
Copy Markdown

In add_recursive_rules, path.rstrip("*/ ") strips a set of characters from the tail, so it also removes a trailing *, / or space wherever it sits at the end. That can change the granted pattern in ways the caller did not intend (for example a path passed as "/vps*", or one with a trailing space).

This trims exactly one trailing /* or / instead, so the granted pattern matches what the caller wrote:

path = path.strip()
if path.endswith("/*"):
    path = path[:-2]
path = path.rstrip("/")

Behaviour is unchanged for the documented cases: "/sms", "/sms/" and "/sms/*" all yield /sms plus /sms/*. The existing test suite passes.

Happy to adjust if you'd prefer a different approach.

Thanks,
Edem Occansey

path.rstrip("*/ ") stripped a whole set of characters from the tail, which
could alter the granted pattern in surprising ways (e.g. a trailing space, or
a path ending in one of those characters). Trim exactly one trailing "/*" or
"/" instead.
@Occansey
Occansey requested a review from a team as a code owner September 8, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant