Skip to content

[CLI]: broaden spawn export secret-scan regex #3381

Open

Description

@la14-1

What would you like?

spawn export scans staged files for known API-key shapes before creating the GitHub repo (packages/cli/src/commands/export.ts, the SECRET_REGEX in step 9). The current pattern covers OpenRouter (v1 only), Anthropic, OpenAI, GitHub, AWS, Hetzner, DigitalOcean, and PEM private keys. Worth widening before the feature sees wider use, since public-visibility exports depend on this as the last line of defence:

  • OpenRouter: tighten from sk-or-v1-[a-f0-9]{20,} to sk-or-[a-zA-Z0-9_-]{20,} so future-prefixed keys (sk-or-v2-…) and keys with non-hex chars still match.
  • Slack: xox[abp]-[0-9A-Za-z-]{10,} (bot/user/app tokens).
  • Google service-account JSON: matches the full \"type\":\\s*\"service_account\" block — BEGIN PRIVATE KEY already catches the key itself but not the surrounding creds JSON typical in ~/.config/gcloud/.
  • Generic bearer headers in committed scripts: Authorization:\\s*Bearer\\s+[A-Za-z0-9._-]{20,} — noisier but worth considering behind a --strict mode.
  • Stripe live keys: sk_live_[A-Za-z0-9]{24,}.
  • Discord bot tokens: [A-Za-z0-9_-]{24}\\.[A-Za-z0-9_-]{6}\\.[A-Za-z0-9_-]{27,}.

Context

Follow-up from the review of #3377. The default is now private (b96e643) and an interactive "make public?" prompt gates the visibility flip, so this is defence-in-depth rather than an acute leak. But public exports exist and the regex is the only runtime check, so coverage gaps here matter.

Suggested approach

  • Extract SECRET_REGEX to a named constant in export.ts (currently embedded in the bash script) with a comment per provider family.
  • Add a unit test matrix that feeds sample keys for each provider through grep -E against the regex to prevent regressions.
  • Consider a --strict flag that additionally runs gitleaks if available on the VM, with a clean fallback to the built-in regex.

Filed from Slack by SPA

Activity

  1. added
    enhancementNew feature or request
    pending-reviewIssue awaiting initial review
    cliCLI feature or bug
    on May 2, 2026
  2. la14-1 commented on May 2, 2026

    @la14-1
    CollaboratorAuthor

    Acknowledged. Categorized as enhancement/cli — broadening the SECRET_REGEX in spawn export to cover additional provider key formats (Slack, Stripe, Discord, Google service-account, generic Bearer headers) and future-proof the OpenRouter pattern.

    This is a well-scoped follow-up from #3377. Delegating to the security-auditor teammate for implementation — the regex changes and test matrix are a good fit for that role.

    Progressing from pending-review → under-review.

    -- refactor/community-coordinator

  3. added
    under-reviewIssue is being reviewed by the team
    and removed
    pending-reviewIssue awaiting initial review
    on May 2, 2026
  4. la14-1 commented on May 2, 2026

    @la14-1
    CollaboratorAuthor

    Fix in #3386.

    -- refactor/community-coordinator

  5. la14-1 commented on May 2, 2026

    @la14-1
    CollaboratorAuthor

    Tracked — fix is in progress in PR #3386.

    -- refactor/community-coordinator

  6. added a commit that references this issue on May 7, 2026
    0e0ca56
  7. la14-1 commented on May 7, 2026

    @la14-1
    CollaboratorAuthor

    Fix in #3386.

    -- refactor/community-coordinator

  8. added 4 commits that reference this issue on May 9, 2026
    e8e7ed9
    1860fd5
    4561048
    f1e701a
  9. added a commit that references this issue on May 21, 2026
    8f4b4a3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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