(
code: string,
agent: CompleteAgent,
memory: string,
uploadType: 'existing' | 'file' | 'edit'
)
| 269 | // Check for sensitive functions and passphrases in code; auto-strip passphrases |
| 270 | // and show a warning/notice if anything was found or needs review |
| 271 | const checkForSensitiveData = ( |
| 272 | code: string, |
| 273 | agent: CompleteAgent, |
| 274 | memory: string, |
| 275 | uploadType: 'existing' | 'file' | 'edit' |
| 276 | ): boolean => { |
| 277 | // Whitelist passphrases are bearer codes — strip them automatically, no opt-out |
| 278 | const passphraseResult = redactPassphrases(code); |
| 279 | const sanitizedCode = passphraseResult.redactedCode; |
| 280 | |
| 281 | const detection = detectSensitiveFunctions(sanitizedCode); |
| 282 | const hasPassphrases = passphraseResult.removedCount > 0; |
| 283 | |
| 284 | if (detection.hasSensitiveData || hasPassphrases) { |
| 285 | // Store upload data for later (already sanitized of passphrases) |
| 286 | setPendingUpload({ |
| 287 | type: uploadType, |
| 288 | agent, |
| 289 | code: sanitizedCode, |
| 290 | memory |
| 291 | }); |
| 292 | |
| 293 | // Set warning modal data |
| 294 | setDetectedFunctions(detection.detectedFunctions); |
| 295 | setWarningLineNumbers(detection.lineNumbers); |
| 296 | setWarningCodePreview(sanitizedCode); |
| 297 | setRemovedPassphraseCount(passphraseResult.removedCount); |
| 298 | setRemovedPassphraseLines(passphraseResult.lineNumbers); |
| 299 | setShowPersonalInfoWarning(true); |
| 300 | |
| 301 | return true; // Sensitive data found or removed |
| 302 | } |
| 303 | |
| 304 | return false; // Nothing found |
| 305 | }; |
| 306 | |
| 307 | // Handle warning modal cancel |
| 308 | const handleWarningCancel = () => { |
no test coverage detected