Skip to content

feat(pass): add --env-file to pass run#526

Merged
joe0BAB merged 1 commit into
mainfrom
feat/pass-run-flags
May 26, 2026
Merged

feat(pass): add --env-file to pass run#526
joe0BAB merged 1 commit into
mainfrom
feat/pass-run-flags

Conversation

@joe0BAB
Copy link
Copy Markdown
Collaborator

@joe0BAB joe0BAB commented May 26, 2026

pass run now reads variables from one or more dotenv files in addition to the process environment, matching op run --env-file ergonomics.

  • --env-file FILE is repeatable.
  • Merge order: process env first, each file in order; later entries override earlier ones.
  • se:// references in file values resolve through the daemon the same way process env vars already do.
  • Missing or unreadable files are a hard error before exec — the child never starts with a partially-merged environment.

Parsing uses github.com/joho/godotenv to match real dotenv semantics (quoted values, comments, etc.) without hand-rolling a parser.

@joe0BAB joe0BAB marked this pull request as ready for review May 26, 2026 10:50
@joe0BAB joe0BAB force-pushed the feat/pass-run-flags branch 2 times, most recently from 9a7bb4f to 386852d Compare May 26, 2026 10:53
@joe0BAB
Copy link
Copy Markdown
Collaborator Author

joe0BAB commented May 26, 2026

/review

`pass run` now reads variables from one or more dotenv files in
addition to the process environment, matching `op run --env-file`
ergonomics.

- `--env-file FILE` is repeatable.
- Merge order: process env first, each file in order; later entries
  override earlier ones.
- `se://` references in file values resolve through the daemon the
  same way process env vars already do.
- Missing or unreadable files are a hard error before exec — the
  child never starts with a partially-merged environment.

Parsing uses github.com/joho/godotenv to match real dotenv semantics
(quoted values, comments, etc.) without hand-rolling a parser.

Signed-off-by: Johannes Großmann <grossmann.johannes@t-online.de>
@joe0BAB joe0BAB force-pushed the feat/pass-run-flags branch from 386852d to 0b001d3 Compare May 26, 2026 13:15
@joe0BAB
Copy link
Copy Markdown
Collaborator Author

joe0BAB commented May 26, 2026

/review

Copy link
Copy Markdown

@docker-agent docker-agent Bot left a comment

Choose a reason for hiding this comment

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

Assessment: 🟡 NEEDS ATTENTION

3 confirmed medium-severity bugs in the new --env-file implementation.

Comment thread vendor/github.com/joho/godotenv/parser.go
Comment thread plugins/pass/commands/run.go
}
}
for _, f := range files {
parsed, err := godotenv.Read(f)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

BUG: godotenv.Read expands $VAR using only the in-file variable map; process-env vars silently become empty strings

godotenv.Read(f) resolves $VAR references during parsing using only variables defined within the same file. The process environment is never consulted.

parsed, err := godotenv.Read(f)   //  expansion is in-file-only

Silent failure scenario: If a user writes a parameterised secret reference in their .env file:

# .env file
SE_TOKEN=se://$ACCOUNT/prod/db

expecting $ACCOUNT to come from the process environment, godotenv.Read silently expands it to the empty string, yielding se:///prod/db. This invalid path is then sent to the secrets daemon, which returns a cryptic error — the user has no indication that variable expansion failed.

Fix: Use godotenv.Parse (which returns raw values without expansion) instead of godotenv.Read, then perform variable expansion against the merged environment map after combining process env and file values:

parsed, err := godotenv.Parse(file)   // no expansion
// then apply os.Expand(v, mergedMap.Get) on values that contain $

Or at minimum, document this limitation prominently in the flag help text so users know $VAR in .env values only references other variables in the same file.

@joe0BAB joe0BAB merged commit 3097408 into main May 26, 2026
24 checks passed
@joe0BAB joe0BAB deleted the feat/pass-run-flags branch May 26, 2026 14:19
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.

2 participants