oscerd opened a new pull request, #31250:
URL: https://github.com/apache/camel/pull/31250
## CAMEL-28020: camel-salesforce - validate REST and raw client request URLs
and encode id segments
### What
The camel-salesforce internal clients build some request URLs by appending a
caller-supplied value onto the
configured Salesforce instance URL:
- `DefaultRestClient.queryMore(nextRecordsUrl, ...)` appended
`nextRecordsUrl` directly.
- `DefaultRawClient.makeRequest(method, path, ...)` appended `path` directly.
A value that is not an absolute path on the configured instance could change
the scheme, host or port of the
resulting request (for example a value that begins with `@`, with `//`, or
with an absolute `http(s)://` URL), so the
request would not stay on the configured instance. In addition, the record
`id` placed in the path of `getSObject`,
`updateSObject`, `deleteSObject` and `getBlobField` was not encoded, unlike
the operations that already URL-encode
their path values (`query`, `getSObjectWithId`, `upsertSObject`, ...).
### Change
- Add a shared `resolveInstanceUrl(relativePath)` helper in
`AbstractClientBase` that requires the value to be an
absolute path (it has to begin with a single `/`) and verifies that the
fully resolved URL keeps the scheme, host
and port of the configured instance URL, failing fast with a
`SalesforceException` otherwise.
- Use the helper in `DefaultRestClient.queryMore` and
`DefaultRawClient.makeRequest`; both report the
`SalesforceException` through their response callback (the same way
`query` already reports a URL-building error)
instead of sending the request.
- URL-encode the `id` path segment of `getSObject`, `updateSObject`,
`deleteSObject` and `getBlobField`, reusing the
existing encoding helper, so they match the operations that already encode.
Legitimate `nextRecordsUrl` values returned by Salesforce and raw `path`
values that begin with `/` are unaffected;
normal 15/18-character record ids are alphanumeric and are left unchanged by
the encoding.
### Tests
- `DefaultRestClientRequestUrlTest` - `queryMore` keeps a normal
`nextRecordsUrl` on the configured instance, rejects
values that would change the host (user-info, user-info with port,
authority-prefix and absolute-URL forms), and
`getSObject` / `updateSObject` / `deleteSObject` / `getBlobField`
percent-encode the id segment.
- `DefaultRawClientRequestUrlTest` - `makeRequest` keeps a normal path on
the configured instance and rejects values
that would change the host.
### Docs
- Added an upgrade-guide note to `camel-4x-upgrade-guide-4_25.adoc`.
_Claude Code on behalf of oscerd_
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]