AWS announces preview of AWS Interconnect - multicloud
AWS announces AWS Interconnect – multicloud (preview), providing simple, resilient, high-speed private connections to other cloud service providers. AWS Interconnect - multicloud is easy to configure and provides high-speed, resilient connectivity with dedicated bandwidth, enabling customers to interconnect AWS networking services such as AWS Transit Gateway, AWS Cloud WAN, and Amazon VPC to other cloud service providers with ease.
如何使用 pgAudit 擴充功能來稽核執行 Amazon RDS for PostgreSQL 資料庫執行個體?
我想要稽核 Amazon Relational Database Service (Amazon RDS) for PostgreSQL 資料庫實例中的所有資料庫、角色、關係和資料欄。此外,我想設定 pgAudit 擴充功能,為不同角色提供不同層級的稽核。
解決方法
您可以設定其他參數來記錄 RDS for PostgreSQL 資料庫執行個體上活動。啟動 pgAudit 擴充功能之後,您可以設定 pgaudit.log 參數以稽核特定的資料庫、角色、表格和資料欄。首先,在資料庫、角色或表格的參數群組中將 pgaudit.log 參數值設定為 none:
> show pgaudit.log;+---------------+ | pgaudit.log | |---------------| | none | +---------------+ SHOW
使用 pgAudit 擴充功能來稽核資料庫
請完成下列步驟:
- 執行下列命令,僅在您的資料庫中覆寫 pgaudit.log 參數的系統組態:
**注意:**使用您的資料庫名稱取代 test_database 資料庫。上述命令會將 pgaudit.log 參數的值變更為 All,如此 pgAudit 僅會稽核 test_database。ALTER DATABASE test_database set pgaudit.log='All'; - 連線到資料庫,然後執行下列查詢以稽核資料庫:
**注意:**使用您要稽核的表格取代 aud_table。select * from aud_table;
錯誤日誌的輸出類似於下列內容:2019-06-25 19:21:35 UTC:192.0.2.7(39330):testpar@test_database:[21638]:LOG: AUDIT: SESSION,2,1,READ,SELECT,,,select * from test_table;,<not logged>
使用 pgAudit 擴充功能來稽核角色
您也可以修改 pgaudit.log 參數中的角色以具有不同的值。若要為您的角色設定不同的 pgaudit.log 參數值,請執行下列命令:
ALTER ROLE test1 set pgaudit.log='All';
ALTER ROLE test2 set pgaudit.log='DDL';
**注意:**使用角色名稱取代 test1 和 test2。
若要檢查是否已在角色層級進行了修改,執行下列查詢:
> select rolname,rolconfig from pg_roles where rolname in ('test1',' test2'); +-----------+----------------------+ | rolname | rolconfig | |-----------+----------------------| | test1 | [u'pgaudit.log=All'] | | test2 | [u'pgaudit.log=DDL'] | +-----------+----------------------+ SELECT 2 Time: 0.010s
**注意:**使用角色名稱取代 test1 和 test2。
若要測試角色的 pgAudit 記錄行為,請對每個角色執行下列查詢:
CREATE TABLE test_table (id int);CREATE TABLE
select * from test_table;id ---- (0 rows)
兩個不同角色的日誌輸出類似於下列範例。
test1:
...2019-06-26 14:51:12 UTC:192.0.2.7(44754):test1@postgres:[3547]:LOG: AUDIT: SESSION,1,1,DDL,CREATE TABLE,,,CREATE TABLE test_table (id int);,<not logged> 2019-06-26 14:51:18 UTC:192.0.2.7(44754):test1@postgres:[3547]:LOG: AUDIT: SESSION,2,1,READ,SELECT,,,select * from test_table;,<not logged> ...
test2:
...2019-06-26 14:53:54 UTC:192.0.2.7(44772):test2@postgres:[5517]:LOG: AUDIT: SESSION,1,1,DDL,CREATE TABLE,,,CREATE TABLE test_table (id int);,<not logged> ...
在 test2 範例輸出中,SELECT 查詢沒有稽核項目,因為 test2 的 pgaudit.log 參數僅設定為 DDL。此測試驗證 test2 角色僅記錄 DDL 作業。
使用 pgAudit 擴充功能來稽核表格
注意: pgAudit 擴充功能只能記錄 SELECT、INSERT、UPDATE 和 DELETE 命令。擴充功能無法稽核 TRUNCATE。
若要稽核您的表格,請執行下列命令,以授予 rds_pgaudit 角色存取這些命令的權限:
grant select, delete on test_table to rds_pgaudit;
**注意:**上述命令允許 **rds_pgaudit ** 角色存取 SELECT 和 DELETE。使用您要稽核的命令取代 SELECT 和 DELETE。
若要確認稽核記錄是否正確設定,請在表格上執行陳述式。下列範例命令在 test_table 上執行 DELETE 陳述式:
Time: 0.008s DELETE 1 >delete from test_table where pid=5050;
DELETE 陳述式的輸出類似於下列內容:
2019-06-25 17:13:02UTC:192.0.2.7(41810):postgresql104saz@postgresql104saz:[24976]:LOG: AUDIT: OBJECT,3,1,WRITE,DELETE,TABLE,public.t1,delete from test_table where pid=5050,<not logged>
使用 pgAudit 擴充功能稽核資料欄
您可以稽核特定表格的資料欄,例如當敏感資料僅存在於一個資料欄中時。下列範例命令會建立一個工資表,其中包含必須稽核的薪資資料敏感資料欄:
create table payroll( name text, salary text );
若要稽核薪資資料欄,請先執行下列命令,將 rds_pgaudit 角色存取權限授予薪資資料欄上的 SELECT:
grant select (salary) on payroll to rds_pgaudit;
然後,執行以下命令選擇表格中的所有資料欄,包括薪資資料欄:
select * from payroll;
如果 SELECT 查詢不包含薪資資料欄,則 pgAudit 不會稽核該資料欄。
在下列範例輸出中,pgAudit 會稽核包含薪資資料欄的任何 SELECT:
2019-06-25 18:25:02 UTC:192.0.2.7(42056):postgresql104saz@postgresql104saz:[4118]:LOG: AUDIT: OBJECT,2,1,READ,SELECT,TABLE,public.payroll,select * from payroll,<not logged>
相關資訊
相關內容
- 已提問 2 年前
- 已提問 2 年前

