davsclaus opened a new pull request, #31043:
URL: https://github.com/apache/camel/pull/31043

   JIRA: https://issues.apache.org/jira/browse/CAMEL-27722
   
   ## What was wrong
   
   When `apiContextPath` is set, camel-rest-postman serves the user-provided 
collection on that path.
   `PostmanRedactor.redact()` removed every `auth` block and masked the value 
of variables of type `secret`, but the rest
   of the document was served as it was loaded, so these values were not masked:
   
   - literal values of credential headers (`Authorization`, 
`Proxy-Authorization`, `x-api-key`, `api-key`, `Cookie`,
     `Set-Cookie`, any header whose name contains `token`), in requests and in 
example responses
   - variables of the default type whose name marks a credential (`apiKey`, 
`password`, `access_token`, ...)
   - the userinfo password (`https://user:password@host`) and credential query 
parameters (`api_key`, `apikey`, `token`,
     `access_token`, `password`, `secret`) in URLs, both in the `raw` URL and 
in the structured `host` / `query` parts
   
   ## What changed
   
   `PostmanRedactor` now also masks, with the same `***` mask:
   
   - `header`, `query`, `urlencoded` and `formdata` entries whose `key` marks a 
credential (also a `header` given as a
     single string of `Name: value` lines)
   - default-type variables whose name marks a credential; other variable 
string values go through the URL masking
     (a `baseUrl` with a userinfo password)
   - every cookie value of an example response
   - the userinfo password and credential query parameter values in `url` 
strings, in `url.raw` and in `url.host`
   
   A name marks a credential when `SensitiveUtils.isSensitiveHeader` says so 
(this also covers the Camel sensitive keys,
   such as `user` and `clientId`), or when it contains `token`, `password` or 
`secret`. The userinfo uses
   `SensitiveUtils.maskUserInfoCredentials`. `URISupport.sanitizeUri` is not 
used for the query, because it masks with
   `xxxxxx` and also masks `{{placeholder}}` values.
   
   Placeholders: a value that is only a Postman variable reference 
(`{{apiKey}}`, or an auth scheme plus one, such as
   `Bearer {{token}}`) is not a credential and is left as it is, so the served 
collection still shows which variable a
   client must provide. The variable it refers to is masked where the 
collection defines it.
   
   Only the served copy is changed; the collection that the routes use is not.
   
   ## Tests
   
   17 new tests in `PostmanRedactorTest`, one per case (Authorization, 
Proxy-Authorization, x-api-key / api-key, Cookie,
   `*token*` headers, example response headers and cookies, header string form, 
default-type variables, userinfo in raw
   and structured URL, a variable holding a URL, query params in raw and 
structured form, form fields, placeholders in
   headers, variables and URLs). Without the fix 14 of them fail (the 3 
placeholder tests pass, as they assert the
   document is unchanged). All 214 tests of the module pass with the fix.
   
   ## Docs
   
   The component doc lists what the served collection masks (and the catalog 
copy). The 4.24 upgrade guide has a short
   entry, as users can see more values masked in the served collection.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 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]

Reply via email to