Bo's Oracle Station

查看: 2357|回复: 0

课程第17次

[复制链接]

27

主题

27

帖子

183

积分

超级版主

Rank: 8Rank: 8

积分
183
发表于 2019-10-30 20:21:02 | 显示全部楼层 |阅读模式
  1. select  * from dba_obj_audit_opts;

  2. select  sao.user_name, sao.audit_option, sao.success,sao.failure
  3. from dba_stmt_audit_opts sao
  4. minus
  5. select  pao.user_name, pao.privilege, pao.success, pao.failure
  6.   from dba_priv_audit_opts  pao;

复制代码
  1. select  * from dba_audit_trail at
  2.   order by at.timestamp  desc;
  3.   
  4. noaudit create session;


  5. select  * from dba_views v
  6. where v.owner='SYS' and v.view_name='DBA_AUDIT_TRAIL';


  7. select  * from dba_tables t
  8. where t.owner='SYS' and t.table_name='AUD


  9. ;


  10. create tablespace tbsaudit datafile size 20M autoextend on;

  11. alter table aud$ move tablespace tbsaudit;

  12. truncate table aud$;


  13. audit create session by ops$oracle by access whenever successful;


  14. select  pao.user_name, pao.privilege, pao.success, pao.failure
  15.   from dba_priv_audit_opts  pao;
复制代码
  1. grant sysdba to hr;

  2. select  u.password
  3.   from user$ u where u.name='HR';
  4.   
  5. ----
  6. select   p."SPID"
  7.   from v$process p , v$session s
  8.   where p."ADDR"=s."PADDR" and
  9.   s."TERMINAL"='pts/1';
复制代码

----
  1. select  sao.user_name, sao.audit_option, sao.success,sao.failure
  2. from dba_stmt_audit_opts sao
  3. minus
  4. select  pao.user_name, pao.privilege, pao.success, pao.failure
  5.   from dba_priv_audit_opts  pao;
  6.   
  7. audit table by hr by access;


  8. -------------------

  9. select  * from dba_audit_trail at
  10.   order by at.timestamp  desc;
  11.   
  12. select  * from dba_common_audit_trail  cat
  13. order by cat.extended_timestamp desc;

  14. alter system set audit_trail='db','extended' scope=spfile;

  15. grant select any table to hr;

  16. audit select  any table by hr by session;

  17. select  * from v$xml_audit_trail;

  18. alter system set audit_trail='xml','extended' scope=spfile;

  19. ----


  20. grant  update (email) on hr.employees  to ops$oracle;

  21. select * from dba_col_privs;
复制代码

  1. create or replace directory  fgalog as '/home/oracle/FGALOG';
  2. -----


  3. CREATE OR REPLACE PROCEDURE PROC_FGA  ( object_schema VARCHAR2, object_name VARCHAR2, policy_name
  4. VARCHAR2 ) AS
  5.   v_filehandle UTL_FILE.FILE_TYPE;
  6. begin
  7.   v_filehandle:=utl_file.fopen(location => 'FGALOG',filename => 'FGA.log',open_mode => 'w');
  8.   
  9.   utl_file.put_line(file =>  v_filehandle,buffer =>object_schema );
  10.   utl_file.put_line(file =>  v_filehandle,buffer =>object_name);
  11.   utl_file.put_line(file =>  v_filehandle,buffer =>policy_name);
  12.   utl_file.put_line(file =>  v_filehandle,buffer =>sys_context('userenv','ip_address'));
  13.   utl_file.put_line(file =>  v_filehandle,buffer => sys_context('userenv','session_user'));
  14.   utl_file.put_line(file =>  v_filehandle,buffer =>sys_context('userenv','current_user'));
  15.   
  16.    utl_file.put_line(file =>  v_filehandle,buffer =>to_char(sysdate,'YYYY-MM-DD:HH24:MI:SS'));
  17.    
  18.   utl_file.put_line(file =>  v_filehandle,buffer =>sys_context('userenv','authentication_type'));
  19.   utl_file.new_line( v_filehandle);
  20.   
  21.   
  22.   
  23.   utl_file.fclose( v_filehandle);
  24. end;


  25. begin
  26.    PROC_FGA  ('HR','EMPLOYEES', 'POLICY2');
  27. end;
  28. ----

  29. select  * from dba_audit_policies;

  30. -----

  31. begin
  32.   dbms_fga.add_policy(object_schema => 'HR',
  33.   object_name => 'EMPLOYEES',
  34.   policy_name => 'POLICY1',
  35.   audit_condition => 'department_id=20',
  36.   audit_column => 'salary,commission_pct',
  37.   handler_schema => 'SYS',
  38.   handler_module => 'PROC_FGA',
  39.   statement_types => 'SELECT,UPDATE',
  40.   audit_trail => dbms_fga.XML+dbms_fga.EXTENDED,
  41.   audit_column_opts => dbms_fga.ANY_COLUMNS);
  42. end;


  43. --------------

  44. select  * from dba_common_audit_trail  cat
  45. order by cat.extended_timestamp desc;
复制代码






回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-5-20 05:34 , Processed in 0.038976 second(s), 24 queries .

快速回复 返回顶部 返回列表