當前位置:九游会j9娱乐平台-九游ag登录中心网址 » 編程語言 » 審計sql

審計sql-九游会j9娱乐平台

發布時間: 2024-07-12 21:35:42

sql server在審計工作中的應用

1、熟悉該單位所使用的財務軟體的資料庫結構,例如:金蝶、瞎滲用友等
2、本身具備強大的sql語句功底,可以使用sql語句對其仔槐財務表內的數據進行匯總統計

3、依據財務常識與審計中對各個財務科目的數據進行比對,發現其中問念神友題,然後再追朔其具體帳目的單據
4、不同種類的企業,在其財務流中,均會不同程度存在違法違紀問題,只要在審計過程中仔細認真核對其數據即可,另外,也要對其數據與財務憑證做細致對比

願你成功!

㈡ 如何開啟sqlserver2008資料庫審計功能

sqlserver2008新增的審核功能
在sqlserver2008新增了審核功能,可以對伺服器級別和資料庫級別的操作進行審核/審計,事實上,事件通知、更改跟蹤、變更數據捕獲(cdc)
都不是用來做審計的,只是某些人亂用這些功能,也正因為亂用這些功能導致踩坑
事件通知:性能跟蹤
更改跟蹤:用sync services來構建偶爾連接的系統
變更數據捕獲(cdc):數據倉庫的etl 中的數據抽取(背後使用logreader)

而審核是sqlserver專門針對資料庫安全的進行的審核,記住,他是專門的!

我們看一下審核的使用方法
審核對象
步驟一:創建審核對象,審核對象是跟保存路徑關聯的,所以如果你需要把審核操作日誌保存到不同的路徑就需要創建不同的審核對象
我們把審核操作日誌保存在文件系統里,在創建之前我們還要在相關路徑先創建好保存的文件夾,我們在d盤先創建sqlaudits文件夾,然後執行下面語句
--創建審核對象之前需要切換到master資料庫
use [master]
go
create server audit myfileaudit to file(filepath='d:\sqlaudits') --這里指定文件夾不能指定文件,生成文件都會保存在這個文件夾
go

實際上,我們在創建審核對象的同時可以指定審核選項,下面是相關腳本
把日誌放在磁碟的好處是可以使用新增的tvf:sys.[fn_get_audit_file] 來過濾和排序審核數據,如果把審核數據保存在windows 事件日誌里查詢起來非常麻煩
use [master]
go
create server audit myfileaudit to file(
filepath='d:\sqlaudits',
maxsize=4gb,
max_rollover_files=6)
with (
on_failure=continue,
queue_delay=1000);

alter server audit myfileaudit with(state =on)

maxsize:指明每個審核日誌文件的最大大小是4gb
max_rollover_files:指明滾動文件數目,類似於sql errorlog,達到多少個文件之後刪除前面的歷史文件,這里是6個文件
on_failure:指明當審核數據發生錯誤時的操作,這里是繼續進行審核,如果指定shutdown,那麼將會shutdown整個實例
queue_delay:指明審核數據寫入的延遲時間,這里是1秒,最小值也是1秒,如果指定0表示是實時寫入,當然性能也有一些影響
state:指明啟動審核功能,state這個選項不能跟其他選項共用,所以只能單獨一句

在修改審核選項的時候,需要先禁用審核,再開啟審核
alter server audit myfileaudit with(state =off)
alter server audit myfileaudit with(queue_delay =1000)
alter server audit myfileaudit with(state =on)

審核規范
在sqlserver審核裡面有審核規范的概念,一個審核對象只能綁定一個審核規范,而一個審核規范可以綁定到多個審核對象
我們來看一下腳本
create server audit specification captureloginstofile
for server audit myfileaudit
add (failed_login_group),
add (successful_login_group)
with (state=on)
go

create server audit myappaudit to application_log
go
alter server audit myappaudit with(state =on)
alter server audit specification captureloginstofile with (state=off)
go
alter server audit specification captureloginstofile
for server audit myappaudit
add (failed_login_group),
add (successful_login_group)
with (state=on)
go

我們創建一個伺服器級別的審核規范captureloginstofile,然後再創建多一個審核對象myappaudit ,這個審核對象會把審核日誌保存到windows事件日誌的應用程序日誌里
我們禁用審核規范captureloginstofile,修改審核規范captureloginstofile屬於審核對象myappaudit ,修改成功

而如果要把多個審核規范綁定到同一個審核對象則會報錯
create server audit specification captureloginstofilea
for server audit myfileaudit
add (failed_login_group),
add (successful_login_group)
with (state=on)
go

create server audit specification captureloginstofileb
for server audit myfileaudit
add (failed_login_group),
add (successful_login_group)
with (state=on)
go

--消息 33230,級別 16,狀態 1,第 86 行
--審核 'myfileaudit' 的審核規范已經存在。

這里要說一下 :審核對象和審核規范的修改 ,無論是審核對象還是審核規范,在修改他們的相關參數之前,他必須要先禁用,後修改,再啟用
--禁用審核對象
alter server audit myfileaudit with(state =off)
--禁用伺服器級審核規范
alter server audit specification captureloginstofile with (state=off)
go
--禁用資料庫級審核規范
alter database audit specification capturedbloginstofile with (state=off)
go

--相關修改選項操作

--啟用審核對象
alter server audit myfileaudit with(state =on)
--啟用伺服器級審核規范
alter server audit specification captureloginstofile with (state=on)
go
--啟用資料庫級審核規范
alter database audit specification capturedbloginstofile with (state=on)
go

審核伺服器級別事件
審核服務級別事件,我們一般用得最多的就是審核登錄失敗的事件,下面的腳本就是審核登錄成功事件和登錄失敗事件
create server audit specification captureloginstofile
for server audit myfileaudit
add (failed_login_group),
add (successful_login_group)
with (state=on)
go

修改審核規范
--跟審核對象一樣,更改審核規范時必須將其禁用
alter server audit specification captureloginstofile with (state =off)
alter server audit specification captureloginstofile
add (login_change_password_gourp),
drop (successful_login_group)
alter server audit specification captureloginstofile with (state =on)
go

審核操作組
每個審核操作組對應一種操作,在sqlserver2008里一共有35個操作組,包括備份和還原操作,資料庫所有權的更改,從伺服器和資料庫角色中添加或刪除登錄用戶
添加審核操作組的只需在審核規范里使用add,下面語句添加了登錄用戶修改密碼操作的操作組
add (login_change_password_gourp)

這里說一下伺服器審核的內部實際上使用的是sql2008新增的擴展事件裡面的其中一個package:secaudit package,當然他內部也是使用擴展事件來收集伺服器信息

審核資料庫級別事件
資料庫審核規范存在於他們的資料庫中,不能審核tempdb中的資料庫操作
create database audit specification和alter database audit specification
工作方式跟伺服器審核規范一樣
在sqlserver2008里一共有15個資料庫級別的操作組
7個資料庫級別的審核操作是:select ,insert,update,delete,execute,receive,references

相關腳本如下:
--創建審核對象
use [master]
go
create server audit mydbfileaudit to file(filepath='d:\sqldbaudits')
go
alter server audit mydbfileaudit with (state=on)
go
--創建資料庫級別審核規范
use [sss]
go
create database audit specification capturedbactiontoeventlog
for server audit mydbfileaudit
add (database_object_change_group),
add (select ,insert,update,delete on schema::dbo by public)
with (state =on)

我們先在d盤創建sqldbaudits文件夾
第一個操作組對資料庫中所有對象的ddl語句create,alter,drop等進行記錄
第二個語句監視由任何public用戶(也就是所有用戶)對dbo架構的任何對象所做的dml操作

創建完畢之後可以在ssms里看到相關的審核

熱點內容
matlab命令窗口和新建腳本 發布:2024-07-17 15:51:26 瀏覽:374
建ftp文件夾 發布:2024-07-17 15:51:26 瀏覽:954
魔獸撿物腳本 發布:2024-07-17 15:27:56 瀏覽:129
開發ip伺服器 發布:2024-07-17 15:24:42 瀏覽:387
安卓系統視頻製作哪個好用 發布:2024-07-17 15:10:47 瀏覽:210
androidapk結構 發布:2024-07-17 15:10:43 瀏覽:945
c語言指針的例子 發布:2024-07-17 15:08:01 瀏覽:768
linuxzcat 發布:2024-07-17 15:02:09 瀏覽:901
賓士編程嗎 發布:2024-07-17 14:57:08 瀏覽:853
硬碟加密硬體 發布:2024-07-17 14:51:05 瀏覽:836
网站地图