Commit Graph
14 Commits
Author SHA1 Message Date
dsql bf7e50f91f fix: list tolerates a null _id; declare the cryptography dependency
A stored doc with a present-but-null _id crashed the whole list table: doc.get('_id',
'')[:16] slices None (the '' default only applies when _id is absent), so one bad doc
aborted the render - now uses (doc.get('_id') or '')[:16], mirroring revoke's finder, so
it renders a blank placeholder row. cli.py imports cryptography.exceptions.InvalidTag but
pyproject only pulled cryptography transitively via envelope_crypto - declare it directly.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-06 19:31:38 -04:00
dsql e5c3547c51 fix: a stored key doc with meta:null no longer crashes authorize/revoke
find_by_friendly, authorize.py's existing-target check, and revoke.py's
success-print all did doc.get("meta", {}).get(...) directly - the {} default
only applies when the key is ABSENT, not when its value is null (plausible in
shared mongo or a hand-edited JSON store), so a null meta raised AttributeError.
revoke's crash landed AFTER storage.delete() already succeeded, so a completed
revoke was reported as a raw traceback instead of a clean exit. list_keys._meta
already coerced correctly; that fix is now hoisted into commands/__init__.py as
doc_meta, the single source every meta-reading call site goes through. cli.py's
catch tuple also gains AttributeError as defense in depth for any future
unguarded meta access.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-06 00:16:52 -04:00
dsql 764bcb6146 refactor: derive __version__ from package metadata (single source)
Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-03 17:00:00 -04:00
dsql 387830084a fix: coerce null _id to empty string in revoke fingerprint match (v0.1.7)
a key doc with an explicit `_id: null` made doc.get("_id", "") return None
instead of the default, so .startswith(prefix) raised an uncaught
AttributeError instead of the contracted clean [✘] + exit 1.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-03 16:15:53 -04:00
dsql e8ea45c15e docs: compress prose/module docstrings, em-dash->hyphen (de-bloat wave 1)
Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-03 00:16:10 -04:00
dsql f150f7f957 fix: clean mongo errors, null-meta list crash, empty-friendly revoke, key passphrase, storage path env expansion (v0.1.5)
envauth-2: catch PyMongoError in cli.py (guarded import) so an unreachable
mongo backend fails fast with a clean [x] line instead of an uncaught
traceback after the driver's server-selection timeout.

envauth-3: coerce a non-dict meta block to {} before rendering `list`, so a
"meta": null doc no longer crashes the table mid-render.

envauth-4: revoke checks args.friendly is not None instead of truthiness, so
--friendly "" correctly routes to the friendly-name lookup instead of
misrouting to the fingerprint branch.

envauth-5: add an optional [keys].password config field and thread it through
boot_local's decrypt_aes_key_with_rsa and verify's self_test, so an encrypted
local private key can be unwrapped.

envauth-6: add Config.storage_path (routed through the existing _expand
helper) so the JSON storage path expands $ENV_VARS the same way the key
paths already do, not just ~.

envauth-7: verified CLAUDE.md and README already correctly describe
authorize's re-run-is-refused behavior (fixed under envauth-1); no doc
change needed.

Also compresses several essay-length docstrings/comments (init's TOCTOU
note, authorize's replace-guard note, mongo_store's module docstring,
json_store's _write docstring, list_keys' _can_authorize docstring) with no
behavior change; re-verified the full CLI flow (JSON + live mongod) after.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-02 23:32:10 -04:00
dsql 0d0558d11b chore: unpin envelope_crypto dependency (track latest release)
envauth used envelope_crypto pinned at v0.1.0, two data-loss fixes behind (the lib
is now v0.1.4). envauth uses only stable crypto primitives (initialize, encrypt_data/
decrypt_data, create_aes_key, *_aes_key_with_rsa, get_rsa_key_fingerprint, self_test)
— never the record-rotation functions whose contract changed — so tracking latest is
safe and keeps the crypto fixes flowing without a manual bump each release.

Verified: full CLI round-trip (init -> authorize server -> privilege gate -> envauth-1
self-authorize refusal -> list) against envelope_crypto v0.1.4 source; all 8 used
primitives present. v0.1.4.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-02 16:50:55 -04:00
dsql bfeee80712 fix: EA-1 refuse authorize of an already-recorded key (v0.1.3)
authorize never checked the target fingerprint against existing docs before
save()'s upsert-by-_id, so authorizing the local machine's own public key
under a new friendly name silently replaced the local authorizer record
(can_authorize demoted to False) while printing a success banner. With a
sole authorizer this bricks the CLI: authorize refuses (not permitted),
init refuses (already initialized), and revoke of the local key refuses
(refusing to revoke the local key) -- no in-CLI recovery. Mirror revoke's
local-key guard and extend it to any existing _id, so a duplicate target
is refused with a clear message instead of silently replacing the record.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-07-02 16:41:09 -04:00
dsql 88e1eaef39 fix: EA-1 clean error on malformed flag/doc; EA-2 fingerprint ambiguity + fd-leak
EA-1: main dispatch catches KeyError/TypeError so a structurally-malformed flag/doc prints
a clean [x] line instead of a traceback. EA-2: fingerprint revoke rejects an empty prefix
and an ambiguous prefix (was: silently revoked the first match). json_store closes the raw
fd if os.fdopen raises before taking ownership (was: leaked). init TOCTOU documented as
by-design (trusted-DEK model, save upserts by _id). list '?' wording clarified.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-06-29 21:35:03 -04:00
dsql a40a7432ef fix: clean error on OS-level write failures in config init and dispatch (v0.1.2)
- config init catches OSError (read-only dir, ENOSPC, gone cwd) alongside CommandError
  and prints a clean [x] line; the main dispatch catches the full OSError family instead
  of only FileNotFoundError (L13)
- document read_flag's fail-closed (non-dict -> not allowed) as a deliberate privilege-
  gate default (nit).

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-06-29 17:58:09 -04:00
dsql eced5333d6 fix: surface a tampered capability flag as a clean error, not a traceback
a tampered or foreign GCM capability flag raises cryptography's InvalidTag (subclasses Exception, not ValueError/RuntimeError), which escaped the CLI's catch tuple as a raw traceback on the authorize/verify paths. main() now catches InvalidTag and surfaces '[\xe2\x9c\x98] capability flag failed authentication — tampered or wrong DEK'. also corrected the stale CLAUDE.md storage note that still described the swallow-wrapped mongo methods instead of the fail-loud raw-collection path.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-06-29 01:10:25 -04:00
dsql 13bf77f0f4 fix: mongo backend — sync close() + fail-loud via raw collection
two regressions in the [mongo] storage backend: (1) the four finally blocks did 'await db.close()' but the mongo lib's close() became synchronous this session, so await None raised TypeError on every op — dropped the await. (2) the backend consumed mongo's swallow-and-return-default wrapped methods raw, conflating a driver error with 'no document / not initialized' in the lib that gates authority; it now goes through the raw db.collection(name) escape hatch (the motor collection, which raises) and raises on a no-op upsert, matching the CLI's fail-loud stance.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-06-28 18:45:25 -04:00
dsql a0824c4b1a fix: unique temp on JSON write + tolerant created_at render (v0.1.1)
- JsonStore._write used a fixed '<path>.tmp' name with no lock, so two concurrent
  authorizer invocations could clobber each other's temp and corrupt/lose the key
  store. use tempfile.mkstemp in the same dir (unique per write) then os.replace
  (atomic), cleaning up the temp on failure.
- list 'created_at' formatting did int(raw) unguarded; one hand-edited/legacy doc
  with a bad timestamp aborted the whole table. guard per-row, fall back to '-'.

verified by execution: 20 concurrent writers -> 0 errors, file stays valid JSON,
no leftover .tmp; upsert still dedupes/updates; bad/absent created_at -> '-'.

Signed-off-by: disqualifier <dev@disqualifier.me>
2026-06-28 15:47:58 -04:00
dsql fb733e86de add package: pyproject + src (authorizer CLI, json/mongo storage, gated capability flag)
Signed-off-by: disqualifier <dev@disqualifier.me>
2026-06-25 00:04:40 -04:00