Skip to content

Validate service and version in EndpointDefinitionProvider - #3378

Merged
stobrien89 merged 1 commit into
masterfrom
john/validate-endpoint-definition-path
Oct 15, 2026
Merged

stobrien89 merged 1 commit into
masterfrom
john/validate-endpoint-definition-path

Conversation

@aBurmeseDev

Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of 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.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

## 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.
@aBurmeseDev
aBurmeseDev requested a review from a team as a code owner October 15, 2026 20:41

@stobrien89 stobrien89 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix @aBurmeseDev!

@stobrien89
stobrien89 merged commit dbe74fc into master Oct 15, 2026
22 of 23 checks passed
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.

2 participants