Repository navigation
feat(audit): add the audit trail core - #188
Merged
Merged
Conversation
…th and agent events) fog-node now keeps an append-only audit trail, like FOG 1.6 (ADR 0021 there, ADR 0003 here): - AuditLog model, with indexes from audit/ensure-indexes at bootstrap. - audit.record writes one row and never throws into a request. - Each request gets a correlationId. The middleware in config/http.js attaches the response finish listener, so the seam also sees a 403 from Sails' own CSRF check. - The seam records every 401/403 and every authenticated write. It skips allowed reads, the read-only POSTs (datatables, columns, task history, token), /agent/v1/, sign-in/out and assets. - audit.can records the permission that a check consulted, so a denial row names it. Group refusals name group.update or group.create. A refused or failed page save is recorded as denied or failed, not as its 302. - auth.login, auth.login.failed, auth.logout and auth.token.rejected. A JWT request now reports authVia 'jwt'. - agent.enroll and agent.token rows with the 1.6 texts. - http.trustProxy defaults to false, and setup carries it forward. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
fog-node now keeps an append-only audit trail, like FOG 1.6 (its ADR 0021). The decisions are in
docs/adr/0003-audit-trail.md. The brief is2026-11-10-audit-core.AuditLogmodel. Its indexes come fromaudit/ensure-indexesat bootstrap (migrate: 'safe'). It has nostock.auditlogCRUD routes.sails.helpers.audit.recordwrites one row and never throws into a request.api/hooks/audit). Each request gets acorrelationId. The middleware inconfig/http.jsattaches thefinishlistener, so the seam also records a 403 from Sails' own CSRF check. It records every 401/403 and every authenticatedPOST/PUT/PATCH/DELETE./agent/v1/./csrfToken.general/datatable,general/columns,task-history,auth/token, and alsohost/pending-datatable.sails.helpers.audit.can(req, perm)replaces the inline permission checks in the policies and controllers. A denial row then names the permission. Group refusals namegroup.updateorgroup.create. A refused or failed page save is recorded asdeniedorfailed, not as its 302.auth.login,auth.login.failed,auth.logoutandauth.token.rejected. A JWT request now reportsauthVia: 'jwt'.agent.enrollandagent.token, with the 1.6 texts.http.trustProxydefaults tofalse.npm run setupcarries it forward.docs/install.mdexplains when to set it.Known gaps
npm testrun leaves a few rows that the cleanup cannot attribute to the suite: anonymous denied requests andauth.token.rejected. They have no test name to match. The ADR says which rows the cleanup deletes.permission, as the brief allows.Test
npm test: 382 passing. The newtest/integration/audit.test.jscovers the seam, the auth and agent events, the outcome overrides and the CSRF refusal. The seam, CSRF, page-save and sign-in tests were each made to fail with their feature removed.npm run test:ui,npm run test:ui:prod,npm run test:install: green.🤖 Generated with Claude Code