Skip to content

test : add unit tests for _sanitize_stderr helper #2298

Description

@tmdeveloper007

Summary of What Needs to be Done:
Add unit tests for the _sanitize_stderr helper function in backend/secuscan/parser_sandbox.py. This function strips file paths and Python line-number references from stderr output and truncates it to a maximum character count. It prevents internal file paths from leaking into logs.

Changes that Need to be Made:
Create testing/backend/unit/test_parser_sandbox_sanitize_stderr.py with tests for:

  • Unix paths replaced with [PATH] (e.g., /home/user/file.py)
  • Windows paths replaced with [PATH] (e.g., C:\Users\file.py)
  • Python line numbers replaced with [LINE] (e.g., line 42)
  • Multiple replacements in one string
  • Strings with no sensitive content passed through unchanged
  • Truncation to max_chars (default 500)
  • Custom max_chars parameter
  • Empty string handled correctly
  • Long output truncation preserves [PATH] and [LINE] replacements

Impact that it would Provide:
Improves test coverage for a security-sensitive output sanitization function. Ensures internal paths and line numbers cannot leak into logs or error messages shown to end users.

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions