Adding cross-DBMS security configuration audit (--audit)

This commit is contained in:
Miroslav Štampar 2026-10-19 18:34:39 +02:00
parent 6530184e2c
commit d0ad9b2e34
43 changed files with 1236 additions and 3 deletions

View file

@ -0,0 +1,5 @@
SELECT audit_key,audit_value FROM (
SELECT name AS audit_key,CASE WHEN setting IS NULL THEN 'N' ELSE 'V'||setting END AS audit_value
FROM pg_catalog.pg_settings
WHERE name IN ('ssl','password_encryption','row_security','logging_collector','log_statement','log_connections','log_disconnections')
) audit_rows ORDER BY audit_key

View file

@ -0,0 +1,7 @@
SELECT audit_key,audit_value FROM (
SELECT 'effective account' AS audit_key,CASE WHEN CURRENT_USER IS NULL THEN 'N' ELSE 'V'||CAST(CURRENT_USER AS TEXT) END AS audit_value
UNION ALL
SELECT 'login identity' AS audit_key,CASE WHEN SESSION_USER IS NULL THEN 'N' ELSE 'V'||CAST(SESSION_USER AS TEXT) END AS audit_value
UNION ALL
SELECT 'database' AS audit_key,CASE WHEN CURRENT_DATABASE() IS NULL THEN 'N' ELSE 'V'||CAST(CURRENT_DATABASE() AS TEXT) END AS audit_value
) audit_rows ORDER BY audit_key

View file

@ -0,0 +1,7 @@
SELECT audit_key,audit_value FROM (
SELECT 'superuser' AS audit_key,'V'||CASE WHEN rolsuper THEN '1' ELSE '0' END AS audit_value FROM pg_catalog.pg_roles WHERE rolname=CURRENT_USER
UNION ALL
SELECT 'bypass RLS','V'||CASE WHEN rolbypassrls THEN '1' ELSE '0' END FROM pg_catalog.pg_roles WHERE rolname=CURRENT_USER
UNION ALL
SELECT rolname,'V'||CASE WHEN pg_has_role(oid,'USAGE') THEN '1' ELSE '0' END FROM pg_catalog.pg_roles WHERE rolname IN ('pg_read_server_files','pg_write_server_files','pg_execute_server_program')
) audit_rows ORDER BY audit_key