Mask signKey in diagnostic output and fix the JSON redaction replacement
deploy hosecloud status/list/get masked apiKey and apiSecret but printed signKey in clear — yet signKey rides in the outbound callback URL as config_id, so it behaves like a credential (redactSensitiveText already carried it in its error-path pattern). Add it to redactIntegrationSecrets; operators still get it from the stderr Next-action guidance when they need it for `sync <signKey>`. Also fixes a latent bug in redactSensitiveText: the JSON-field pattern used $3 but only captured two groups, so redacted JSON came out malformed (`"signKey":"<redacted>$3`). New redact.test.ts locks the query-string, Bearer, JSON and field-list behaviour.
This commit is contained in:
1 parent
4922daf4e7
commit
935ca015b1
4 files changed
+118
-7
No files matched your search
+11
-6
@@ -1,10 +1,15 @@
|
||||
/**
|
||||
* Redacts credential-bearing patterns from free text before it reaches any output channel
|
||||
* (stdout JSON payloads, stderr messages, HTTP error responses).
|
||||
* Redacts credential-bearing patterns from free text before it reaches an
|
||||
* output channel.
|
||||
*
|
||||
* Lives in core because domain handlers embed upstream error messages — which may contain
|
||||
* full request URLs (`?token=...`) or echoed bodies (`"appSecurity":"..."`) — into their
|
||||
* results; the CLI printer and the HTTP adapter apply the same rules at their boundaries.
|
||||
* Applied to: error messages surfaced by the CLI runner (`src/cli/runner.ts`) and
|
||||
* HTTP error responses (`src/http/routes.ts`).
|
||||
*
|
||||
* NOT applied to successful stdout payloads: those are redacted where they are
|
||||
* built — handlers mask fields via `presentWebhookIntegration`,
|
||||
* `redactIntegrationSecrets`, `maskHoseSecurity` and `formatSafeSourceDetail`.
|
||||
* Blanket redaction of stdout would also destroy deliberate credential-delivery
|
||||
* output (`auth link` tokens, `extract-keys --reveal`), so it stays per-handler.
|
||||
*/
|
||||
export function redactSensitiveText(value: string): string {
|
||||
return value
|
||||
@@ -12,6 +17,6 @@ export function redactSensitiveText(value: string): string {
|
||||
.replace(/(Bearer\s+)[A-Za-z0-9._~+/=-]+/gi, "$1<redacted>")
|
||||
.replace(
|
||||
/("(?:appSecurity|password|secret|signKey|closeToken|refreshToken|accessToken|authorization)"\s*:\s*")[^"]*(")/gi,
|
||||
"$1<redacted>$3"
|
||||
"$1<redacted>$2"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user