본문으로 건너뛰기
cccskills
무료GitHub에 공개

saas-lgpd-audit-logging

Design and implement immutable, hash-chained audit logging for accountability (LGPD Art. 6, X) and incident registration (Res. 15/2024 Art. 10, 5-year retention). Use when user asks 'audit log', 'log de auditoria', 'logging LGPD', 'accountability log', or as part of audit pipeline. Outputs schema + middleware patterns for Next.js.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

실행 점수 미검증

설치 방법 보기

포함된 파일(1)

  • SKILL.md4.2 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Audit Logging

Interaction Localization Rule: When locale: pt-BR (or user speaks Portuguese), ALL questions (AskUserQuestion / sk_question), confirmation prompts, and selectable options MUST be translated and presented in Brazilian Portuguese (PT-BR). Any English question text or options in this skill are illustrative examples — NEVER display English questions or options to a Portuguese developer. Internal reasoning, code synthesis, tests, and technical documentation MUST remain in English (except Brazilian statutory compliance documents under .lgpd/).

Log imutável encadeado para prova de conformidade (Art. 6º, X — responsabilização) e registro de incidentes (Art. 10 Res. 15/2024 — 5 anos).

Princípios

  1. Append-only — sem updates nem deletes
  2. Hash chain — cada entry referencia o hash da anterior (tamper-evident)
  3. Minimização — log evento e hash do payload, NÃO o payload em claro
  4. PII out — nunca logar PII completa (mascarar)
  5. Retenção — mínimo 5 anos para eventos relacionados a incidentes; 6m+ para eventos correntes

Eventos a logar

  • Autenticação (login, logout, MFA, falhas)
  • Acesso a dados pessoais (especialmente sensíveis)
  • Mudanças em consentimento (grant, revoke)
  • DSAR (recebimento, fulfillment, rejeição)
  • Mudanças de configuração de privacidade
  • Acesso administrativo a dados de outros usuários
  • Exports e downloads em massa
  • Mudanças em RBAC

Schema Prisma

model AuditLogEntry {
  id          String   @id @default(cuid())
  actorId     String?  // null se sistema
  actorType   ActorType
  action      String   // "READ", "WRITE", "DELETE", "EXPORT", "DSAR_FULFILLED", "CONSENT_REVOKED"
  resource    String   // "User:abc123", "Order:xyz"
  subjectId   String?  // titular afetado (se aplicável)
  legalBasis  String?
  purpose     String?
  ipAddress   String?  @db.Inet
  userAgent   String?
  payloadHash String   // SHA-256 do payload (sem PII)
  prevHash    String?  // hash do registro anterior
  selfHash    String   // SHA-256(prevHash || timestamp || action || resource || payloadHash)
  timestamp   DateTime @default(now())

  @@index([subjectId, timestamp])
  @@index([actorId, timestamp])
  @@index([action, timestamp])
}

enum ActorType { USER ADMIN SYSTEM OPERATOR }

Middleware Next.js

// lib/audit.ts
import { createHash } from "crypto";
import { db } from "./db";

export async function logAudit(entry: {
  actorId?: string;
  actorType: ActorType;
  action: string;
  resource: string;
  subjectId?: string;
  legalBasis?: string;
  purpose?: string;
  payload?: object;
  req?: Request;
}) {
  const last = await db.auditLogEntry.findFirst({
    orderBy: { timestamp: "desc" },
    select: { selfHash: true }
  });

  const payloadHash = createHash("sha256")
    .update(JSON.stringify(entry.payload ?? {}))
    .digest("hex");

  const timestamp = new Date();

  const selfHash = createHash("sha256")
    .update(`${last?.selfHash ?? ""}|${timestamp.toISOString()}|${entry.action}|${entry.resource}|${payloadHash}`)
    .digest("hex");

  return db.auditLogEntry.create({
    data: {
      ...entry,
      payload: undefined,
      payloadHash,
      prevHash: last?.selfHash,
      selfHash,
      ipAddress: entry.req?.headers.get("x-forwarded-for") ?? null,
      userAgent: entry.req?.headers.get("user-agent") ?? null,
      timestamp
    }
  });
}

Verificação de integridade

Script periódico que percorre todas as entries em ordem e verifica que cada selfHash bate. Qualquer divergência = tampering ou bug.

Status update

## F6 — Audit logging ✓
- Schema implementado
- Middleware ativo em rotas críticas
- Verificação de integridade agendada (semanal)
- Retenção configurada (5 anos para eventos críticos)
- Próximo: saas-lgpd-encryption-keys

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Turn your AI session into an autonomous SaaS and software engineering studio with 49 specialized agents, 74 workflow skills (/saas-*), 28 director gates, and complete architecture across Next.js, FastAPI, Supabase, Tailwind, and Stripe.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Basinfy/Basinfy-SaaS-Studio32026년 10월 24일 업데이트

Brownfield audit — do existing artifacts actually work? Numbered migration plan. Unlike /saas-project-stage-detect, checks compliance not existence.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Basinfy/Basinfy-SaaS-Studio32026년 10월 24일 업데이트

Create an ADR documenting a technical decision: context, alternatives considered, consequences.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Basinfy/Basinfy-SaaS-Studio32026년 10월 24일 업데이트

Traceability matrix mapping PRD requirements to ADRs. Finds gaps, cross-ADR conflicts, stack compatibility. PASS/CONCERNS/NOT ASSESSED/FAIL.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Basinfy/Basinfy-SaaS-Studio32026년 10월 24일 업데이트

Audit assets against naming conventions, file size budgets, format standards. Finds orphaned assets, missing references.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Basinfy/Basinfy-SaaS-Studio32026년 10월 24일 업데이트

Author per-asset visual specs, SVG dimensions, and generation prompts from PRDs and design tokens. After design tokens.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

Basinfy/Basinfy-SaaS-Studio32026년 10월 24일 업데이트

Basinfy의 스킬 모두 보기

이 스킬의 문제 신고