Skip to content

Commit 39f61c9

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
fix(redaction): cover namespaced secret fields
1 parent f4f088e commit 39f61c9

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

apps/sim/lib/core/security/redaction.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@ describe('redactSensitiveValues', () => {
198198
expect(result).not.toContain('key123456')
199199
})
200200

201+
it.concurrent('should redact dotted and parenthesized sensitive fields', () => {
202+
const result = redactSensitiveValues(
203+
`stripe.api_key: "stripe-secret" (password: 'password-value') service.SyncToken: "3"`
204+
)
205+
206+
expect(result).toBe(
207+
`stripe.api_key: "${REDACTED_MARKER}" (password: '${REDACTED_MARKER}') service.SyncToken: "3"`
208+
)
209+
})
210+
201211
it.concurrent('should redact equals-style sensitive fields', () => {
202212
const result = redactSensitiveValues(
203213
`password="password-value" token='token-value' api_key="api-key-value" SyncToken="3"`

apps/sim/lib/core/security/redaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ const SENSITIVE_VALUE_PATTERNS: Array<{
7171
]
7272

7373
const STRING_FIELD_PATTERNS = [
74-
/(^|[{,\s])(["']?)([A-Za-z0-9_-]+)\2(\s*[:=]\s*)("(?:\\.|[^"\\])*")/gm,
75-
/(^|[{,\s])(["']?)([A-Za-z0-9_-]+)\2(\s*[:=]\s*)('(?:\\.|[^'\\])*')/gm,
74+
/(^|[^A-Za-z0-9_.-])(["']?)([A-Za-z0-9_.-]+)\2(\s*[:=]\s*)("(?:\\.|[^"\\])*")/gm,
75+
/(^|[^A-Za-z0-9_.-])(["']?)([A-Za-z0-9_.-]+)\2(\s*[:=]\s*)('(?:\\.|[^'\\])*')/gm,
7676
]
7777

7878
export function isSensitiveKey(key: string): boolean {

0 commit comments

Comments
 (0)