agentleFS
rrezartprebrezarrezartprebreza/spring-boot-skills/skills/spring-boot-3/security-audit-logging/SKILL.md

security-audit-logging

Skill344 starsChanged 3 months agoMITView on GitHub

Use when designing or reviewing security audit events, their redaction, durable storage, integrity, or failure policies in Spring Boot. General metrics and debugging logs belong to production observability rather than this security-event workflow.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Prefer typed fields: event ID, UTC time, verified actor ID, tenant ID, action, target ID, outcome and server-generated correlation ID.

    line 23
  2. Distinctive:

    Use a structured serializer, never concatenate JSON or interpolate untrusted text into lines.

    line 31
  3. Distinctive:

    Keep credentials, cookies, bearer tokens, passwords, session secrets, sensitive prompts, private documents and full configuration out of …

    line 38
  4. Distinctive:

    Do not globally fail every request or silently drop required audit events.

    line 48
  5. Distinctive:

    Do not publish Actuator auditevents, env or configprops to solve an investigation.

    line 52

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Security Audit Logging

Version boundary

Target Spring Boot 3 with Spring Framework 6 and Spring Security 6. Check the selected release's Actuator audit APIs before wiring listeners. The shipped Java 17 record has no Boot/Jackson dependency and is shared across both trees.

Event contract

Choose events needed for the requested security or business requirement: authentication decisions, access denial, privilege changes, sensitive exports and administrative actions. Separate attempted, denied, successful and failed operations. Do not log SUCCESS before the authoritative transaction commits.

Prefer typed fields: event ID, UTC time, verified actor ID, tenant ID, action, target ID, outcome and server-generated correlation ID. Unauthenticated events may have no actor; do not mislabel a supplied username as verified identity. Record only identifiers needed for the investigation, with controlled access and retention.

SecurityAuditRecord demonstrates bounded typed fields and a restricted correlation identifier. It intentionally has no arbitrary message, headers, token, request body or exception field. This is an event contract, not a durable audit sink. Use a structured serializer, never concatenate JSON or interpolate untrusted text into lines. The sample assumes tenant-scoped operations and UUID identities. Adapt those types and the success invariant to the application's actual identity model; do not invent tenants for a single-tenant system. Correlation IDs must be server-generated, not arbitrary caller text.

Delivery and access policy

  • Keep credentials, cookies, bearer tokens, passwords, session secrets, sensitive prompts, private documents and full configuration out of audit records. Sanitize controls and bound any separately approved free-text fields. Hashing arbitrary identifiers is not automatic anonymization.
  • Spring Boot's in-memory audit repository is for development, not durable evidence. Authentication events alone do not capture every business authorization decision.
  • For committed mutations requiring durable audit, use an atomic outbox alongside the business transaction. Deliver idempotently by event ID; handle duplicate delivery, backpressure, retention and retries. An after-commit listener can still lose events on process failure.
  • Explicitly choose failure behavior by operation. A required audit write may need to prevent a privileged mutation; optional read-event loss may instead trigger bounded buffering and alerts. Do not globally fail every request or silently drop required audit events.
  • Separate application write permissions from investigator read and retention/delete permissions. Define export controls, clock synchronization, access auditing and integrity checks. Append-only configuration alone is not proof of tamper resistance.
  • Do not publish Actuator auditevents, env or configprops to solve an investigation. Collection and external export require approved scope and a redacted handoff.

Verification and output

Exercise malformed/oversized correlation IDs, missing fields, all outcomes and stable event IDs. The local fixture tests record construction, not a production logging backend. Application integration tests must also prove rollback emits no committed-success event, outbox retry deduplicates, and sink failures follow the selected policy.

Provide a field inventory, access/retention policy, delivery semantics, failure matrix and tests run. Label evidence confirmed, suspected, or not verified rather than claiming compliance from the mere presence of log statements. See good design and bad design.

Gotchas

  • Agent logs request headers or principal.toString - select typed non-secret identifiers.
  • Agent writes SUCCESS before commit - tie success evidence to the committed operation.
  • Agent uses in-memory events as a production ledger - choose durable, access-controlled storage.
  • Agent swallows sink failures - implement the operation's documented audit failure policy.

Official sources

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.