Skip to content

[CLI]: end-to-end test for spawn export redact pass (sed, grep, regex) #3385

@la14-1

Description

@la14-1

What would you like?

The export test suite covers buildExportScript as string assertions and the host-side orchestration via injected runners, but nothing actually executes the generated bash against a temp directory containing planted fake secrets. That gap let #3383 ship with a sed delimiter bug that only surfaced at VM runtime (unknown option to 'sed s'). #3384 fixed it, but the gap remains.

Suggested test

In packages/cli/src/__tests__/export.test.ts, add a test that:

  1. Generates the script with allowRedact: true.
  2. Extracts just the "SECRETS SCAN — redact" block (step 9) into a temp .sh file.
  3. Creates a temp git init directory with a file containing a synthetic match for each regex family (e.g. sk-or-v1-00000000000000000000, sk-ant-api0_ + 20 chars, etc.).
  4. Runs bash <tempfile> and asserts:
    • The file no longer contains the synthetic match.
    • It contains ***REDACTED-BY-SPAWN-EXPORT***.
    • git diff --cached shows the redaction.

Why

  • bash -n is syntax-only — it doesn't catch runtime quoting/escaping bugs like sed s|…|…|g colliding with | in the pattern.
  • Redaction is now the last line of defence before a (possibly public) gh repo create --push. Any regression here ships secrets.
  • A happy-path subprocess test is OK per project testing rules — the rule bans subprocess-driven unit tests of cloud behaviour; a purely local bash <temp.sh> against a sandbox git init is deterministic, fast, and doesn't hit any network.

Related

Filed from Slack by SPA

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliCLI feature or bugenhancementNew feature or requestin-progressIssue is being actively worked onunder-reviewIssue is being reviewed by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions