Skip to content

Commit d322cf2

Browse files
authored
more redact (#29)
* more redact * format
1 parent 772c0ff commit d322cf2

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

lib/sandbox/creation.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,6 @@ export async function createSandbox(config: SandboxConfig, logger: TaskLogger):
7777
resources: { vcpus: config.resources?.vcpus || 4 },
7878
}
7979

80-
await logger.info(
81-
`Sandbox config: ${JSON.stringify(
82-
{
83-
...sandboxConfig,
84-
token: '[REDACTED]',
85-
source: { ...sandboxConfig.source, url: '[REDACTED]' },
86-
},
87-
null,
88-
2,
89-
)}`,
90-
)
91-
9280
// Call progress callback before sandbox creation
9381
if (config.onProgress) {
9482
await config.onProgress(25, 'Validating configuration...')
@@ -132,7 +120,7 @@ export async function createSandbox(config: SandboxConfig, logger: TaskLogger):
132120
await logger.error(`Sandbox creation failed: ${errorMessage}`)
133121
if (errorResponse) {
134122
await logger.error(`HTTP Status: ${errorResponse.status}`)
135-
await logger.error(`Response: ${JSON.stringify(errorResponse.data)}`)
123+
await logger.error(`Response: ${redactSensitiveInfo(JSON.stringify(errorResponse.data))}`)
136124
}
137125
throw error
138126
}

lib/utils/logging.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ export function redactSensitiveInfo(message: string): string {
2222
/Bearer\s+([a-zA-Z0-9_-]{20,})/gi,
2323
// Generic tokens
2424
/TOKEN[=\s]*["']?([a-zA-Z0-9_-]{20,})/gi,
25+
// Vercel Team IDs (team_xxxx or alphanumeric strings after VERCEL_TEAM_ID)
26+
/VERCEL_TEAM_ID[=\s:]*["']?([a-zA-Z0-9_-]{8,})/gi,
27+
// Vercel Project IDs (prj_xxxx or alphanumeric strings after VERCEL_PROJECT_ID)
28+
/VERCEL_PROJECT_ID[=\s:]*["']?([a-zA-Z0-9_-]{8,})/gi,
29+
// Vercel tokens (any alphanumeric strings after VERCEL_TOKEN)
30+
/VERCEL_TOKEN[=\s:]*["']?([a-zA-Z0-9_-]{20,})/gi,
2531
]
2632

2733
// Apply redaction patterns
@@ -47,9 +53,14 @@ export function redactSensitiveInfo(message: string): string {
4753
})
4854
})
4955

56+
// Redact JSON field patterns (for teamId, projectId in JSON objects)
57+
redacted = redacted.replace(/"(teamId|projectId)"[\s:]*"([^"]+)"/gi, (match, fieldName) => {
58+
return `"${fieldName}": "[REDACTED]"`
59+
})
60+
5061
// Redact environment variable assignments with sensitive values
5162
redacted = redacted.replace(
52-
/([A-Z_]*(?:KEY|TOKEN|SECRET|PASSWORD)[A-Z_]*)[=\s]*["']?([a-zA-Z0-9_-]{8,})["']?/gi,
63+
/([A-Z_]*(?:KEY|TOKEN|SECRET|PASSWORD|TEAM_ID|PROJECT_ID)[A-Z_]*)[=\s:]*["']?([a-zA-Z0-9_-]{8,})["']?/gi,
5364
(match, varName, value) => {
5465
const redactedValue =
5566
value.length > 8

0 commit comments

Comments
 (0)