Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
docs(backend): audit log event quality rule
bernie-gc534eaf0f664
diff --git a/AGENTS.md b/AGENTS.mdindex b0ccc5dc72..5876dc2abe 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -6,7 +6,7 @@ Check out CLAUDE.md for additional context on project file structure and general**Read the [Backend Code Quality Guide](backend/CODE_QUALITY.md) for any change under `backend/`, and check your work against it before reporting the task done.** Features, refactors, bug fixes, and reviews all count.-It is a short, deliberately non-exhaustive floor: error messages users can understand (and no pointless 500s), validation on every API input, correct pagination when calling third-party APIs, no deadlock conditions on a small connection pool, and REST-aligned API interfaces.+It is a short, deliberately non-exhaustive floor: error messages users can understand (and no pointless 500s), validation on every API input, correct pagination when calling third-party APIs, no deadlock conditions on a small connection pool, REST-aligned API interfaces, and audit log events an admin can actually read.Treat that list as a summary of the guide's current contents, not as a condition for reading it. A change that does not look like any of those topics still gets checked, because the guide grows and because the items apply in places they are not obviously about (a bug fix that adds a query inside an existing transaction, a refactor that moves a third-party list call).diff --git a/CLAUDE.md b/CLAUDE.mdindex fd0b4fc09b..9169f80aa3 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -68,7 +68,7 @@ Both `backend/` and `frontend/` enforce a minimum release age of 7 days for npm**Read [`backend/CODE_QUALITY.md`](backend/CODE_QUALITY.md) for every backend change, and check the change against it before calling the work done.** This applies to all work under `backend/`: new features, refactors, bug fixes, and reviews alike.-It is a floor, not an exhaustive standard: user-understandable error messages and no pointless 500s, explicit validation on every API input, correct pagination when calling third-party APIs, avoiding deadlock conditions on a small connection pool (thread `tx`, keep transactions short), and REST-aligned API interfaces (flag deviations for the author to confirm rather than implementing them silently).+It is a floor, not an exhaustive standard: user-understandable error messages and no pointless 500s, explicit validation on every API input, correct pagination when calling third-party APIs, avoiding deadlock conditions on a small connection pool (thread `tx`, keep transactions short), REST-aligned API interfaces (flag deviations for the author to confirm rather than implementing them silently), and audit log events an admin can actually read (every id paired with a human-readable label).That list describes what the guide currently covers; it is **not** a test for whether the guide applies. Do not skip it because a change does not look like one of those topics. Read it, then decide which items are relevant.diff --git a/backend/CODE_QUALITY.md b/backend/CODE_QUALITY.mdindex 2d53fcb056..693f315e68 100644--- a/backend/CODE_QUALITY.md+++ b/backend/CODE_QUALITY.md@@ -11,6 +11,7 @@ Expect it to grow as we find more worth checking.- [Paginate external API calls](#paginate-external-api-calls)- [Do not create deadlock conditions](#do-not-create-deadlock-conditions)- [Intuitive API interfaces](#intuitive-api-interfaces)+- [Audit log events admins can read](#audit-log-events-admins-can-read)- [License checks](#license-checks)---@@ -263,6 +264,42 @@ customers are calling it.---+## Audit Log Events Admins Can Read++An audit log event is read by an admin investigating an incident, in a UI that renders the+`metadata` body as raw JSON, or in their own SIEM. They cannot run a query to expand a UUID.++**Every identifier in an event's `metadata` must be paired with a human-readable label,+resolved when the event is emitted.** An identifier is any field whose name ends in an+id-like token in any casing (`groupId`, `group_id`, `groupID`), or a lone `id`. An optional+id takes an equally optional label. Resolve the label by loading the parent record; adding+the field to the type and passing `undefined` does not count. This applies to the event body+only, not the surrounding envelope, which already carries the actor and org.++```ts+// Bad: nothing here tells the admin which certificate this was+metadata: { certificateId: cert.id, profileId: profile.id }++// Good+metadata: { certificateId: cert.id, commonName: cert.commonName, profileId: profile.id, profileName: profile.slug }+```++**Name the field after what it identifies.** `requestId` on an event that carries an+approval request's id sends the reader looking for a certificate request that does not+match. Prefer `approvalRequestId`.++**Record the outcome, not just the attempt.** A handler that logs the same event whether the+operation succeeded, failed, or is awaiting approval produces a log that cannot answer+"did this happen?". Where a service returns a status, put it in the metadata, and only emit+result fields (a new id, a serial number) when the result actually exists.++**Renaming, retyping, or removing a field on an existing event is a breaking change.** These+bodies go to customer SIEMs unchanged, so a field that switches from string to number, or+disappears, silently breaks rules built on it. Adding a field is safe; changing one needs a+deliberate call.++---+## License ChecksA license check answers exactly one question: **is this org entitled to use this feature