Repository navigation
Reject deploy-key lines without an equals sign - #119
Draft
posthog[bot] wants to merge 1 commit into
Draft
posthog[bot] wants to merge 1 commit into
posthog[bot] wants to merge 1 commit into
Conversation
parseEnvFile used indexOf("=") without checking for -1, so a malformed
line like CONVEX_PROD_DEPLOY_KEYX became the key CONVEX_PROD_DEPLOY_KEY
and passed the deploy-key presence check. Throw with the line number
instead, without echoing the line contents.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Generated-By: PostHog Desktop
Task-Id: 6e17da17-a2ab-4c0c-8076-becc8a5931c8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes PostHog Inbox report auth-env parser accepts lines without an equals sign.
Why: A malformed line in
deploy-keys.envshould stopscripts/auth-env.ts. Today the parser can instead turn it into a deploy key that looks valid.Root cause
parseEnvFilecalledline.indexOf("=")and never checked for-1. With no=,line.slice(0, -1)drops the last character to make the key, andline.slice(0)makes the whole line the value. SoCONVEX_PROD_DEPLOY_KEYXparsed as{ CONVEX_PROD_DEPLOY_KEY: "CONVEX_PROD_DEPLOY_KEYX" }and passed the deploy-key presence check.Change
=now throwsExpected KEY=value on line N. The message leaves out the line's contents so a secret can't end up in the terminal.=characters still parse as before; the existingdev:x=ytest covers this.scripts/auth-env.test.ts.Proof
Before the fix (new test only):
After the fix,
bun run test -- run scripts/auth-env.test.ts:tsc -p tsconfig.node.json,eslint, andprettier --checkon the changed files also pass.Created with PostHog Desktop
🤖 Generated with Claude Code