Portal Community

What sanitize() Strips

PatternReplacementExamples
JWT tokens (three base64url segments)[REDACTED:JWT]Bearer eyJhbG...
16-digit credit card patterns[REDACTED:CC]4111111111111111
Known password field names + valuepassword=[REDACTED]password=secret123
Known secret field names + valueapiKey=[REDACTED]apiKey=sk-abc123
HTML tagsTags stripped, text retained<script>alert()</script>
User home directory paths[REDACTED:PATH]C:\Users\binoy\secrets.json

sanitize() Source

// flow-observer-core/src/sanitization/sanitize.ts
const JWT_PATTERN = /\beyJ[\w-]+\.[\w-]+\.[\w-]+\b/g;
const CC_PATTERN = /\b\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}\b/g;
const PASSWORD_PATTERN = /\b(password|passwd|secret|apikey|api_key|token)\s*=\s*\S+/gi;
const HTML_PATTERN = /<[^>]+>/g;
const HOME_PATH_WIN = /C:\\Users\\[^\\]+\\/gi;
const HOME_PATH_UNIX = /\/home\/[^/]+\//gi;

export function sanitize(text: string): string {
  return text
    .replace(JWT_PATTERN, '[REDACTED:JWT]')
    .replace(CC_PATTERN, '[REDACTED:CC]')
    .replace(PASSWORD_PATTERN, (m, key) => `${key}=[REDACTED]`)
    .replace(HTML_PATTERN, '')
    .replace(HOME_PATH_WIN, '[REDACTED:PATH]\\')
    .replace(HOME_PATH_UNIX, '[REDACTED:PATH]/');
}

When Sanitization Runs

Sanitization runs on the display path only — not in the buffer. The raw log entry (with all original fields) is stored in flowObserverPanelStore.logs. The sanitize() call happens inside the LogRow render function:

// Inside LogRow component
const displayMessage = useMemo(
  () => sanitize(log.message),
  [log.message]
);

This means the Log Detail tab shows the sanitized version, and the text search also operates on sanitized text.

Not a Security Boundary Sanitization is a UI convenience to prevent accidental credential exposure in shared screen sessions or screenshots. The raw log data is transmitted over the authenticated WebSocket connection. Do not rely on sanitize() as a security control — sanitize sensitive data at the source (the executor) instead.