Skip to content

Conversation

@waleedlatif1
Copy link
Collaborator

Summary

  • consolidate redaction utils, apply them to inputs and outputs before persisting logs

Type of Change

  • New feature

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Dec 19, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Dec 19, 2025 9:03pm

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 19, 2025

Greptile Summary

  • Consolidates scattered redaction utilities across the codebase into a centralized redaction.ts module with comprehensive pattern matching for sensitive data like API keys, passwords, and tokens
  • Updates terminal console store and instrumentation client to apply redaction to both input and output fields before persisting data to ensure consistent security practices
  • Replaces hardcoded redaction markers with a standardized REDACTED_MARKER constant and moves existing redaction tests to the new dedicated test file

Important Files Changed

Filename Overview
apps/sim/lib/core/security/redaction.ts New centralized redaction module with pattern-based sensitive key detection; contains overly broad regex patterns that may cause false positives
apps/sim/stores/terminal/console/store.ts Updated to apply redaction to both inputs and outputs before persisting console entries; inherits pattern matching issues from new redaction module
apps/sim/instrumentation-client.ts Replaced inline sanitization function with centralized redaction utility; may over-redact telemetry data due to pattern matching issues

Confidence score: 2/5

  • This PR requires careful review due to critical pattern matching issues that will cause over-redaction and false positives in production
  • Score lowered due to overly broad regex patterns in SENSITIVE_KEY_PATTERNS (like /^.*token$/i, /^.*secret$/i) that will match legitimate keys such as tokenCount, hasSecret, userAuthenticated, etc.
  • Pay close attention to apps/sim/lib/core/security/redaction.ts - the pattern matching logic needs refinement to avoid breaking legitimate functionality

Sequence Diagram

sequenceDiagram
    participant User
    participant StagehandAPI as "Stagehand API"
    participant ValidationService as "Validation Service"
    participant RedactionService as "Redaction Service"
    participant Stagehand
    participant Browser as "Browserbase"

    User->>StagehandAPI: "POST /api/tools/stagehand/agent"
    StagehandAPI->>ValidationService: "validate request schema"
    ValidationService-->>StagehandAPI: "validation result"
    StagehandAPI->>RedactionService: "sanitize variables for logging"
    RedactionService-->>StagehandAPI: "sanitized variables"
    StagehandAPI->>Stagehand: "initialize with Browserbase"
    Stagehand-->>StagehandAPI: "initialized instance"
    StagehandAPI->>Browser: "navigate to startUrl"
    Browser-->>StagehandAPI: "page loaded"
    StagehandAPI->>Stagehand: "create agent with instructions"
    Stagehand-->>StagehandAPI: "agent instance"
    StagehandAPI->>Stagehand: "execute task with variables"
    Stagehand-->>StagehandAPI: "agent execution result"
    StagehandAPI->>StagehandAPI: "parse structured output from result"
    StagehandAPI->>Stagehand: "close instance"
    StagehandAPI-->>User: "return agent result and structured output"
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1
Copy link
Collaborator Author

@greptile

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@waleedlatif1 waleedlatif1 merged commit 65efa03 into staging Dec 19, 2025
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/terminal branch December 19, 2025 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants