From harness-claude
Guides compliance logging for SOC2, GDPR, HIPAA, PCI-DSS: maps controls, retention policies, audit trails, and balances data minimization with breach detection.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Regulatory frameworks mandate specific logging requirements -- SOC2, GDPR, HIPAA, and
Designs structured, tamper-evident audit logs for security events like authentication, authorization, and data access. Useful for new apps, adding logs to existing systems, SOC2/HIPAA/PCI-DSS compliance, or incident investigation.
Implements tamper-evident audit logging, SIEM integration, vulnerability scanning, and compliance reporting for Python, Go, TypeScript apps.
Implements structured security audit logging for compliance, forensics, and SIEM integration in Node.js, Python, and Java. Use for audit trails and monitoring.
Share bugs, ideas, or general feedback.
Regulatory frameworks mandate specific logging requirements -- SOC2, GDPR, HIPAA, and PCI-DSS each define what must be logged, how long logs are retained, and what constitutes auditable evidence, and failing to meet these requirements carries fines, legal liability, and loss of certification
Compliance logging failures create two categories of organizational risk: regulatory penalties and undetectable breaches.
Map your regulatory obligations to specific logging controls. Each framework has explicit logging requirements:
Implement correct retention periods. Retention is not optional -- both too short and too long create violations:
Define what to log and what to exclude. The core auditable events are:
j***@example.com), IP addresses in GDPR
jurisdictions (IP is personal data -- log truncated or hashed IPs for analytics, full IPs
only for security investigation with documented legal basis), names (log user IDs, not
full names, unless the audit requires name resolution).Ensure tamper evidence for audit trails. Auditors must trust that logs have not been modified after the fact:
Maintain audit readiness at all times. Compliance is not a point-in-time activity:
SOC2 Type II vs Type I and the logging implications: Type I audits assess control design at a point in time -- the auditor verifies that logging controls exist. Type II audits assess control effectiveness over a period (typically 12 months) -- the auditor verifies that logging controls operated continuously and correctly throughout the period. A single month with missing logs or disabled monitoring can result in a qualified opinion or exception in the SOC2 Type II report. This means logging infrastructure must be treated with the same availability requirements as production systems.
GDPR's legitimate interest basis for security logging: Under GDPR, processing personal data requires a legal basis. For security logging, the most common basis is Article 6(1)(f) -- legitimate interest. The organization has a legitimate interest in detecting and preventing security incidents. A Legitimate Interest Assessment (LIA) documents that the logging is necessary, proportionate, and that the individual's rights do not override the interest. This assessment should be documented and reviewed annually. Without it, logging personal data (even IP addresses) lacks a legal basis.
PCI-DSS Requirement 10 in depth: Requirement 10.2 mandates logging specific events. Requirement 10.3 mandates specific fields in each log entry: user identification, type of event, date and time, success or failure, origination of event, identity or name of affected data/system/resource. Requirement 10.4 mandates time synchronization using NTP -- all systems must agree on the time so that log correlation across systems is accurate. Requirement 10.5 mandates securing audit trails so they cannot be altered. Requirement 10.7 mandates retaining audit trail history for at least 12 months.
Log format standardization across services: Use a consistent structured format (JSON with a defined schema) across all services. Every log entry should include: timestamp (ISO 8601, UTC), event type (from a controlled vocabulary), actor (user ID, service account, or system), action (verb from a controlled vocabulary), resource (what was acted upon), outcome (success/failure), source IP, request ID (for correlation), and session ID. Inconsistent formats across services make audit evidence unreliable because the auditor cannot compare events across systems.
Logging PII or PHI without masking. An organization implements comprehensive logging to demonstrate HIPAA compliance but includes patient names and diagnosis codes in access logs. The logs themselves now contain ePHI, requiring the same protections as the clinical database. The logging system has created a second copy of sensitive data, expanding the attack surface and the compliance scope. Log the access event (who, when, which record ID) but not the record content.
Retaining logs indefinitely without a documented policy. An organization stores all logs forever because "storage is cheap" and "we might need them." Under GDPR, this violates Article 5(1)(e) storage limitation -- personal data must not be kept longer than necessary. The organization now has years of IP addresses, user activity patterns, and behavioral data with no legal basis for retention. Define retention periods per regulatory requirement, implement automated deletion, and document the policy.
No centralized log collection. Logs remain on individual application servers, database servers, and network devices. When an auditor requests evidence, the team must manually collect logs from dozens of systems, hoping nothing was lost to log rotation or disk failures. When an attacker compromises a server, they delete the local logs to cover their tracks. Ship all logs to a centralized, access-restricted system within seconds.
Different logging standards across services. One service logs authentication events with user ID and timestamp. Another logs with username and local time. A third does not log authentication events at all. The auditor cannot construct a consistent picture of access patterns across the organization. Define a logging standard with required fields and event types, enforce it through shared libraries or middleware, and validate compliance in CI.
Treating compliance logging as a separate system from security logging. Building a dedicated "compliance log" pipeline that captures a subset of events for auditors, while the security team uses a different logging pipeline for detection and response. The compliance logs miss events the security team catches, and the security logs miss events the auditors need. Use a single logging infrastructure that serves both purposes. Apply different retention policies and access controls to the same data rather than maintaining parallel systems.