fix(#4926): broaden _redactToolTargetLabel to mask env/flag/header secrets in the full command
Codex gate: exposing the full multi-line command in the expanded shell card newly surfaces secrets on non-first lines (the collapsed header only ever showed line 1). The old redactor masked only password-shaped fields. Broaden it to mask common secret forms across the WHOLE command: env/colon assignments for *TOKEN/*API_KEY/*SECRET/*ACCESS_KEY/*PRIVATE_KEY/*CREDENTIAL/*CLIENT_SECRET/ *SESSION_KEY and *AUTH*=, --token/--api-key/--secret style flags, Authorization: Bearer/Bot/Token headers, and secret-looking URL query params. Test now drives the REAL redactor (not an identity stub) and asserts non-first-line secrets are masked while the collapsed header stays first-line.
This commit is contained in:
1 parent
99b6a5e30b
commit
ed21bd20cd
2 files changed
+56
-6
No files matched your search
+17
-1
@@ -12520,7 +12520,23 @@ function _redactToolTargetLabel(value){
|
||||
return String(value||'')
|
||||
.replace(/\bsshpass\s+-p\s+(?:"[^"]*"|'[^']*'|\S+)/gi,'sshpass -p "[redacted]"')
|
||||
.replace(/(--password(?:=|\s+))(?:"[^"]*"|'[^']*'|\S+)/gi,'$1[redacted]')
|
||||
.replace(/(password(?:=|\s+))(?:"[^"]*"|'[^']*'|\S+)/gi,'$1[redacted]');
|
||||
.replace(/(password(?:=|\s+))(?:"[^"]*"|'[^']*'|\S+)/gi,'$1[redacted]')
|
||||
// Env-assignment / flag secrets, masked across the full (multi-line) text so
|
||||
// the expanded shell card can't leak a key on a non-first line (#4926). Keys
|
||||
// matched case-insensitively: *(TOKEN|API_KEY|APIKEY|SECRET|PASSWD|PASSWORD|
|
||||
// ACCESS_KEY|PRIVATE_KEY|AUTH|CREDENTIAL|SESSION_KEY|CLIENT_SECRET)*.
|
||||
.replace(/(\b[A-Za-z0-9_]*(?:TOKEN|API[_-]?KEY|SECRET|PASSWD|ACCESS[_-]?KEY|PRIVATE[_-]?KEY|CREDENTIALS?|CLIENT[_-]?SECRET|SESSION[_-]?KEY)[A-Za-z0-9_]*\s*=\s*)(?:"[^"]*"|'[^']*'|\S+)/gi,'$1[redacted]')
|
||||
// AUTH-family env assignment, but only the `=` form (the `Authorization:`
|
||||
// header colon form is handled separately below, and must not be eaten here).
|
||||
.replace(/(\b[A-Za-z0-9_]*AUTH[A-Za-z0-9_]*\s*=\s*)(?:"[^"]*"|'[^']*'|\S+)/gi,'$1[redacted]')
|
||||
// --token / --api-key / --secret style flags.
|
||||
.replace(/(--(?:token|api[_-]?key|secret|access[_-]?key|client[_-]?secret|auth[_-]?token)(?:=|\s+))(?:"[^"]*"|'[^']*'|\S+)/gi,'$1[redacted]')
|
||||
// Authorization: Bearer/Bot/Token <token> (header or curl -H form):
|
||||
// redact everything after the scheme keyword up to the closing quote/space.
|
||||
.replace(/(authorization\s*:?\s*(?:bearer|bot|token)\s+)(?:"[^"]*"|'[^']*'|[^\s'"]+)/gi,'$1[redacted]')
|
||||
.replace(/((?:authorization|x-api-key)\s*:\s+)(?:"[^"]*"|'[^']*'|[^\s'"]{12,})/gi,'$1[redacted]')
|
||||
// Secret-looking URL query params (?token=... &api_key=... &access_token=...).
|
||||
.replace(/([?&](?:token|api[_-]?key|access[_-]?token|secret|sig|signature|key)=)(?:[^&\s"']+)/gi,'$1[redacted]');
|
||||
}
|
||||
function _shortToolLabel(value, limit){
|
||||
const text=String(value||'').replace(/\s+/g,' ').trim();
|
||||
|
||||
Reference in new issue
Block a user