Skip to content

Add audit-logs export commands for S3 export destinations - #214

Merged
yummybomb merged 5 commits into
mainfrom
hypeship/audit-logs-s3-export
Aug 10, 2026
Merged

Add audit-logs export commands for S3 export destinations#214
yummybomb merged 5 commits into
mainfrom
hypeship/audit-logs-s3-export

Conversation

@yummybomb

@yummybomb yummybomb commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a kernel audit-logs export command group for managing S3 audit log export destinations:

  • create — creates a destination (paused by default) and prints the trust-policy onboarding steps with the Kernel role ARN and external ID
  • list — paginated table with delivery status per destination (--limit/--offset, more-results hint from pagination headers); JSON output includes a next_offset cursor when another page is available
  • get — full detail view including delivery status: status, last success with computed lag, last error and time, consecutive failures, next attempt
  • update — partial update of region/bucket/prefix/role ARN/KMS key; --clear-kms-key sends an empty string to remove the key, omitted flags leave fields unchanged; 409 conflicts get a retry-against-fresh-state hint
  • pause / resume — status transitions with notes on in-flight uploads and resume semantics
  • delete — removes a destination
  • test — runs the destination test and exits non-zero on failure, reporting the failing stage and error code

All calls go through the generated AuditLogExportDestinationService in kernel-go-sdk v0.87.0 (bumped from v0.85.0), following the existing cmd/audit_logs.go service-interface pattern. A thin adapter remains only to read and validate the X-Has-More/X-Next-Offset pagination headers via option.WithResponseInto, since the SDK pager does not surface them. --clear-kms-key sends {"kms_key_id":""} per the SDK contract (empty string clears; omit/null leaves unchanged), locked in by a wire-contract test. Create, list, get, update, pause, resume, and test support --output json.

Testing

  • make test passes (unit tests cover output rendering, flag validation, partial-update/clear semantics, pagination headers and JSON cursors, 409 handling, and test-failure exit behavior)
  • All flows (create, get, list, update incl. KMS set/clear, pause/resume, test, delete, and error paths) were exercised end-to-end against a live environment with the built binary

Note

Low Risk
CLI-only feature with mocked and httptest coverage; no changes to core auth or runtime paths beyond a dependency bump.

Overview
Adds kernel audit-logs export, a new subcommand group under audit-logs for managing continuous S3 audit log export destinations via kernel-go-sdk v0.87.0 (from v0.85.0).

Operators can create paused S3 destinations (with optional KMS), list with --limit/--offset and pagination from X-Has-More / X-Next-Offset, get delivery health, partially update bucket/role/KMS (including --clear-kms-key), pause / resume, delete, and test (non-zero exit on failure). Create prints IAM trust onboarding steps; list/get/update/pause/resume/test support --output json.

Implementation mirrors existing audit-logs CLI patterns (service interface + thin SDK adapter for list pagination). Broad unit tests cover rendering, validation, KMS wire contract, 409 hints, and pagination.

Reviewed by Cursor Bugbot for commit 0987661. Bugbot is set up for automated code reviews on this repo. Configure here.

@socket-security

socket-security Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedgolang/​github.com/​kernel/​kernel-go-sdk@​v0.85.0 ⏵ v0.87.072 +1100100100100

View full report

@yummybomb
yummybomb marked this pull request as ready for review August 10, 2026 15:00

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit fd522c5. Configure here.

Comment thread cmd/audit_logs_export.go Outdated
Comment thread cmd/audit_logs_export.go Outdated
@yummybomb
yummybomb requested a review from sjmiller609 August 10, 2026 15:16

@sjmiller609 sjmiller609 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed — overall looks good. two low-priority follow-ups:

Nits

  • cmd/audit_logs_export.go:444-450 — nit: truncate by runes or display width; byte slicing can split UTF-8 error messages.

Tests

  • cmd/audit_logs_export_test.go:319-375 — consider exercising auditLogsExportClient.List through an httptest.Server; parser and fake tests do not verify SDK response-header capture.

@yummybomb
yummybomb merged commit 77a6def into main Aug 10, 2026
7 checks passed
@yummybomb
yummybomb deleted the hypeship/audit-logs-s3-export branch August 10, 2026 15:50
kernel-internal Bot added a commit that referenced this pull request Aug 10, 2026
Bump github.com/kernel/kernel-go-sdk to
v0.87.1-0.20260810163328-5819723ab49d (5819723). The merge of main into
this branch had reset go.mod to v0.87.0, so this diff spans v0.87.0.

SDK changes in range:
- New BrowserProxyConfigParam / BrowserProxyMode on BrowserNewParams and
  BrowserUpdateParams, plus BrowserProxy / BrowserProxyConfig responses.
  Already covered by --proxy-id/--proxy-name/--proxy-mode on `browsers
  create` and `browsers update`.
- New ManagedAuthBrowserConfigParam (stealth, proxy, telemetry) on auth
  connection create, update, and login. Already covered by --stealth,
  --proxy-*, --telemetry, and --telemetry-export-otlp.
- HealthCheckInterval docs now document a Free-plan minimum of 21600 (6h)
  and a default of 3600 or the plan minimum, whichever is larger.

Changes:
- Fix a build break inherited from the main merge: cmd/projects.go
  imported samber/lo but main's header-based pagination rewrite no longer
  uses it, so `go build ./...` failed on the branch tip.
- Reword --health-check-interval help on `auth connections create` and
  `update` to match the new SDK docs (plan minimums incl. Free 21600,
  and the max(3600, plan minimum) default).

Coverage analysis: full enumeration of all 134 methods in api.md against
the CLI command tree found no missing commands. Param-field sweep across
all 111 *Params/*RequestParam structs found no missing flags.

Investigated and deliberately not added: the SDK exposes
Telemetry.Export.Otlp on BrowserUpdateParams and on all three
BrowserPool*Params, because every telemetry field is generated from one
shared BrowserTelemetryRequestConfig schema. The API does not honor it
there -- openapi.yaml states pools reject export and browser update
ignores it, and a live `browser-pools create --telemetry-export-otlp`
probe returned "telemetry.export is only supported when creating a
browser". Export stays on `browsers create` and the managed-auth
commands only, as README already documents.

Note for reviewers: the 6 audit-logs export-destination endpoints are
still marked x-cli-skip in openapi.yaml but were implemented on main in
#214, so `kernel audit-logs export *` now covers them. Left as-is; the
annotation looks stale.

Tested: go build ./..., go vet ./..., go test ./... (all pass).
Against the live API: `projects list` (the file with the build fix),
`auth connections list`, `browsers list`, and a full proxy-config round
trip -- `browsers create --proxy-mode direct --stealth` returned
proxy.mode=direct, `browsers update --proxy-mode default` then
`browsers get` returned proxy.mode=default, `browsers delete` cleaned up.
Verified the reworded --health-check-interval help renders.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants