@kaynooo/cli-env 0.14.1 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ev and redact
2
2
 
3
- Two CLIs that keep secrets out of a Claude Code transcript: `ev` lists and edits `.env` files with every secret masked, and `redact` masks secrets in any piped output.
3
+ `ev` keeps secrets out of a Claude Code transcript: it lists and edits `.env` files with every secret masked, and `ev redact` masks secrets in any piped output.
4
4
 
5
5
  ```sh
6
6
  bun install -g @kaynooo/cli-env
@@ -22,29 +22,31 @@ bun install -g @kaynooo/cli-env
22
22
  | `ev diff <a> <b>` | names the keys set in one file and not the other, exit 1 when they differ; `--json` prints `{a, b, onlyA, onlyB}` |
23
23
  | `ev missing [file]` | names the keys of `.env.example` (`--against`) that the file lacks, exit 1 when some are; `--json` prints `{a, b, onlyA, onlyB}` with the reference as `a` |
24
24
  | `ev pins [dir]` | checks an app's tests pin the env that reaches outside (see below), exit 1 when something is unpinned |
25
- | `ev audit [dir...]` | lists the `.env` files any account can read or git tracks, and the compose files any account can read that write a secret or URL password out, with the fix for each, exit 1 when it finds one |
25
+ | `ev audit [dir...]` | lists the `.env` files any account can read or git tracks, and the compose files any account can read that write a secret or URL password out, never printing a value, with the fix for each, exit 1 when it finds one; it looks down to 5 levels, skipping `node_modules`, `vendor`, `.git` and `.example`, `.sample`, `.template` and `.dist` files, and names a folder it cannot read on stderr |
26
26
  | `ev audit --fix [dir...]` | moves each secret a listed compose file writes out into the `.env` beside it as `${KEY}` (a key the `.env` sets to another value stays put), puts it back when `docker compose config` resolves differently, and shuts other accounts out of both files and of every listed `.env`; exit 1 when something is left |
27
27
 
28
- `ev pins` lists, by name only, the optional URL, key, token, secret, password and host variables of the app's `defineEnv` schema that no `.env.test` entry, test `overrideEnv` or local bunfig preload dropping what `.env` sets pins, and each test file calling `testSite` or `proxyKeyTests` without pinning them. `// ev pins: none reached, <why>` exempts a file.
28
+ `ev pins` lists, by name only, the optional URL, key, token, secret, password and host variables of the app's `defineEnv` schema that no `.env.test` entry, test `overrideEnv` or local bunfig preload dropping what `.env` sets pins, and each test file calling `testSite` or `proxyKeyTests` without pinning them. `// ev pins: none reached, <why>` exempts a file. The `dir` is an app, or a monorepo holding apps one level down (the current folder by default); only variable names are read.
29
29
 
30
30
  A value is masked when its key is named like a secret (`TOKEN`, `SECRET`, `PASSWORD`, `PASS`, `PWD`, `KEY`, `PRIVATE`, `DSN`, `AUTH`, `SALT`, `COOKIE`, `CREDENTIALS`, the definition `isSecretName` of `@kaynooo/cli-kit` that `db` shares), when it equals a secret value of the folder's `.env*` files whatever its own key, when it is a private key (PEM or PGP, also escaped on one line), or in the password part of any URL (`postgres://user:***@host/db`) and any known token format (GitHub, GitLab, Slack, AWS, npm, Stripe, Google, SendGrid, `sk-`, JWTs, `Authorization` credentials and `password=`/`secret=` pairs). A URL is also masked where it carries a token, whatever its key is named: the last segment of a Discord, Slack, Uptime Kuma push or healthchecks.io ping URL, any path segment of 20 or more characters of `A-Za-z0-9_-` mixing lowercase, uppercase and digits, any path segment of 32 or more letters and digits of any case (hex, base32, dashless UUIDs), and the value of a query parameter named `token`, `key`, `apikey`, `secret`, `password`, `sig`, `signature`, `auth` or ending in `_token` or `_secret`; the host and the rest of the URL stay readable. A masked value keeps a few leading characters and its length (`ghp***(40)`) so two values can be told apart. There is no flag that prints a secret unmasked.
31
31
 
32
32
  Files are parsed and written back preserving comments, order, `export KEY=` prefixes, quoting and multiline values; only the lines a command touches change.
33
33
 
34
- ## redact
34
+ Only dotenv files are read: a file named on the command line with a `.json`, `.yaml`, `.toml`, `.ini` or `.xml` extension, or holding lines but no `KEY=value` one, is refused with exit 2 rather than read as empty. `ev redact < file` masks the secrets of those.
35
+
36
+ ## ev redact
35
37
 
36
38
  ```sh
37
- some-command 2>&1 | redact
38
- git diff --cached | redact --check
39
+ some-command 2>&1 | ev redact
40
+ git diff --cached | ev redact --check
39
41
  ```
40
42
 
41
- `redact` copies stdin to stdout line by line, masking:
43
+ `ev redact` copies stdin to stdout line by line, masking:
42
44
 
43
45
  - known token formats: `ghp_`, `github_pat_`, `glpat-`, `sk-`, `xox?-`, JWTs and the body of PEM private key blocks
44
46
  - the password and the tokens of any URL (webhook and push URLs, opaque path segments, token query parameters)
45
47
  - the values of secret-looking keys in the `.env*` files of the current folder and the folders below it (whole words only, from 4 characters, also in their percent-encoded and JSON-escaped forms), `--no-env` skips them
46
48
 
47
- `redact --check` prints nothing of the input: it lists `<file>:<line>: <kind>` for each secret found and exits 1. On a diff it reads the added lines only and names the new file's line numbers.
49
+ `ev redact --check` prints nothing of the input: it lists `<file>:<line>: <kind>` for each secret found and exits 1. On a diff it reads the added lines only and names the new file's line numbers.
48
50
 
49
51
  ## The parser and the guard
50
52