Menu ▾ ▴

#134 feat(audit): browse audit events with dopbase audit list

closed
nobody
None
2026-10-26
2026-10-23
Anonymous
No

Originally created by: thomijasir

Summary

Adds dopbase audit list, a one-page-at-a-time table of audit events for administrators. Closes [#24].

audit export from [#131] already had the filters, name resolution and cursor handling, so the first commit moves them into a shared AuditFilters and list reuses them:

 audit

+  list    --action --project --environment --actor   --limit 1..200 (default 50)  --cursor
   verify  --anchor
   export  --action --project --environment --actor   --limit N  --output  --force
           \___________ AuditFilters (shared) _____/

:::text
dopbase audit list --limit 2
  stdout  TIME  SEQ  ACTOR  ACTION  RESOURCE  PROJECT  ENVIRONMENT   (+ "2 event(s)")
  stderr  Info: More events match. Next page: dopbase audit list --limit 2 --cursor <C>
dopbase --json audit list
  stdout  the API page unchanged: {"items": [...], "nextCursor": ...}
  stderr  (nothing)

Where this differs from the original issue text:

  • The next-page command goes to stderr and repeats the original filters. The server doesn't tie a cursor to a filter set, so reusing a cursor with different filters would skip or repeat events. Keeping the hint off stdout also leaves the table clean for grep and less.
  • A SEQ column shows each event's chain position, so it can be matched against audit verify output. Legacy rows show -.
  • Table cells replace control characters and bidirectional overrides with ?. Since [#131] we assume someone may write rows directly, and a planted actorLabel like evil\e[2K\rforged could otherwise erase or rewrite rows on an investigator's screen. --json keeps the stored value.
  • --limit is checked by clap before any request.
  • export now fails on a page without an items array instead of stopping quietly and reporting a short export as a success.

The issue body has been updated to match.

Compatibility

No compatibility impact. audit export keeps the same flags and output, and the server is unchanged. The only behavior change outside the new command is that export now errors on a malformed API response.

Merge risk: a two-way door. The change is CLI only, with no migrations or server changes, so reverting the branch removes the command and nothing else. Blast radius: the audit subcommands. The shared output::printable helper is new and only audit list uses it.

Known gap, left out on purpose: a runner or agent token running audit list is refused before any audit request, but the message comes from the shared sign-in check (the configured Dopbase credential is invalid or expired) and is misleading for a valid token. Fixing it changes every administrator command, so it belongs in its own PR. Members get the server's This operation requires an administrator.

Verification

  • cargo fmt --check and cargo clippy --locked --all-targets --all-features -- -D warnings pass. While working, cargo test --test cli audit and cargo test --test cli args passed after each commit.
  • bash ./scripts/verify-backend.sh passes in a clean app/Dockerfile.test container on the final branch: fmt, clippy, the full test suite with --test-threads=1 (CLI suite: 218 passed, 1 ignored), release build, and the CLI and server smoke checks.
  • An end-to-end script ran 8 checks against the release binary in the same container, with a real server, a bootstrapped admin, and sqlite3 used to plant a record. All passed:
Check Result
audit list default table headers and 9 events, newest first
audit list --limit 2 \| cat stdout holds only the table; the next-page command is on stderr
Run the printed next-page command returns sequences 7 and 6, no overlap with page 1
--project storefront --environment storefront/production --action secret.created only secret.created rows
--json --limit 2 page JSON with nextCursor, empty stderr
--limit 201, --project nope rejected
Planted actor_label with ESC, [2K, CR table shows evil?[2K?forged, JSON keeps \u001b[2K\rforged
Runner token refused, nothing on stdout
  • New tests in app/tests/cli/commands/audit.rs, run against the in-process Fixture server: paging through the printed commands, including a filter value with a space and a quote checked by a real sh; --json equal to a direct API call; every filter alone and combined, plus empty results; local limit errors and a server-rejected cursor; planted escape codes; agent token and member refusal. app/tests/cli/args.rs gains parse cases, and the export test's seeding loop is now a shared helper.
  • bun run test:docs and bunx prettier --check pass on the changed Markdown.

Checklist

  • [x] I kept this pull request focused on one problem.
  • [x] I added or updated tests for behavior changes, or explained why tests are not needed.
  • [x] I updated the documentation and CHANGELOG.md when public behavior changed, or explained why they are not needed.
  • [x] I updated relevan documentation inside /docs

Related

Tickets: #131
Tickets: #24

Discussion

  • Anonymous

    Anonymous - 2026-10-23

    Ticket changed by: dopbase

    • status: open --> closed
     

Log in to post a comment.