Skip to content

security: replace env-or-default patterns with fail-closed requireEnv helper (#444) - #543

Merged
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
davidsoniaudin2-oss:security/fail-closed-env-revalidate
Jun 28, 2026
Merged

security: replace env-or-default patterns with fail-closed requireEnv helper (#444)#543
nanaf6203-bit merged 1 commit into
MettaChain:mainfrom
davidsoniaudin2-oss:security/fail-closed-env-revalidate

Conversation

@davidsoniaudin2-oss

@davidsoniaudin2-oss davidsoniaudin2-oss commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Description

Replaces env-or-default patterns in API routes with a centralized fail-closed
equireEnv\ helper.

Changes

  • Create \src/lib/requireEnv.ts\ with
    equireEnv\ and
    equireEnvStrict\ functions
  • Fix \src/app/api/revalidate/route.ts\ - remove hardcoded fallback REVALIDATE_WEBHOOK_SECRET, use
    equireEnvStrict\ instead
  • Add comprehensive test suite for requireEnv helpers

Related Issues

Closes #441 - hardcoded fallback REVALIDATE_WEBHOOK_SECRET
Closes #444 - replace env-or-default patterns with fail-closed helpers
closes #443
closes #447

… helper (MettaChain#441, MettaChain#444)

- Remove hardcoded fallback REVALIDATE_WEBHOOK_SECRET from revalidate route
- Create centralized requireEnv/requireEnvStrict helpers in src/lib/requireEnv.ts
- Add test suite for requireEnv helpers
- requireEnvStrict throws in all environments when env var is missing
- requireEnv provides optional default with dev-only warning
@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@davidsoniaudin2-oss Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Copy link
Copy Markdown
Contributor

Fail-closed is the right call. Merging.

@nanaf6203-bit
nanaf6203-bit merged commit 00ecbce into MettaChain:main Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants