Habilitar auditoria / logging
Oracle
-- Unified Auditing (12c+):
CREATE AUDIT POLICY table_audit
ACTIONS SELECT, INSERT, UPDATE, DELETE ON hr.employees;
AUDIT POLICY table_audit;
-- Monitoring: SELECT * FROM unified_audit_trail ORDER BY event_timestamp DESC;Com o Unified Auditing, uma política é criada e habilitada com AUDIT; os registros ficam na view unified_audit_trail.
PostgreSQL
-- pgaudit extension (recommended; first shared_preload_libraries = 'pgaudit' + restart + CREATE EXTENSION pgaudit):
ALTER SYSTEM SET pgaudit.log = 'write, ddl';
SELECT pg_reload_conf();
-- Simple built-in method:
ALTER SYSTEM SET log_statement = 'ddl';
SELECT pg_reload_conf();O pgaudit fornece log de auditoria detalhado; configure-o com ALTER SYSTEM para valer em todo o servidor (um SET em nível de sessão audita apenas aquela sessão). Sem a extensão, o logging básico é habilitado com log_statement ('ddl','mod','all'). Atenção ao volume de log.
MySQL
-- Enterprise/MariaDB audit plugin:
INSTALL PLUGIN audit_log SONAME 'audit_log.so';
SET GLOBAL audit_log_policy = 'ALL';
-- Simple alternative (all queries):
SET GLOBAL general_log = 'ON';O plugin audit_log (Enterprise, ou server_audit no MariaDB) mantém uma trilha de auditoria detalhada; o general_log registra todas as consultas, mas degrada o desempenho.
SQL Server
USE master;
CREATE SERVER AUDIT Audit_A TO FILE (FILEPATH = 'C:\\audit\\');
ALTER SERVER AUDIT Audit_A WITH (STATE = ON);
USE mydb;
CREATE DATABASE AUDIT SPECIFICATION db_spec
FOR SERVER AUDIT Audit_A
ADD (SELECT, INSERT, UPDATE, DELETE ON SCHEMA::dbo BY public)
WITH (STATE = ON);Primeiro crie e habilite um destino SERVER AUDIT (arquivo/event log) e depois defina quais eventos rastrear com uma AUDIT SPECIFICATION de servidor ou de banco de dados.
MongoDB
# MongoDB Enterprise / Atlas only. Configuration (mongod.conf):
# auditLog:
# destination: file
# format: JSON
# path: /var/log/mongodb/audit.json
# filter: '{ atype: { $in: ["authCheck","createCollection","dropCollection"] } }'
# mongod --auditDestination file --auditPath /var/log/mongodb/audit.jsonA auditoria está disponível apenas no Enterprise e no Atlas; é habilitada com a seção auditLog da configuração do mongod. Não existe na edição Community.
Redis
ACL LOG
# Shows rejected authentication/command/key access attempts.
# To reset: ACL LOG RESET
# For general command auditing: an external proxy or MONITOR (with care).O ACL LOG registra automaticamente eventos de segurança (falhas de autenticação, comandos/chaves não autorizados); a auditoria completa de comandos não é nativa.
Elasticsearch
# elasticsearch.yml (on all nodes, restart required):
xpack.security.audit.enabled: true
# Optional event filter:
xpack.security.audit.logfile.events.include: [ "authentication_failed", "access_denied" ]O log de auditoria é habilitado com xpack.security.audit.enabled; é definido no elasticsearch.yml e exige restart do nó (não é dinâmico). Requer licença comercial.