{"id":518,"date":"2013-09-30T21:35:03","date_gmt":"2013-09-30T18:35:03","guid":{"rendered":"http:\/\/www.fatihacar.com\/blog\/?p=518"},"modified":"2013-09-30T21:50:31","modified_gmt":"2013-09-30T18:50:31","slug":"fine-grained-auditing-fga-in-oracle","status":"publish","type":"post","link":"http:\/\/www.fatihacar.com\/blog\/fine-grained-auditing-fga-in-oracle\/","title":{"rendered":"Fine Grained Auditing (FGA) in Oracle"},"content":{"rendered":"<p>Fine Grained Auditing (FGA), introduced with Oracle9i, can be understood as &#8216;policy-based auditing&#8217;. As opposed to the standard auditing functionality, FGA lets you specify the conditions necessary for an audit record. FGA policies are programatically bound to the object (table, view) by using the &#8216;dbms_fga&#8217; package.<\/p>\n<p>You have to have a valid set of Fine-Grained Audit policies to make it possible to specify access to the following items:<\/p>\n<ul>\n<li>A set of database objects (views or tables)<\/li>\n<li>A specific type of data (queried with SELECT, INSERT, UPDATE, and DELETE SQL statements)<\/li>\n<li>A specific column<\/li>\n<li>A specific value of a column<\/li>\n<\/ul>\n<p><strong>Procedure<\/strong><\/p>\n<blockquote><p>begin<br \/>\ndbms_fga.add_policy<br \/>\n( object_schema=&gt;&#8217;HR&#8217;<br \/>\n, object_name=&gt;&#8217;EMPLOYEES&#8217;<br \/>\n, policy_name=&gt;&#8217;SELECT_COUNT&#8217;<br \/>\n, audit_column =&gt; &#8216;FIRST_NAME&#8217;<br \/>\n, audit_condition =&gt; &#8221;<br \/>\n, handler_schema =&gt; &#8216;AUDITEDUSER&#8217;<br \/>\n, handler_module =&gt; &#8216;AUDIT_HANDLER.HANDLE_ACCESS&#8217;<br \/>\n);<br \/>\nend;<\/p><\/blockquote>\n<blockquote><p>\nCREATE OR REPLACE PACKAGE AUDIT_HANDLER<br \/>\nis<br \/>\nPROCEDURE HANDLE_ACCESS<br \/>\n( object_schema VARCHAR2<br \/>\n, object_name VARCHAR2<br \/>\n, policy_name VARCHAR2<br \/>\n);<br \/>\nend;<br \/>\n\/<\/p>\n<p>CREATE OR REPLACE PACKAGE BODY AUDIT_HANDLER<br \/>\nis<br \/>\nPROCEDURE HANDLE_ACCESS<br \/>\n( object_schema VARCHAR2<br \/>\n, object_name VARCHAR2<br \/>\n, policy_name VARCHAR2<br \/>\n) is<br \/>\n  PRAGMA AUTONOMOUS_TRANSACTION;<br \/>\nbegin<br \/>\n  insert into TABLENAME<br \/>\n  ( whodidit, whenwasit, sql_executed)<br \/>\n  values<br \/>\n  ( user, systimestamp, sys_context(&#8216;userenv&#8217;,&#8217;current_sql&#8217;))<br \/>\n  ;<br \/>\n  commit;<br \/>\nend HANDLE_ACCESS;<br \/>\nend;<br \/>\n\/<\/p>\n<p>begin<br \/>\n  dbms_fga.add_policy<br \/>\n  ( object_schema=>&#8217;SCHEMANAME&#8217;<br \/>\n  , object_name=>&#8217;TABLENAME&#8217;<br \/>\n  , policy_name=>&#8217;ACCESS_HANDLED&#8217;<br \/>\n  , audit_column => &#8216;COLUMNNAME&#8217;<br \/>\n  , audit_condition => &#8221;<br \/>\n  , handler_schema => &#8216;AUDITEDUSER&#8217;<br \/>\n  , handler_module => &#8216;AUDIT_HANDLER.HANDLE_ACCESS&#8217;<br \/>\n  );<br \/>\nend;<br \/>\n\/<\/p>\n<p>begin<br \/>\n  dbms_fga.drop_policy<br \/>\n  ( object_schema=>&#8217;SCHEMANAME&#8217;<br \/>\n  , object_name=>&#8217;TABLENAME&#8217;<br \/>\n  , policy_name=>&#8217;ACCESS_HANDLED&#8217;<br \/>\n  );<br \/>\nend;<\/p>\n<\/blockquote>\n<p>Source : Oracle Offical Documents<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fine Grained Auditing (FGA), introduced with Oracle9i, can be understood as &#8216;policy-based auditing&#8217;. As opposed to the standard auditing functionality, FGA lets you specify the conditions necessary for an audit record. FGA policies are programatically bound to the object (table, view) by using the &#8216;dbms_fga&#8217; package. You have to have a valid set of Fine-Grained&#8230;<\/p>\n","protected":false},"author":37,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9,12],"tags":[14,90,32],"class_list":["post-518","post","type-post","status-publish","format-standard","hentry","category-administration","category-oracle-procedure","tag-database-administration","tag-oracle","tag-oracle-administration"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p39NFI-8m","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/users\/37"}],"replies":[{"embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/comments?post=518"}],"version-history":[{"count":10,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/518\/revisions"}],"predecessor-version":[{"id":868,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/posts\/518\/revisions\/868"}],"wp:attachment":[{"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/media?parent=518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/categories?post=518"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.fatihacar.com\/blog\/wp-json\/wp\/v2\/tags?post=518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}