{"id":199,"date":"2024-04-09T15:01:27","date_gmt":"2024-04-09T13:01:27","guid":{"rendered":"http:\/\/130.61.57.200\/?p=199"},"modified":"2024-04-09T15:01:27","modified_gmt":"2024-04-09T13:01:27","slug":"manage-audit-in-oracle","status":"publish","type":"post","link":"http:\/\/130.61.57.200\/index.php\/2024\/04\/09\/manage-audit-in-oracle\/","title":{"rendered":"Manage Audit in Oracle"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Enable Unified Auditing<\/h4>\n\n\n\n<p>To enable Unified Auditing (being available since 12c) stop instance and listener and relink auditing library:<\/p>\n\n\n\n<p>Check current value:<br>SELECT value FROM v$option WHERE parameter = &#8216;Unified Auditing&#8217;;<br>Let&#8217;s assume it is FALSE.<br>Stop instance.<br><br>Go to library directory and relink:<br>cd $ORACLE_HOME\/rdbms\/lib<br>make -f ins_rdbms.mk unaiaud_on ioracle<br><br>Start the instance<br><br>Check the value again.<br>Now it should be TRUE.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Audit Parameters<\/h4>\n\n\n\n<p>To check current audit settings we need to check two places:<\/p>\n\n\n\n<p>Audit parameters:<br>show parameter audit<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"588\" height=\"150\" src=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image.png\" alt=\"\" class=\"wp-image-202\" style=\"width:749px;height:auto\" srcset=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image.png 588w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-300x77.png 300w\" sizes=\"auto, (max-width: 588px) 100vw, 588px\" \/><\/figure>\n\n\n\n<p><strong>audit_file_dest <\/strong>specifies the operating system directory into which the audit trail is written when the&nbsp;<code>AUDIT_TRAIL<\/code>&nbsp;initialization parameter is set to&nbsp;<strong>os<\/strong>,&nbsp;<strong>xml<\/strong>, or&nbsp;<strong>xml,extended<\/strong>.<br><strong>audit_sys_operations <\/strong>enables or disables the auditing of directly issued user SQL statements with&nbsp;<code>SYS<\/code>&nbsp;authorization. These include SQL statements directly issued by users when connected with the&nbsp;<code>SYSASM<\/code>,&nbsp;<code>SYSBACKUP<\/code>,&nbsp;<code>SYSDBA<\/code>,&nbsp;<code>SYSDG<\/code>,&nbsp;<code>SYSKM<\/code>, or&nbsp;<code>SYSOPER<\/code>&nbsp;privileges, as well as SQL statements that have been executed with&nbsp;<code>SYS<\/code>&nbsp;authorization using the PL\/SQL package&nbsp;<code>DBMS_SYS_SQL<\/code>.<br><strong>audit_syslog_level <\/strong>allows&nbsp;<code>SYS<\/code>&nbsp;and standard&nbsp;<code>OS<\/code>&nbsp;audit records to be written to the system audit log using the&nbsp;<code>SYSLOG<\/code>&nbsp;utility.<br><strong>audit_trail <\/strong>enables or disables database auditing. Values are <strong>none<\/strong>, <strong>os <\/strong>(directing audit records to files), <strong>db <\/strong>(logging in SYS.AUD$ table), <strong>db,extended<\/strong> (extends db by keeping sql and variables information also), <strong>xml<\/strong> (writes in XML files) and <strong>xml,extended<\/strong> (extends xml  by keeping sql and variables information also).<br><strong>unified_audit_common_systemlog <\/strong>specifies whether key fields of unified audit records generated due to common audit policies will be written to the SYSLOG utility.<br><strong>unified_audit_sga_queue_size <\/strong>specifies the size in bytes of SGA queue for unified auditing.<br><strong>unified_audit_systemlog <\/strong>specifies whether key fields of unified audit records will be written to the SYSLOG utility (on UNIX platforms) or to the Windows Event Viewer (on Windows). In a CDB, this parameter is a per-PDB static initialization parameter.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Audit Management Configuration Parameters<\/h4>\n\n\n\n<p>Check Audit Management configuration parameters with:<br>select * from dba_audit_mgmt_config_params;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"621\" height=\"368\" src=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-1.png\" alt=\"\" class=\"wp-image-205\" style=\"width:749px;height:auto\" srcset=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-1.png 621w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-1-300x178.png 300w\" sizes=\"auto, (max-width: 621px) 100vw, 621px\" \/><\/figure>\n\n\n\n<p>Use DBMS_AUDIT_MGMT&nbsp; package to manage auditing:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Change Default Audit Tablespace<\/h4>\n\n\n\n<p>Change the tablespace of the UNIFIED_AUDIT_TRAIL view tables with subprogram <strong>set_audit_trail_location <\/strong>accepting two parameters: <strong>audit_trail_type <\/strong>of PLS_INTEGER type and <strong>audit_trail_location_value  <\/strong>of VARCHAR2 type. An example follows that makes UNIFIED_AUDIT_TRAIL tables use AUDIT_TBS tablespace:<\/p>\n\n\n\n<p>begin<br>dbms_audit_mgmt.set_audit_trail_location(<br>audit_trail_type =&gt; dbms_audit_mgmt.audit_trail_unified,<br>audit_trail_location_value =&gt; &#8216;AUDIT_TBS&#8217;);<br>end;<br>\/<\/p>\n\n\n\n<p>Other audit_trail_type values are: <br>dbms_audit_mgmt.audit_trail_aud_std and dbms_audit_mgmt.audit_trail_fga_std<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Change partition interval of audit<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">Setup cleanup job<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">exec DBMS_AUDIT_MGMT.SET_LAST_ARCHIVE_TIMESTAMP (AUDIT_TRAIL_TYPE =&gt; DBMS_AUDIT_MGMT.AUDIT_TRAIL_UNIFIED,LAST_ARCHIVE_TIME =&gt; sysdate-7)<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">See enabled policies<\/h4>\n\n\n\n<p>There are two default policies enabled by Oracle:ORA_SECURECONFIG and ORA_LOGON_FAILURES:<\/p>\n\n\n\n<p>select * from audit_enabled_policies;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"99\" src=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-3-1024x99.png\" alt=\"\" class=\"wp-image-212\" srcset=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-3-1024x99.png 1024w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-3-300x29.png 300w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-3-768x74.png 768w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-3.png 1148w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Action audited from these policies:<\/p>\n\n\n\n<p>SELECT policy_name,  audit_option,  condition_eval_opt,audit_condition  FROM   audit_unified_policies<br>WHERE  policy_name in (&#8216;ORA_SECURECONFIG&#8217;,&#8217;ORA_LOGON_FAILURES&#8217;)<br>order by 1 ,2;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"684\" src=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-5-1024x684.png\" alt=\"\" class=\"wp-image-215\" srcset=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-5-1024x684.png 1024w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-5-300x200.png 300w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-5-768x513.png 768w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-5.png 1118w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Create Audit Policy<\/h4>\n\n\n\n<p>Let&#8217;s create a policy for example let&#8217;s log all password changes in all containers:<\/p>\n\n\n\n<p>In root:<br>CREATE AUDIT POLICY POLICY_PASSWORD_CHANGE ACTIONS CHANGE PASSWORD CONTAINER=ALL;<br>And enable it with:<br>AUDIT POLICY_PASSWORD_CHANGE;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"131\" src=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-7-1024x131.png\" alt=\"\" class=\"wp-image-220\" srcset=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-7-1024x131.png 1024w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-7-300x38.png 300w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-7-768x99.png 768w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-7.png 1029w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"101\" src=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-6-1024x101.png\" alt=\"\" class=\"wp-image-219\" srcset=\"http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-6-1024x101.png 1024w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-6-300x30.png 300w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-6-768x76.png 768w, http:\/\/130.61.57.200\/wp-content\/uploads\/2024\/04\/image-6.png 1159w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Disable policy with:<br>NOAUDIT POLICY_PASSWORD_CHANGE;<\/p>\n\n\n\n<p>Drop it with:<br>DROP AUDIT POLICY POLICY_PASSWORD_CHANGE;<br>You cannot drop an enabled audit policy; you must disable it first.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Enable Unified Auditing To enable Unified Auditing (being available since 12c) stop instance and listener and relink auditing library: Check current value:SELECT value FROM v$option WHERE parameter = &#8216;Unified Auditing&#8217;;Let&#8217;s assume it is FALSE.Stop instance. Go to library directory and relink:cd $ORACLE_HOME\/rdbms\/libmake -f ins_rdbms.mk unaiaud_on ioracle Start the instance Check the value again.Now it should [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":106,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[66],"class_list":["post-199","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oracle","tag-audit"],"blocksy_meta":[],"_links":{"self":[{"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/posts\/199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/comments?post=199"}],"version-history":[{"count":15,"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/posts\/199\/revisions"}],"predecessor-version":[{"id":223,"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/posts\/199\/revisions\/223"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/media\/106"}],"wp:attachment":[{"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/media?parent=199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/categories?post=199"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/130.61.57.200\/index.php\/wp-json\/wp\/v2\/tags?post=199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}