ossc-db / pgaudit

PostgreSQL Audit Extension
Other
2 stars 4 forks source link

(refactored branch) Pattern matching with '%' character is not supported. #45

Open harada-toshi opened 7 years ago

harada-toshi commented 7 years ago

Overview

In the value '%' can be used for backward match or forward match.

Config file

[output]
        logger = 'serverlog'

# SQL(1)
[rule]
        class = 'READ,WRITE'
        object_name = 'public.f%'

# SQL(2)
[rule]
        class = 'READ,WRITE'
        object_name = 'public.f%,b%,public.baz%'

# SQL(3)
[rule]
        class = 'READ,WRITE'
        object_name = 'ba%,public.baz%,public.fo%'

Executed SQL

-- create objects
CREATE TABLE IF NOT EXISTS foo(id int, data text);
CREATE TABLE IF NOT EXISTS bar(id int, data text);
BEGIN;
INSERT INTO foo VALUES (1, 'aaa');
INSERT INTO bar VALUES (1, 'xxx');
UPDATE foo SET data = 'AAA' WHERE id = 1;
UPDATE bar SET data = 'XXX' WHERE id = 1;
SELECT * FROM foo;
SELECT * FROM bar;
DELETE FROM foo;
DELETE FROM bar;
TRUNCATE foo;
TRUNCATE bar;
COMMIT;
DROP TABLE foo;
DROP TABLE bar;

Log.

LOG:  connection received: host=[local]
LOG:  connection authorized: user=postgres database=postgres
LOG:  disconnection: session time: 0:00:00.060 user=postgres database=postgres host=[local]