Repository navigation
Validate service and version in EndpointDefinitionProvider - #3378
Merged
Merged
Conversation
## Changes 1. `EndpointDefinitionProvider` now requires the service name to be a single segment of letters, digits, and `.`, `-`, `_` separators, and throws `InvalidArgumentException` with `Invalid service name.` otherwise. 2. It requires the api version, checked after `latest` is resolved, to be letters and digits joined by hyphens, and throws `InvalidArgumentException` with `Invalid api version.` otherwise. 3. The checks run in the shared lookup behind `getParsedRuleset`, `getEndpointRuleset`, `getEndpointBdd` and `getEndpointTests`, so `S3MultiRegionClient` and other clients get them without extra code. 4. Non-string values, empty strings, and values with a trailing newline or NUL byte are rejected. 5. Add a changelog entry under `EndpointV2`. ## Compatibility 1. A `version` or `service` value outside the patterns above now throws at client construction or lookup. Every service and version directory shipped in `src/data` passes, and `latest` and `2006-03-01` still construct a multi-region client. 2. The checks throw even when `$throwIfMissing` is false, so a malformed value no longer returns null from the BDD probe in `getParsedRuleset`. The next lookup in that method threw for the same input before. 3. A future api version name containing `.` or `_` would need the version pattern widened. ## Alternatives Considered 1. Validate only in `MultiRegionClient`. This leaves the public static methods and `ClientResolver` with a custom `api_provider` unchecked. 2. Check the version against the endpoint manifest. Test fixtures that use a `$baseDir` such as `widget` are not in the manifest. 3. Use a `realpath()` containment check. It needs the path to exist first and handles symlinked vendor directories poorly. 4. Reject only `..`, `/` and `\`. A character allowlist also covers NUL bytes and other unexpected characters.
stobrien89
approved these changes
Oct 15, 2026
stobrien89
left a comment
Member
There was a problem hiding this comment.
Thanks for the fix @aBurmeseDev!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue #, if available:
Description of changes:
EndpointDefinitionProvidernow requires the service name to be a single segment of letters, digits, and.,-,_separators, and throwsInvalidArgumentExceptionwithInvalid service name.otherwise.latestis resolved, to be letters and digits joined by hyphens, and throwsInvalidArgumentExceptionwithInvalid api version.otherwise.getParsedRuleset,getEndpointRuleset,getEndpointBddandgetEndpointTests, soS3MultiRegionClientand other clients get them without extra code.EndpointV2.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.