@@ -127,12 +127,18 @@ const STANDALONE_ASSIGNMENT_REDACT_PATTERN = String.raw`(^|[\s,;])(?:${STANDALON
127127// data-URL media is never corrupted while tokens in URL paths or assignments still redact.
128128const BASE64_SAFE_TOKEN_BOUNDARY = String . raw `(^|[^A-Za-z0-9])(?<!;base64,[A-Za-z0-9+/=]*)` ;
129129const IDENTIFIER_SAFE_TOKEN_BOUNDARY = String . raw `(^|[^A-Za-z0-9_])` ;
130+ const TELEGRAM_BOT_TOKEN_REDACT_PATTERN = String . raw `\bbot(\d{6,}:[A-Za-z0-9_-]{20,})\b` ;
131+ const TELEGRAM_TOKEN_REDACT_PATTERN = String . raw `\b(\d{6,}:[A-Za-z0-9_-]{20,})\b` ;
130132const SHELL_REFERENCE_PRESERVING_PATTERN_SOURCES = new Set ( [
131133 ENV_ASSIGNMENT_REDACT_PATTERN ,
132134 ESCAPED_ENV_ASSIGNMENT_REDACT_PATTERN ,
133135 STANDALONE_ASSIGNMENT_QUOTED_REDACT_PATTERN ,
134136 STANDALONE_ASSIGNMENT_REDACT_PATTERN ,
135137] ) ;
138+ const CHUNK_UNSAFE_PATTERN_SOURCES = new Set ( [
139+ TELEGRAM_BOT_TOKEN_REDACT_PATTERN ,
140+ TELEGRAM_TOKEN_REDACT_PATTERN ,
141+ ] ) ;
136142const shellReferencePreservingPatterns = new WeakSet < RegExp > ( ) ;
137143// Patterns whose left-context assertions or complete token can cross a chunk boundary must run
138144// against the full string; chunking can invent a `^` boundary or split the secret itself.
@@ -251,8 +257,8 @@ const DEFAULT_REDACT_PATTERNS: string[] = [
251257 String . raw `(api_org_[A-Za-z0-9]{20,})` ,
252258 String . raw `(r8_[A-Za-z0-9]{10,})` ,
253259 // Telegram Bot API URLs embed the token as `/bot<token>/...` (no word-boundary before digits).
254- String . raw `\bbot(\d{6,}:[A-Za-z0-9_-]{20,})\b` ,
255- String . raw `\b(\d{6,}:[A-Za-z0-9_-]{20,})\b` ,
260+ TELEGRAM_BOT_TOKEN_REDACT_PATTERN ,
261+ TELEGRAM_TOKEN_REDACT_PATTERN ,
256262] ;
257263let defaultResolvedPatterns : RegExp [ ] | undefined ;
258264
@@ -323,7 +329,9 @@ function parsePattern(raw: RedactPattern): RegExp | null {
323329 if (
324330 pattern &&
325331 typeof raw === "string" &&
326- ( raw . startsWith ( BASE64_SAFE_TOKEN_BOUNDARY ) || raw . startsWith ( IDENTIFIER_SAFE_TOKEN_BOUNDARY ) )
332+ ( raw . startsWith ( BASE64_SAFE_TOKEN_BOUNDARY ) ||
333+ raw . startsWith ( IDENTIFIER_SAFE_TOKEN_BOUNDARY ) ||
334+ CHUNK_UNSAFE_PATTERN_SOURCES . has ( raw ) )
327335 ) {
328336 chunkUnsafePatterns . add ( pattern ) ;
329337 }
0 commit comments