Skip to content

feat(cli): validate sensitive fields require env() references#110

Open
tonychang04 wants to merge 10 commits into
mainfrom
feat/insforge-toml-secrets-validation
Open

feat(cli): validate sensitive fields require env() references#110
tonychang04 wants to merge 10 commits into
mainfrom
feat/insforge-toml-secrets-validation

Conversation

@tonychang04
Copy link
Copy Markdown
Contributor

@tonychang04 tonychang04 commented May 7, 2026

Summary

  • Adds parseEnvRef() and validateSensitiveString() in src/lib/config-secrets.ts
  • Sensitive TOML fields (OAuth client_secret, SMTP password, S3 secret key, etc.) MUST be env(NAME) references — never literal values
  • Same convention as Vercel/Fly.io/Supabase: makes insforge.toml unconditionally safe to commit to git
  • Foundation laid but not yet wired — first consumer will be [email.smtp] or [auth.providers.<built_in>]

Why this is a separate branch

The MVP scope on feat/insforge-toml-mvp (PR #109) is [auth] allowed_redirect_urls only — zero sensitive fields, so the validator wouldn't be exercised. This branch lands the foundation so the next sensitive section to ship has the validator ready to register.

Test plan

  • 6 vitest cases in src/lib/config-secrets.test.ts — all pass
  • Full src/lib test suite (18 tests across config-toml, config-diff, config-format, config-secrets) passes
  • Wired into validateConfig() when first sensitive field section ships

🤖 Generated with Claude Code


Summary by cubic

Adds insforge.toml support to the CLI (export, plan, apply) for [auth] allowed_redirect_urls, and lays the groundwork to require env(NAME) refs for sensitive fields. Also fixes re-link to replace masked DATABASE_URL passwords with the real value.

  • New Features

    • insforge config subcommands:
      • export writes live config to insforge.toml; plan shows a human-readable diff; apply updates the project via PUT /api/auth/config.
    • Config schema/codec for v1: InsforgeConfig with [auth].allowed_redirect_urls, TOML parsing/formatting via smol-toml, and deterministic output.
    • Structured diff and plan: diffConfig() and formatPlan() for clear change summaries.
    • Sensitive-field validation foundation: parseEnvRef() and validateSensitiveString() enforce env(NAME) (UPPER_SNAKE_CASE) with actionable errors; wiring will happen when SMTP/OAuth sections land.
  • Bug Fixes

    • refreshStaleEnvDefaults now refreshes .env.local values that contain masked passwords (:****@) to the real platform value during re-link.

Written for commit 150ef30. Summary will update on new commits.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03f54bfe-c725-4650-a3fc-75cdad776daf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/insforge-toml-secrets-validation

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

tonychang04 and others added 10 commits May 11, 2026 22:09
Sensitive fields in insforge.toml (OAuth client_secret, SMTP password,
S3 secret key, etc.) MUST be env(NAME) references — never literal
values. Same convention as Vercel/Fly.io/Supabase, makes the file
unconditionally safe to commit to git.

parseEnvRef() extracts the secret name from a well-formed env(NAME)
reference (NAME must be UPPER_SNAKE_CASE).

validateSensitiveString() throws ConfigValidationError with an
actionable message naming the exact 'insforge secrets add' command
when a literal is pasted in place of an env() ref.

Foundation laid but not yet wired — first consumer will be
[email.smtp] or [auth.providers.<built_in>], whichever ships next.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tonychang04 tonychang04 force-pushed the feat/insforge-toml-secrets-validation branch from 44496e6 to 150ef30 Compare May 12, 2026 05:12
@tonychang04 tonychang04 changed the base branch from feat/insforge-toml-mvp to main May 12, 2026 05:13
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.

1 participant