Repository navigation
feat(cli): add runtime credential injection command with log stream redaction - #12
Conversation
|
AI review | Looks safe to merge Adds a Reviewed 5340434. AI can be wrong, a maintainer still decides. Comment |
LukeGus
left a comment
There was a problem hiding this comment.
Thanks for this, the idea fits the CLI. A few things need to change before it can go in:
- Name based variables can overwrite the environment. A credential named
Path,HomeorNode OptionssetsPATH,HOMEorNODE_OPTIONSto the password. Only set theTERMIX_<ID>_*names by default, and add an opt in flag like--namesthat refuses any name already inprocess.env. - Too many names per credential. Keep one set:
TERMIX_<ID>_USERNAME,TERMIX_<ID>_PASSWORD,TERMIX_<ID>_KEY(and the name based ones only behind the flag above). - Drop the
/plugin-api/import-export/exportfallback. It pulls every host's secrets (and is audited as a full export) just to find one key. If/credentials/:idhas no key, fail with a clear message. - Use commander for the
--split instead of readingprocess.argvby hand (.passThroughOptions()with a variadic argument). As written,termix --server x inject ...or a host namedinjectbreaks the parsing. - Masking: piping stdout and stderr turns off the TTY for the child, so interactive programs, colors and prompts break, and a secret split across two chunks is not masked. Make masking opt in (
--mask), inherit stdio otherwise, and keep the lastmaxSecretLength - 1bytes of each chunk to mask across chunk edges. - Forward signals (SIGINT, SIGTERM) to the child and exit with its code, and add a
## 1.3.0CHANGELOG bullet plus a short section in the README command list. - Please retarget nothing yourself, I moved the base to
dev-1.3.0.
Tests for 1, 4 and 5 would be great.
bacf22b to
0ed8581
Compare
|
Thanks for the thorough review, @LukeGus! All requested changes have been addressed:
|
0ed8581 to
ab83b81
Compare
LukeGus
left a comment
There was a problem hiding this comment.
Thanks, the command and the masking tests look good. One thing blocks it: program.enablePositionalOptions() in src/index.ts changes every command. Global flags are now only accepted before the subcommand, so termix hosts list --json and termix hosts list --url ... fail with unknown option. On dev-1.3.0 both work.
Please keep global options working after any subcommand. One way: drop enablePositionalOptions() and passThroughOptions(), use .allowUnknownOption() on inject, and read the command to run from process.argv after the first --. Add a test that termix hosts list --json still parses.
Also, bad input like a missing -- or an invalid id should exit with the usage code, not the internal error code.
- enforce TERMIX_<ID>_USERNAME, TERMIX_<ID>_PASSWORD, TERMIX_<ID>_KEY - gate friendly env names behind --names with process.env collision checks - remove export fallback endpoint - use native commander passThroughOptions with positional args - make stream masking optional via --mask and implement sliding window buffer - forward SIGINT/SIGTERM and propagate child exit code - update CHANGELOG.md, README.md, and add unit tests
… 2 on inject usage errors
ab83b81 to
4ec3117
Compare
LukeGus
left a comment
There was a problem hiding this comment.
Thanks, this is a nice addition. A few changes before it can go in:
- In the close handler, a child killed by any signal other than SIGINT or SIGTERM (SIGKILL, SIGHUP, an OOM kill) exits 0. Exit with 128 plus the signal number (os.constants.signals[signal]) so scripts see the failure.
- Two credentials whose names normalize to the same variable (like 'Stripe API Key' and 'stripe-api-key') silently overwrite each other. Please refuse with a clear error, or skip the name based variables for those and say so on stderr.
- Masking works per chunk, so a secret split across two stdout chunks can print unmasked. Keep the last (longest secret length - 1) bytes back between chunks before masking, and flush them on close. A test for a secret split over two writes would cover it.
- Add a short section on inject to the README's command list and to the CLI docs page in Termix-SSH/Docs if you can, so people find it.
LukeGus
left a comment
There was a problem hiding this comment.
Thanks @CesarSanch1998. Your last round covered the name clashes and split secrets. I added the 128 plus signal exit code, kept multi byte characters whole across chunks, merged dev-1.3.1 and wrote the docs section.
* fix: update zod and override minimatch for audit advisories * chore: harden workflows, pin actions and add Dependabot for actions * chore: run installs without scripts and lint the lockfile * chore: drop overwrite mode, release as draft then publish * feat: attest build provenance for release binaries * feat: api-keys create takes read and full scopes and --never-expires * fix: drop the npm cache from the release job that holds the App key * fix: pin postject and build the binary without a shell * chore: run CI on free GitHub runners * chore: update dependencies (#28) * chore: update dependencies * chore: keep typescript below 7 until the tooling supports it * fix: keep the original error as cause when rethrowing * feat: users disable/enable, invite links and access-review commands * feat(cli): add runtime credential injection command with log stream redaction (#12) * feat(cli): add inject command for runtime credential injection with stream redaction * feat(cli): address review feedback for inject command - enforce TERMIX_<ID>_USERNAME, TERMIX_<ID>_PASSWORD, TERMIX_<ID>_KEY - gate friendly env names behind --names with process.env collision checks - remove export fallback endpoint - use native commander passThroughOptions with positional args - make stream masking optional via --mask and implement sliding window buffer - forward SIGINT/SIGTERM and propagate child exit code - update CHANGELOG.md, README.md, and add unit tests * fix(cli): allow global options after subcommands and return exit code 2 on inject usage errors * fix: exit 128 plus signal when the child is killed, keep split utf-8 whole --------- Co-authored-by: LukeGus <bugattiguy527@gmail.com> * chore: bring in main --------- Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: CesarSanch1998 <100056699+CesarSanch1998@users.noreply.github.com>
* fix: update zod and override minimatch for audit advisories * chore: harden workflows, pin actions and add Dependabot for actions * chore: run installs without scripts and lint the lockfile * chore: drop overwrite mode, release as draft then publish * feat: attest build provenance for release binaries * feat: api-keys create takes read and full scopes and --never-expires * fix: drop the npm cache from the release job that holds the App key * fix: pin postject and build the binary without a shell * chore: run CI on free GitHub runners * chore: update dependencies (#28) * chore: update dependencies * chore: keep typescript below 7 until the tooling supports it * fix: keep the original error as cause when rethrowing * feat: users disable/enable, invite links and access-review commands * feat(cli): add runtime credential injection command with log stream redaction (#12) * feat(cli): add inject command for runtime credential injection with stream redaction * feat(cli): address review feedback for inject command - enforce TERMIX_<ID>_USERNAME, TERMIX_<ID>_PASSWORD, TERMIX_<ID>_KEY - gate friendly env names behind --names with process.env collision checks - remove export fallback endpoint - use native commander passThroughOptions with positional args - make stream masking optional via --mask and implement sliding window buffer - forward SIGINT/SIGTERM and propagate child exit code - update CHANGELOG.md, README.md, and add unit tests * fix(cli): allow global options after subcommands and return exit code 2 on inject usage errors * fix: exit 128 plus signal when the child is killed, keep split utf-8 whole --------- Co-authored-by: LukeGus <bugattiguy527@gmail.com> * chore: bring in main * fix: build the windows binary in bash so the asset name reaches npm --------- Co-authored-by: LukeGus <bugattiguy527@gmail.com> Co-authored-by: Luke Gustafson <88517757+LukeGus@users.noreply.github.com> Co-authored-by: CesarSanch1998 <100056699+CesarSanch1998@users.noreply.github.com>
Summary
This PR introduces the
termix injectcommand, allowing developers to securely fetch credentials stored in Termix and inject them directly into a child process's environment in memory at runtime (similar to Infisical or Vault agent injection).Motivation
Developers often need to run scripts, CLI commands, or microservices that require credentials (API keys, database passwords, SSH private keys) stored in Termix, without:
.envfiles..bash_historyor/proc/<pid>/cmdline.Key Security Features
stdoutandstderrstreams in real time.[REDACTED_BY_TERMIX].print, debug tracebacks, or unhandled exceptions.TERMIX_<ID>_USER,TERMIX_<ID>_PASS,TERMIX_<ID>_KEY.Stripe API Keywill be available asSTRIPE_API_KEYandSTRIPE_API_KEY_PASSWORD.Syntax & Usage Examples
Basic syntax:
Example 1: Running a Python script with an API key
Example 2: Multiple credentials (e.g., DB and API keys)
Example 3: Running a curl command without hardcoding tokens
termix inject 8 -- bash -c 'curl -X POST https://api.example.com -H "Authorization: Bearer $API_KEY"'Verification & Testing
test/inject.test.tscovering:normalizeEnvName).maskSecrets).tsc --noEmit).