Fix paste ownership, input bounds, and IPC validation

Supersedes #5745, #5746, and #5747.
This commit is contained in:
Jinwoo Hong
2026-06-19 17:14:55 -07:00
committed by GitHub
parent a5920b2183
commit 972078f2c4
592 changed files with 33303 additions and 3737 deletions
+33 -2
View File
@@ -64,8 +64,7 @@ export function linearMessage(error: unknown): string {
export function sanitizeLinearErrorMessage(message: string): string {
// Why: provider text is useful in CLI errors, but raw SDK failures can embed secrets or user payloads.
return message
.split(/\r?\n\s+at\s+/)[0]
return stripLinearStackTrace(message)
.replace(
/(headers?\s*[:=]\s*)\{[^{}]*(?:authorization|token|api[-_]?key)[^{}]*\}/gi,
'$1[REDACTED]'
@@ -77,3 +76,35 @@ export function sanitizeLinearErrorMessage(message: string): string {
.replace(/((?:body|comment|description)\s*[:=]\s*)(["']).*?\2/gi, '$1[REDACTED]')
.trim()
}
function stripLinearStackTrace(message: string): string {
for (let index = 0; index < message.length; index += 1) {
const code = message.charCodeAt(index)
if (code !== 10 && code !== 13) {
continue
}
let candidateStart = index + 1
if (code === 13 && message.charCodeAt(candidateStart) === 10) {
candidateStart += 1
}
while (
candidateStart < message.length &&
isLinearStackWhitespace(message.charCodeAt(candidateStart))
) {
candidateStart += 1
}
if (
message.startsWith('at', candidateStart) &&
isLinearStackWhitespace(message.charCodeAt(candidateStart + 2))
) {
return message.slice(0, index)
}
}
return message
}
function isLinearStackWhitespace(code: number): boolean {
return code === 32 || (code >= 9 && code <= 13)
}