vvauth 2.4.1 → 2.6.0
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/.github/workflows/publish-npm.yml +5 -0
- package/.github/workflows/release.yml +33 -0
- package/.github/workflows/test.yml +52 -0
- package/.goreleaser.yaml +31 -0
- package/API_and_tests.md +144 -0
- package/README.md +88 -17
- package/SECURITY_AUDIT_fable-5.1.md +88 -0
- package/SECURITY_AUDIT_gpt-6.1-sol.md +196 -0
- package/cmd/vauth/main.go +218 -0
- package/go.mod +18 -0
- package/go.sum +24 -0
- package/index.js +146 -345
- package/package.json +7 -7
- package/rc.go +320 -0
- package/test/token-cache.js +271 -135
- package/vault.go +46 -0
- package/vauth.go +399 -0
- package/vauth_test.go +868 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# vvauth — Architecture, Code Quality, and Security Review
|
|
2
|
+
|
|
3
|
+
**Review date:** October 23, 2026
|
|
4
|
+
**Reviewer:** Codex (GPT 6.1-sol)
|
|
5
|
+
|
|
6
|
+
## Scope and evidence
|
|
7
|
+
|
|
8
|
+
This is a read-only review of the current checkout. I read `README.md`, `API_and_tests.md`, both canonical implementations (`index.js`; `vauth.go`, `vault.go`, `cache.go`, `rc.go`, `humandiff.go`, and `cmd/vauth/main.go`), both test files, the three workflows, and the package/build manifests. I also inspected locally installed dependency source where necessary to understand Node HTTP, CLI, macro, child-process, and encryption delegation, Go agent selection, and Go HTTP redirect handling. I did not read the other audit as evidence, examine project history, modify the repository, craft inputs, or perform behavioral probes.
|
|
9
|
+
|
|
10
|
+
Authorized verification:
|
|
11
|
+
|
|
12
|
+
- `npm test`: **64 passed, 0 failed, 0 skipped**.
|
|
13
|
+
- `go test ./...`: **passed** for the library; `cmd/vauth` reports **no test files**. The normal Go output does not establish whether individual tests skipped optional checks.
|
|
14
|
+
- The Git working tree was clean before and after the test runs.
|
|
15
|
+
|
|
16
|
+
Findings below distinguish observed source behavior from inferred consequences. Severity reflects the likely impact under the stated conditions, not a demonstrated exploit. This is not an independent cryptographic certification, dependency-vulnerability scan, live Vault integration test, or Windows execution test.
|
|
17
|
+
|
|
18
|
+
## Design as understood
|
|
19
|
+
|
|
20
|
+
vvauth combines an authentication client, a credential/profile resolver, and an environment publisher. Node exposes a class and a reflection-based CLI; Go separates configuration, cache, Vault transport, orchestration, and the command entry point.
|
|
21
|
+
|
|
22
|
+
Both locate `.vauthrc` through `VAUTHRC`, the working directory, then the home directory, and perform environment macro expansion. With an authentication configuration, connection precedence is the inherited `VAULT_TOKEN`, then the encrypted session cache, then SSH challenge signing or JWT login. Cached expiry drives reuse, renewal in the final third of the recorded lease, or replacement. `--renew` means fresh authentication, not merely renewal of the existing token. Without an auth block, inherited Vault tokens are deliberately ignored, allowing local armored credentials to work offline.
|
|
23
|
+
|
|
24
|
+
The shared disk contract is a hash-addressed `.creds` file beneath `~/.vauth/tokens`, containing armored JSON with the token, lease duration, renewable flag, and absolute expiry. `ssh-agent-crypt` performs encryption/decryption using an agent-backed key; new cache writes select a key through identity/mail settings, while decryption generally selects the armor's embedded fingerprint.
|
|
25
|
+
|
|
26
|
+
Environment resolution combines Vault entity metadata, the user's private KV-v2 `.vauth_database`, optional local encrypted JSON, and ordered remote secret reads. Metadata overrides private database entries; later secret sources override earlier ones. `env.map` publishes selected values through JSON, Bash exports, raw dotenv lines, or a child process. `set`/`unset` replace the private database document after a read.
|
|
27
|
+
|
|
28
|
+
**Overall assessment:** a useful, compact design with thoughtful cache hygiene and substantial lifecycle regression coverage. The principal weaknesses are implicit trust in working-directory configuration, incomplete lifecycle validation, unsafe transport defaults in Go, and a parity promise broader than the implementation and tests support.
|
|
29
|
+
|
|
30
|
+
## Strengths
|
|
31
|
+
|
|
32
|
+
- **No plaintext token-cache fallback.** Encryption precedes writing, unreadable/plaintext armor is treated as a miss, and cache write failure does not fail authentication or print the token. Both request private creation modes and rename the completed temporary file into place (`index.js:121–152`, `cache.go:43–101`).
|
|
33
|
+
- **Well-covered lease decisions.** Tests exercise expiry, proportional renewal thresholds, lease-baseline preservation, nonrenewable replacement, forced reauthentication, environment-token precedence, disabled caching, and ordinary reuse without rewriting the cache.
|
|
34
|
+
- **Reasonable failure classification in token lookup/renewal.** HTTP 400/403 can trigger reauthentication, whereas server/network failures are propagated instead of creating extra tokens (`index.js:178–202`, `vauth.go:181–215,255–263`).
|
|
35
|
+
- **Good shell-value quoting and key checks on the normal environment path.** Bash values are single-quoted with embedded quotes escaped; `env.map` names are validated in both implementations. Resolution completes before export output begins (`index.js:330–335,489–492`, `vauth.go:419–431,448–459`).
|
|
36
|
+
- **Secrets are not printed in ordinary success diagnostics.** Token status and sourced export echoes are redacted; JSON output can be separated from stderr diagnostics.
|
|
37
|
+
- **Go has useful architectural seams.** Typed configuration, injectable HTTP client/clock/streams/environment, and separate transport/cache files make the library more maintainable and testable than a single CLI-bound implementation.
|
|
38
|
+
- **CI has basic quality gates and restrained permissions.** Linting, formatting, vetting, and tests are present; regular CI has read-only repository permissions. Go release configuration includes trimmed builds, version injection, checksums, and a Windows signing hook.
|
|
39
|
+
|
|
40
|
+
## Weaknesses and correctness risks
|
|
41
|
+
|
|
42
|
+
### 1. High — Configuration discovery is also an implicit credential trust decision
|
|
43
|
+
|
|
44
|
+
**Evidence:** `index.js:39,64–95,330–335`; `rc.go:322–373`; `vault.go:57–67`; `vauth.go:419–425`.
|
|
45
|
+
|
|
46
|
+
A working-directory `.vauthrc` can select the Vault destination and auth parameters, reference local encrypted credentials, and map arbitrary syntactically valid environment names. The code checks names against shell injection, but does not establish whether the configuration is trusted. In a malicious checkout, invoking the helper can therefore send an inherited token or JWT to a chosen endpoint, request agent signatures, decrypt available local material, or export values affecting command execution. This is a configuration-authority boundary, not a claim that correctly quoted values execute as Bash code.
|
|
47
|
+
|
|
48
|
+
A nonexistent explicit `VAUTHRC` also silently falls through to another configuration. That matches the README's fallback wording but can select an unintended security context.
|
|
49
|
+
|
|
50
|
+
**Remedy:** make explicit configuration selection fail closed; add an opt-in/trust mechanism for project configurations and display the selected configuration and destination without credentials. Bind inherited tokens to a trusted Vault origin, restrict sensitive environment overrides, and document that approving a configuration authorizes credential resolution and agent use.
|
|
51
|
+
|
|
52
|
+
### 2. High — Transport policy is insufficient, particularly Go redirects
|
|
53
|
+
|
|
54
|
+
**Evidence:** `vault.go:42–86`; Node request construction throughout `index.js`; locally installed `nyks/http/request.js`; local Go `net/http/client.go` redirect-header copying.
|
|
55
|
+
|
|
56
|
+
Neither implementation requires HTTPS for credential-bearing requests. Go uses `http.DefaultClient` unless overridden, with no helper-level deadline, and reads complete response bodies without a size cap. Its default redirect behavior copies the custom `X-Vault-Token` header; that header is not among the standard headers receiving sensitive-header filtering. A redirect to another origin can consequently disclose a token. This is a static conclusion from the local HTTP implementation, not a redirect experiment.
|
|
57
|
+
|
|
58
|
+
Node does not enable redirects in these requests. Its dependency supplies a 60-second response-header timer, but that is not a total deadline: the timer is cleared when headers arrive, and timeout rejection does not explicitly destroy the request. Body draining remains unbounded.
|
|
59
|
+
|
|
60
|
+
**Remedy:** default to HTTPS, with explicit local-development exceptions; reject redirects for Vault calls or enforce an exact trusted origin and prohibit downgrade. Use bounded total deadlines, cancellation, response-size limits, and proper request/response cleanup in both runtimes. Preserve normal certificate verification.
|
|
61
|
+
|
|
62
|
+
### 3. Medium — Cached validity and in-memory validity are conflated with actual token usability
|
|
63
|
+
|
|
64
|
+
**Evidence:** `index.js:161–226,276–288`; `vauth.go:159–252,289–319`; the explicit cached-revocation tests in both suites.
|
|
65
|
+
|
|
66
|
+
Cache reuse intentionally skips lookup until renewal is due. Revoked cached tokens can be returned successfully by `connect`/`login`; the subsequent profile lookup used by `env` can fail without retrying authentication. Moreover, once an instance is marked connected, ordinary calls bypass expiry and renewal altogether. A long-lived library client can keep returning an expired token. Absolute wall-clock expiry also assumes a stable clock and does not subtract network latency or a safety margin.
|
|
67
|
+
|
|
68
|
+
**Remedy:** retain in-memory lease metadata and reevaluate expiry on every connection request. Decide and document the freshness policy for cached tokens; offer validation, and implement one bounded reauthentication retry for token-invalid responses on safe reads. Add conservative expiry skew and keep network/server failures distinct from invalid credentials.
|
|
69
|
+
|
|
70
|
+
### 4. Medium — Token persistence and replacement do not fully define ownership or cleanup
|
|
71
|
+
|
|
72
|
+
**Evidence:** `index.js:175,205–221`; `vauth.go:177,218–246`; environment-token and repeated-force-login tests.
|
|
73
|
+
|
|
74
|
+
An inherited token is persisted under the configured auth session even though it may belong to a different identity or carry different privileges. A later invocation without that environment variable can reuse it. Fresh authentication overwrites the local cache but does not revoke the previous token. Cache disabling leaves files intact; changing JWT content creates another filename; there is no logout, expiry cleanup, or retention policy. Replacement is therefore not revocation or credential erasure.
|
|
75
|
+
|
|
76
|
+
**Remedy:** distinguish externally supplied tokens from helper-owned tokens and make persistence of inherited tokens explicit. Bind persisted sessions to the intended principal/policy context. Add local cache cleanup and a documented logout path, with revocation limited to tokens the helper owns so that unrelated inherited credentials are not accidentally revoked.
|
|
77
|
+
|
|
78
|
+
### 5. Medium — The decrypted cache lacks a validated, context-bound schema
|
|
79
|
+
|
|
80
|
+
**Evidence:** `index.js:121–141,175–187`; `cache.go:15–20,43–59`; `vault.go:89–96,161–176`.
|
|
81
|
+
|
|
82
|
+
Node accepts any successfully decrypted JSON without checking token type, lease duration, expiry, or renewable shape. Go checks a nonempty token and JSON types, but omitted/null expiry becomes unlimited and lease invariants are not checked. Go login parsing also accepts an omitted lease duration as zero; lookup accepts an omitted TTL as zero. Encryption authenticates bytes, not application meaning.
|
|
83
|
+
|
|
84
|
+
Neither payload contains a format version or session digest. Thus a valid armor copied into another session filename is not rejected for context mismatch if the corresponding key remains available. This requires local cache manipulation or another source of valid armor; it is not an unauthenticated bypass of encryption.
|
|
85
|
+
|
|
86
|
+
**Remedy:** define a shared versioned schema with required fields, finite/nonnegative durations, explicit unlimited-token semantics, and consistency checks. Embed and verify the session digest and relevant principal context. Treat malformed or mismatched payloads as misses with redacted diagnostics.
|
|
87
|
+
|
|
88
|
+
### 6. Medium — Fixed cache staging names are unsafe under concurrency
|
|
89
|
+
|
|
90
|
+
**Evidence:** `index.js:134–151`; `cache.go:66–100`.
|
|
91
|
+
|
|
92
|
+
Both writers use exactly `<session>.creds.next`, overwrite it without exclusive creation, rename it, and unconditionally attempt cleanup. Concurrent Node/Go invocations can overwrite or remove each other's staging file, lose an update, or persist a different process's token. The read/renew/login/write sequence is also unlocked, so simultaneous callers may issue redundant logins or renewals.
|
|
93
|
+
|
|
94
|
+
Creation modes do not repair existing permissive files/directories, prevent following a preexisting symlink, or establish Windows ACL isolation. These are hardening gaps, not evidence that plaintext tokens are written.
|
|
95
|
+
|
|
96
|
+
**Remedy:** use unique exclusively created temporary files in a verified private directory, close and optionally sync before rename, and clean up only the writer's own file. Coordinate the session lifecycle with a cross-runtime lock and re-read inside the lock. Check ownership/permissions, avoid symlink traversal, and implement/test the Windows ACL equivalent.
|
|
97
|
+
|
|
98
|
+
### 7. Medium — Cache identity selection is not authentication identity selection
|
|
99
|
+
|
|
100
|
+
**Evidence:** `index.js:143,390–419`; `cache.go:89–94`; `vault.go:110–158`; identity-selection tests in `test/token-cache.js`.
|
|
101
|
+
|
|
102
|
+
Identity/mail settings select new cache encryption, not the SSH login key: login tries all agent identities in order. Cache reads use the embedded fingerprint, so changing selectors does not isolate users when the old key remains loaded. Multiple identities sharing the same Vault/role configuration also share the cache filename. Agent ordering can therefore determine the authenticated principal independently of the advertised cache selector.
|
|
103
|
+
|
|
104
|
+
Both SSH loops swallow all login failures and continue, including transport/server failures. Node signing failures escape the loop, whereas Go signing refusals skip to another key. There is no JWT fallback after an attempted SSH login fails. On Windows, Node explicitly selects `pageant`; Go's dependency discovers a Pageant pipe and otherwise selects OpenSSH, so the documented fallback is not implemented identically.
|
|
105
|
+
|
|
106
|
+
**Remedy:** expose an explicit authentication-key fingerprint separate from, or intentionally coupled to, cache encryption selection. Include principal selection in session identity. Define fallback and error-classification rules, constrain agent access/signing, and harmonize Windows agent selection. Document that access to a loaded key's signing service can enable cache decryption; armor is not protection against an already-compromised session with agent access.
|
|
107
|
+
|
|
108
|
+
### 8. Medium — Configuration and macro semantics diverge and can silently preserve mistakes
|
|
109
|
+
|
|
110
|
+
**Evidence:** `index.js:67–88,293–335`; `rc.go:121–136,155–245,247–301,340–371`; locally installed `nyks/string/replaceEnv.js` and `nyks/object/walk.js`.
|
|
111
|
+
|
|
112
|
+
Unknown macros remain literal, including in authentication and required credential fields. Node's recursive replacement has no cycle/depth guard; cyclic references can overflow recursion or grow output. Go stops after 16 passes without reporting incomplete resolution and stringifies structured values, whereas Node can return a structured value directly. Go's YAML walk processes mapping keys as well as values; Node's object walk processes values only. Alias handling and YAML coercion further complicate parity. Unknown configuration fields are not comprehensively rejected.
|
|
113
|
+
|
|
114
|
+
**Remedy:** publish a constrained schema and deterministic macro specification covering types, missing values, recursion, keys, and aliases. Reject unresolved required fields, detect cycles, and bound expansion depth and output size with errors rather than partial success. Treat secret values as literal data by default instead of automatically interpreting embedded macros.
|
|
115
|
+
|
|
116
|
+
### 9. Medium — Cache hashing is order-sensitive, and Go can retain a stale auth hash
|
|
117
|
+
|
|
118
|
+
**Evidence:** `index.js:110–115`; `rc.go:27–45,247–301,358–371`; `cache.go:23–31`; `vauth_test.go:TestTokenCacheKeyMatchesNode`.
|
|
119
|
+
|
|
120
|
+
The cache key hashes serialized auth objects rather than a normalized semantic session. Reordering nested YAML auth fields can create another cache entry for the same session. Raw JWT inclusion also causes cache fragmentation as JWTs rotate. Go reimplements Node-style serialization and tests only a small number of expected strings, not a real Node-to-Go session exchange.
|
|
121
|
+
|
|
122
|
+
More importantly, `ParseRC` stores `authKey`, and `AuthKey()` prefers it over the public auth structs. If an embedding caller changes a parsed role or JWT, the runtime auth configuration changes but the cached hash does not. That can reuse or overwrite a token associated with the earlier configuration.
|
|
123
|
+
|
|
124
|
+
**Remedy:** derive a versioned canonical session identity from immutable validated configuration, or invalidate/recompute it whenever public auth settings change. Normalize ordering/defaults and define JWT rotation semantics deliberately. Add bidirectional cross-runtime cache tests using the same parsed configuration and principal settings.
|
|
125
|
+
|
|
126
|
+
### 10. Medium — Environment publication has stale-state and data-format hazards
|
|
127
|
+
|
|
128
|
+
**Evidence:** `index.js:248–255,300–335,340–345`; `vauth.go:366–424,448–470,475–487`; `FunctionDecl` in both implementations.
|
|
129
|
+
|
|
130
|
+
Valid names such as `VAULT_TOKEN`, `VAULT_ADDR`, `PATH`, and runtime loader options remain unrestricted in `env.map`; mapping happens after the helper adds its own Vault values. A trusted authenticated session can thus publish a different token/address pair. Missing profile values differ by runtime: Node can retain `undefined`, while Go can retain a macro literal. Raw dotenv output does not escape multiline, quote, or comment-sensitive values.
|
|
131
|
+
|
|
132
|
+
The installed `venv` function sources process-substitution output without propagating the producer's exit status. A failed resolver can leave old credentials in the shell while the sourcing operation appears successful. Successful output also does not unset credentials absent from the newly resolved environment. Public Go `PublishEnv` assumes callers supply validated names and ignores output errors.
|
|
133
|
+
|
|
134
|
+
**Remedy:** reserve or explicitly authorize sensitive overrides, validate environment values at publication, and define missing/null behavior. Use a specified dotenv encoder or reject values outside its supported format. Make the shell wrapper check producer success before sourcing and manage previously exported variables explicitly. Validate names at exported sinks and return write errors.
|
|
135
|
+
|
|
136
|
+
### 11. Medium — Private database updates can lose concurrent changes
|
|
137
|
+
|
|
138
|
+
**Evidence:** `index.js:258–268,362–386`; `vauth.go:333–347`; `vault.go:203–237`.
|
|
139
|
+
|
|
140
|
+
`set` and `unset` read the complete `.vauth_database`, edit it, then replace the complete KV-v2 document without a version/CAS condition. Concurrent updates can overwrite each other. Secret paths, mounts, login metadata, and entity IDs are concatenated into URLs without a shared validation/encoding policy. Vault remains the authorization boundary, but ambiguous path characters or missing identity fields can target unintended paths or produce confusing errors. Later secret documents also silently override earlier fields.
|
|
141
|
+
|
|
142
|
+
**Remedy:** retain KV-v2 version metadata, use CAS and bounded conflict retries, validate identity/path components, and construct URLs safely. Specify duplicate-secret precedence and provide a strict collision mode. Treat tokens without entity metadata as an explicit supported case or reject profile-dependent operations with a precise error.
|
|
143
|
+
|
|
144
|
+
### 12. Medium — Error handling can expose sensitive response content or hide the real failure
|
|
145
|
+
|
|
146
|
+
**Evidence:** `index.js:362–386,410–419,472–483`; `vault.go:17–24,99–107,151–158,203–235`; `vauth.go:508–521`; local Node runner error handling.
|
|
147
|
+
|
|
148
|
+
Several errors include complete remote response bodies; the Node runner also prints the error and stack. A server or proxy can return sensitive or attacker-controlled text. Cache read failures are all swallowed, obscuring permission, integrity, and unavailable-agent failures. Missing auth capability can yield successful empty connection results on the first attempt. Go's installer ignores a `.bashrc` read error before writing; Node's function check has no child-spawn error handling. Interactive installation prompts also contradict the blanket machine-readable-stdout claim.
|
|
149
|
+
|
|
150
|
+
**Remedy:** use typed, contextual, redacted errors with bounded/sanitized remote messages, and make diagnostics distinguish expected cache misses from operational failures without secrets. Separate offline mode from required authentication. Preserve existing shell files on read failure, handle process-start errors, return output errors, and document interactive commands as exceptions to machine-readable output.
|
|
151
|
+
|
|
152
|
+
### 13. Medium — The Node/Go CLI parity contract is currently false in important cases
|
|
153
|
+
|
|
154
|
+
**Evidence:** `index.js:103–107,495–498`; `cmd/vauth/main.go:98–114,175–201`; locally installed `cnyks/lib/index.js`, `nyks/process/parseArgs.js`, and child-process helpers.
|
|
155
|
+
|
|
156
|
+
Static dispatch analysis identifies concrete mismatches not exercised by the current suites:
|
|
157
|
+
|
|
158
|
+
- Node selects raw output unless JSON is requested; its runner stringifies ordinary objects as raw strings. Bare `env`/`show` therefore do not receive the JSON-object formatting promised for both runtimes. Go explicitly JSON-encodes objects.
|
|
159
|
+
- Go implements `version`/`--version`; the Node class and inspected runner contain no corresponding version command.
|
|
160
|
+
- Node's runner leaves the textual flag value `false` as a truthy string, contrary to the documented boolean rule; Go interprets it as false. Node also coerces numeric-looking `set` arguments, unlike Go's string-preserving CLI.
|
|
161
|
+
- Node's child helper turns any nonzero child status into a generic rejection and exits 1; Go propagates the child's exit code.
|
|
162
|
+
- The documented `vauth run -- <command>` form passes `--` as the executable in both dedicated run paths, which forward original arguments rather than consuming that separator.
|
|
163
|
+
|
|
164
|
+
**Remedy:** use explicit command dispatch and shared argument/output rules rather than reflection as the Node contract boundary. Add version handling, preserve `set` strings, normalize booleans and separators, and propagate child statuses. Exercise both actual CLIs against the same contract fixtures, including default output and failure cases.
|
|
165
|
+
|
|
166
|
+
### 14. Medium — Testing and release gates do not establish the advertised assurance
|
|
167
|
+
|
|
168
|
+
**Evidence:** both test files; `.github/workflows/test.yml`, `publish-npm.yml`, `release.yml`; `.goreleaser.yaml`; `.gitignore:2`; package manifests.
|
|
169
|
+
|
|
170
|
+
Tests are strong for JWT/cache lifecycle but neither fake Vault implements SSH nonce/login or meaningful KV/profile operations. Go lacks CLI tests and identity-selection coverage comparable to Node. Armor interoperability checks use each runtime's corresponding crypto CLI, not a bidirectional Node/Go vvauth cache exchange; Go can skip its CLI check when unavailable.
|
|
171
|
+
|
|
172
|
+
The Node CI job runs only on Linux. The Windows Go job builds instead of running tests, despite `API_and_tests.md` saying both suites run on Linux and Windows. Existing test harnesses assume Unix-style `ssh-agent -s`, Bash, and process cleanup. No race/concurrency, hostile transport, or broad configuration-contract coverage is present.
|
|
173
|
+
|
|
174
|
+
Node workflows run `npm install`, while `package-lock.json` is ignored and untracked in this checkout, so CI dependency resolution is not tied to a committed lock. The Node package declares no engine requirement although CI tests only Node 24. Publishing uses a different event (`create`) from binary releases (`push` with tag filtering), has no explicit tag-type guard or production environment in the job, and does not validate package/module/tag version agreement. Release actions, GoReleaser selection, and the trusted external signing helper use movable refs/ranges. Checksums and an external signing hook do not alone prove that every Windows artifact is signed, and the README download commands do not verify downloaded artifacts.
|
|
175
|
+
|
|
176
|
+
**Remedy:** add common CLI, SSH/profile/KV, and real cross-runtime cache fixtures; make optional interop mandatory in release CI. Run platform-appropriate tests on Windows and declare the supported Node range. Commit a lockfile and use reproducible dependency installation. Align publication triggers, protect release environments/tags, and validate version agreement. Pin trusted build actions/helpers to reviewed immutable revisions, verify required signatures before publishing, provide provenance/checksum verification instructions, and ensure release gates cover both implementations.
|
|
177
|
+
|
|
178
|
+
## Recommended order of work
|
|
179
|
+
|
|
180
|
+
1. Establish trusted configuration/origin selection and safe transport defaults, especially Go redirect suppression.
|
|
181
|
+
2. Fix the explicit CLI-contract mismatches and the shell wrapper's failure propagation.
|
|
182
|
+
3. Validate/version cache payloads, eliminate fixed staging names, and make lifecycle decisions concurrency-safe.
|
|
183
|
+
4. Define token ownership, authentication identity, configuration immutability, and macro semantics.
|
|
184
|
+
5. Add shared end-to-end parity fixtures, real platform tests, and reproducible/protected release gates.
|
|
185
|
+
|
|
186
|
+
## Final scores
|
|
187
|
+
|
|
188
|
+
These are qualitative engineering judgments, not vulnerability counts or certification grades.
|
|
189
|
+
|
|
190
|
+
| Criterion | Score / 20 | One-line justification |
|
|
191
|
+
| --- | ---: | --- |
|
|
192
|
+
| Coolness | **17 / 20** | Agent-backed armored caching, offline secret resolution, and two interoperable implementation targets make a genuinely useful developer tool. |
|
|
193
|
+
| Robustness | **11 / 20** | Strong cache regression tests are offset by lifecycle/concurrency gaps, weak transport bounds, and concrete CLI/configuration parity defects. |
|
|
194
|
+
| Safety | **10 / 20** | Encryption and shell-value hygiene are good, but implicit configuration trust, Go redirect leakage, token retention, and insufficient context validation need hardening. |
|
|
195
|
+
|
|
196
|
+
**Signed: Codex (GPT 6.1-sol)**
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// Command vauth is the standalone Vault credentials helper: same commands
|
|
2
|
+
// and flags as the vvauth npm package.
|
|
3
|
+
package main
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"bytes"
|
|
7
|
+
"encoding/json"
|
|
8
|
+
"fmt"
|
|
9
|
+
"os"
|
|
10
|
+
"regexp"
|
|
11
|
+
"runtime/debug"
|
|
12
|
+
"strings"
|
|
13
|
+
|
|
14
|
+
vvauth "github.com/131/vvauth/v2"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
const usage = `Usage: vauth <command> [--flag[=value]] [--ir://json]
|
|
18
|
+
|
|
19
|
+
Commands:
|
|
20
|
+
env [--source] [--renew] Resolve the .vauthrc environment (JSON with --ir://json)
|
|
21
|
+
login [--source] [--renew] Authenticate; --source exports VAULT_TOKEN
|
|
22
|
+
connect [--renew] Authenticate and print the token
|
|
23
|
+
run <command> [args...] Run a command with the resolved environment
|
|
24
|
+
dotenv Print the environment as K=v lines
|
|
25
|
+
show Print the identity profile and .vauth_database
|
|
26
|
+
set <key> <value> Store a key in the .vauth_database
|
|
27
|
+
unset <key> Remove a key from the .vauth_database
|
|
28
|
+
install Install the venv shell function in ~/.bashrc
|
|
29
|
+
version Print the build version
|
|
30
|
+
`
|
|
31
|
+
|
|
32
|
+
// version is set by the release build (-ldflags "-X main.version=v1.2.3");
|
|
33
|
+
// otherwise the module version recorded by go install is used.
|
|
34
|
+
var version string
|
|
35
|
+
|
|
36
|
+
func buildVersion() string {
|
|
37
|
+
if version != "" {
|
|
38
|
+
return version
|
|
39
|
+
}
|
|
40
|
+
if info, ok := debug.ReadBuildInfo(); ok && info.Main.Version != "" {
|
|
41
|
+
return info.Main.Version
|
|
42
|
+
}
|
|
43
|
+
return "(devel)"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
var flagPattern = regexp.MustCompile(`^--?([a-zA-Z_0-9/:-]+)(?:=(.*))?$`)
|
|
47
|
+
|
|
48
|
+
// parseArgs splits positional arguments from --flags (nyks/process/parseArgs).
|
|
49
|
+
func parseArgs(argv []string) ([]string, map[string]string) {
|
|
50
|
+
var args []string
|
|
51
|
+
dict := map[string]string{}
|
|
52
|
+
for i, arg := range argv {
|
|
53
|
+
if arg == "--" {
|
|
54
|
+
args = append(args, argv[i+1:]...)
|
|
55
|
+
break
|
|
56
|
+
}
|
|
57
|
+
if !strings.HasPrefix(arg, "-") {
|
|
58
|
+
args = append(args, arg)
|
|
59
|
+
continue
|
|
60
|
+
}
|
|
61
|
+
if match := flagPattern.FindStringSubmatch(arg); match != nil {
|
|
62
|
+
value := "true"
|
|
63
|
+
if strings.Contains(arg, "=") {
|
|
64
|
+
value = match[2]
|
|
65
|
+
}
|
|
66
|
+
dict[match[1]] = value
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return args, dict
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
func truthy(value string, ok bool) bool {
|
|
73
|
+
if !ok {
|
|
74
|
+
return false
|
|
75
|
+
}
|
|
76
|
+
switch strings.ToLower(value) {
|
|
77
|
+
case "", "false", "0":
|
|
78
|
+
return false
|
|
79
|
+
}
|
|
80
|
+
return true
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// param reads the nth positional argument or the --name flag.
|
|
84
|
+
func param(args []string, dict map[string]string, index int, name string) (string, bool) {
|
|
85
|
+
if index < len(args) {
|
|
86
|
+
return args[index], true
|
|
87
|
+
}
|
|
88
|
+
value, ok := dict[name]
|
|
89
|
+
return value, ok
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func main() {
|
|
93
|
+
if err := run(os.Args[1:]); err != nil {
|
|
94
|
+
fmt.Fprintln(os.Stderr, err)
|
|
95
|
+
os.Exit(1)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
func run(argv []string) error {
|
|
100
|
+
if len(argv) > 0 && argv[0] == "run" {
|
|
101
|
+
return runCommand(argv[1:])
|
|
102
|
+
}
|
|
103
|
+
args, dict := parseArgs(argv)
|
|
104
|
+
if _, ok := dict["version"]; ok && len(args) == 0 {
|
|
105
|
+
args = []string{"version"}
|
|
106
|
+
}
|
|
107
|
+
if len(args) == 0 {
|
|
108
|
+
fmt.Fprint(os.Stderr, usage)
|
|
109
|
+
os.Exit(1)
|
|
110
|
+
}
|
|
111
|
+
command, args := args[0], args[1:]
|
|
112
|
+
_, jsonOutput := dict["ir://json"]
|
|
113
|
+
if command == "version" || command == "--version" {
|
|
114
|
+
fmt.Println(strings.TrimPrefix(buildVersion(), "v"))
|
|
115
|
+
return nil
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
vvauth.Version = buildVersion()
|
|
119
|
+
v, err := vvauth.New()
|
|
120
|
+
if err != nil {
|
|
121
|
+
return err
|
|
122
|
+
}
|
|
123
|
+
switch command {
|
|
124
|
+
case "env":
|
|
125
|
+
source, renew := truthy(param(args, dict, 0, "source")), truthy(param(args, dict, 1, "renew"))
|
|
126
|
+
env, err := v.Env(renew)
|
|
127
|
+
if err != nil {
|
|
128
|
+
return err
|
|
129
|
+
}
|
|
130
|
+
if source {
|
|
131
|
+
v.PublishEnv(env)
|
|
132
|
+
return nil
|
|
133
|
+
}
|
|
134
|
+
return respond(env, jsonOutput)
|
|
135
|
+
case "login":
|
|
136
|
+
source, renew := truthy(param(args, dict, 0, "source")), truthy(param(args, dict, 1, "renew"))
|
|
137
|
+
return v.Login(source, renew)
|
|
138
|
+
case "connect":
|
|
139
|
+
token, err := v.Connect(truthy(param(args, dict, 0, "renew")))
|
|
140
|
+
if err != nil {
|
|
141
|
+
return err
|
|
142
|
+
}
|
|
143
|
+
if token == "" {
|
|
144
|
+
return nil
|
|
145
|
+
}
|
|
146
|
+
return respond(token, jsonOutput)
|
|
147
|
+
case "dotenv":
|
|
148
|
+
return v.Dotenv()
|
|
149
|
+
case "show":
|
|
150
|
+
profile, err := v.Show()
|
|
151
|
+
if err != nil {
|
|
152
|
+
return err
|
|
153
|
+
}
|
|
154
|
+
return respond(profile, jsonOutput)
|
|
155
|
+
case "set":
|
|
156
|
+
key, ok := param(args, dict, 0, "k")
|
|
157
|
+
if !ok {
|
|
158
|
+
return fmt.Errorf("Missing parameter --k")
|
|
159
|
+
}
|
|
160
|
+
value, ok := param(args, dict, 1, "v")
|
|
161
|
+
if !ok {
|
|
162
|
+
return fmt.Errorf("Missing parameter --v")
|
|
163
|
+
}
|
|
164
|
+
return v.Set(key, value)
|
|
165
|
+
case "unset":
|
|
166
|
+
key, ok := param(args, dict, 0, "k")
|
|
167
|
+
if !ok {
|
|
168
|
+
return fmt.Errorf("Missing parameter --k")
|
|
169
|
+
}
|
|
170
|
+
return v.Unset(key)
|
|
171
|
+
case "install":
|
|
172
|
+
return v.Install()
|
|
173
|
+
}
|
|
174
|
+
return fmt.Errorf("Invalid command key '%s'", command)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
func runCommand(argv []string) error {
|
|
178
|
+
if len(argv) > 0 && argv[0] == "--" {
|
|
179
|
+
argv = argv[1:]
|
|
180
|
+
}
|
|
181
|
+
if len(argv) == 0 {
|
|
182
|
+
return fmt.Errorf("run: missing command")
|
|
183
|
+
}
|
|
184
|
+
vvauth.Version = buildVersion()
|
|
185
|
+
v, err := vvauth.New()
|
|
186
|
+
if err != nil {
|
|
187
|
+
return err
|
|
188
|
+
}
|
|
189
|
+
code, err := v.Run(argv[0], argv[1:]...)
|
|
190
|
+
if err != nil {
|
|
191
|
+
return err
|
|
192
|
+
}
|
|
193
|
+
os.Exit(code)
|
|
194
|
+
return nil
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// respond prints the command result: JSON with --ir://json, raw strings
|
|
198
|
+
// otherwise (objects are still rendered as JSON).
|
|
199
|
+
func respond(response any, jsonOutput bool) error {
|
|
200
|
+
if text, ok := response.(string); ok && !jsonOutput {
|
|
201
|
+
// Raw token output has no trailing newline.
|
|
202
|
+
_, err := fmt.Fprint(os.Stdout, text)
|
|
203
|
+
return err
|
|
204
|
+
}
|
|
205
|
+
if jsonOutput {
|
|
206
|
+
var out bytes.Buffer
|
|
207
|
+
encoder := json.NewEncoder(&out)
|
|
208
|
+
encoder.SetEscapeHTML(false)
|
|
209
|
+
if err := encoder.Encode(response); err != nil {
|
|
210
|
+
return err
|
|
211
|
+
}
|
|
212
|
+
_, err := os.Stdout.Write(bytes.TrimSuffix(out.Bytes(), []byte("\n")))
|
|
213
|
+
return err
|
|
214
|
+
}
|
|
215
|
+
encoder := json.NewEncoder(os.Stdout)
|
|
216
|
+
encoder.SetEscapeHTML(false)
|
|
217
|
+
return encoder.Encode(response)
|
|
218
|
+
}
|
package/go.mod
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module github.com/131/vvauth/v2
|
|
2
|
+
|
|
3
|
+
// version: 2.6.0
|
|
4
|
+
|
|
5
|
+
go 1.22
|
|
6
|
+
|
|
7
|
+
require (
|
|
8
|
+
github.com/131/ssh-agent-crypt v1.4.2
|
|
9
|
+
github.com/131/vauth-login v1.1.5
|
|
10
|
+
github.com/Masterminds/semver/v3 v3.5.0
|
|
11
|
+
gopkg.in/yaml.v3 v3.0.1
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
require (
|
|
15
|
+
github.com/Microsoft/go-winio v0.6.2 // indirect
|
|
16
|
+
golang.org/x/crypto v0.31.0 // indirect
|
|
17
|
+
golang.org/x/sys v0.28.0 // indirect
|
|
18
|
+
)
|
package/go.sum
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
github.com/131/ssh-agent-crypt v1.4.1 h1:Ng6+kKhFkk6XvpCLT8+VhWH9J5wwh1wq4NlHsZwa4NA=
|
|
2
|
+
github.com/131/ssh-agent-crypt v1.4.1/go.mod h1:XNiI2n3+2NTwjhyd/plFhrd0vSfWOZ58ocvqTlx1Ydk=
|
|
3
|
+
github.com/131/ssh-agent-crypt v1.4.2 h1:e0srAUvSwbPaZXjkE2qY5OCWKxXNTCOVOVWyfrxhTM4=
|
|
4
|
+
github.com/131/ssh-agent-crypt v1.4.2/go.mod h1:/YBOMh8URU2lc5kTxjTDftcVrJqGv1SIpo0TjwNQPCA=
|
|
5
|
+
github.com/131/vauth-login v1.1.3 h1:XzwooJBhHIltt5PGRVoRXmgsrX6JTSNYPUNrG1O4SXM=
|
|
6
|
+
github.com/131/vauth-login v1.1.3/go.mod h1:+Z5ibQE3Wa1ouVSRaiH7t5ckNPlAcpx0j8C8KF+5Z9M=
|
|
7
|
+
github.com/131/vauth-login v1.1.4 h1:yv5+5m/0LNIDPlpFzfiKOiA5B6HH5bz1OfzfF9tRc/U=
|
|
8
|
+
github.com/131/vauth-login v1.1.4/go.mod h1:4jGHBN8aLgvbhvHGhw1U9jPbl/bfgJUgNyz+O9g3A90=
|
|
9
|
+
github.com/131/vauth-login v1.1.5 h1:Uho9fCexylScv5TBVlgctPGj/itVBjdvMFHjqsD4Xlg=
|
|
10
|
+
github.com/131/vauth-login v1.1.5/go.mod h1:R0CIG8+HiwdPEsE/VPvltiN7QSeoMuIN46YP/T8JtAw=
|
|
11
|
+
github.com/Masterminds/semver/v3 v3.5.0 h1:kQceYJfbupGfZOKZQg0kou0DgAKhzDg2NZPAwZ/2OOE=
|
|
12
|
+
github.com/Masterminds/semver/v3 v3.5.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
|
13
|
+
github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
|
|
14
|
+
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
|
|
15
|
+
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
|
16
|
+
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
|
17
|
+
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
|
18
|
+
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
19
|
+
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
|
|
20
|
+
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
|
21
|
+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
22
|
+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
23
|
+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
24
|
+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|