编辑手记:对于敏感数据的适当屏蔽一直是数据安全中一个重要的部分,在SQLServer 2016上推出了动态数据屏蔽的新特性,使得开发人员或者数据库管理员能够控制敏感数据的暴露程度,并且在数据库层面生成数据,大大简化了数据库应用层的安全设计和编码。 Microsoft has introduced an impressive new feature in SQL Server 2016 called Dynamic Data Masking (DDM). Dynamic Data Masking allows a developer or administrator to decide how much of the sensitive data to reveal with minimal impact on the application layer. This feature also helps to simplify the design and coding of security in your application by ** the data at the database level. 在SQL Server 2016上推出了一个很强的新特性叫做Dynamic Data Masking (DDM)-动态数据屏蔽,为了尽可能少的对应用层造成影响,该特性允许开发人员或者数据库管理员能够控制敏感数据的暴露程度,并且在数据库层面生成数据,大大简化了数据库应用层的安全设计和编码。 Dynamic Data Masking does not modify or change the actual data stored in a table; it appliesthe masking functions on the table’s column at the time of returning a data as the result of a query. Dynamic Data Masking supports four data masking functions, as listed below, using which you can mask the data at the database level:
动态数据屏蔽并不会真正改动表中存储的实际数据,只是在查询的时候应用该特性控制查询返回的数据,动态数据屏蔽支持四种数据屏蔽函数,可以通过以下四个函数在数据库层面进行屏蔽: 1、默认屏蔽 2、随机屏蔽 3、自定义屏蔽 4、邮件屏蔽
接下来我们将介绍四种屏蔽函数。 1、Default默认函数 The default function of Dynamic Data Masking masksdata on the basis of the column's data type. 默认屏蔽函数是针对基本类型的数据列进行屏蔽的。
An example of the Default Dynamic Data Masking function is shown below. 以下是使用默认屏蔽函数的一个案例。 In this whole article, we will use the sametable, so let's create this table. Thebelow script will create a table named DDM_Student_Sample. While creating thetable, we will apply the default DDM function on the Student_DOB column. The actual data of the Student_DOB column will not be visible to the user who has read permission. Instead of the actual data, SQL Server will return data in the 1900-01-01 00.00.00.000 format. 首先我们来创建一张表,命名为“DDM_Student_Sample”,在创建的时候,我们在Student_DOB列上应用以下默认屏蔽函数,此时Student_DOB列上的真实数据将不能被正常访问,哪怕用户具有读取表的权限,当数据被访问到的时候,将会返回1900-01-01 00.00.00.000格式的数据。 After table creation, we need to insert some data into table to check how the Default DDM function works. So we will use below query to insert four rows into the table. 创建完成以后,我们需要插入一些数据来验证默认屏蔽函数的作用。使用以下语句在表中插入四行数据。 After inserting the data we will use the below script to check an actual data stored in the table- DDM_Student_Sample. ( here we are using the user credentials who is having full access or adequate permission which require to check an actual data of the table and those users only will be able to see the sensitive information like as shown in above figure.) 插入数据以后,我们将采用以下脚本检查表中的真实数据。我们使用具有足够权限的高级用户来做查询,这类用户能够查看真实数据,只是在返回的时候会提示敏感信息。
Now we will create a user and grant read permission on DDM_Student_Sample table using below script: 现在我们创建一个用户 ,使用以下语句对其授DDM_Student_Sample表的读取权。
As we have applied Default DDM function on column Student_DOB, so lets check how the data will appear when user having read permission on a table using below script. 在这张表的Student_DOB列我们已经应用了默认屏蔽函数,接下来我们看在查询到的时候数据会如何返回。
On above output we can see that user DDM_Read is not able to see the actual data for the Student_DOB column because we have applied the Default Dynamic Data Masking function on this column. Hence, data of column Student_DOB showing in the 1900-01-01 00.00.00.000 format. 在上面的结果中我们看到,用户虽然具有访问表的权限,但并不能读取到真实的数据,因为应用了默认屏蔽函数,所以该列最终返回1900-01-01 00.00.00.000。 If you want to allow a few users who have less privileges, like the user, DDM_Read, then grant the UNMASK permission for this set of users: 如果你想用权限更低的用户,比如DDM_Read,然后我们对这类用户授非屏蔽权限。
after granting UNMASK permission to the user, DDM_Read, they will be able to see the actual data, like shown in the below figure. 授权非屏蔽之后,就能看到真实的数据,如下所示: Use the below script to revoke the UNMASK permission of user, DDM_Read. 回收刚才的DDM_Read用户的非屏蔽权限
2、随机屏蔽函数 This DDM function is applied on numeric data types only. It displays a random value for the specified range. In the below example we will apply the Random function on the Student_ID column. 随机屏蔽函数只对数字类型起作用。它会将某一个范围内的值随机显示。在下面的案例中,我们在Student_ID列上应用了随机屏蔽函数。
After applying the Random function, when we try to check the data of table using the DDM_Read user (user with read permission only), the data of the table will look like shown in below figure: 应用完随机屏蔽函数之后,我们通过DDM_Read用户访问表的数据,结果如下所示: In the above figure, we can see that actual values for Student_ID are replaced with some random numeric values. Again, if you want to allow less privileged user to check the actual data of the table, then grant the UNMASK permission. 在上面的表中,我们看到Student_ID列的真实数据被随机的数值代替,同样,如果你想尝试用权限低一点的用户,可以授非屏蔽权限。 3、Custom String 自定义屏蔽 This DDM function uses the below syntax to mask the data: 自定义屏蔽函数使用以下语法进行屏蔽数据。 Syntax : Partial(prefix,[padding],suffix) 语法:Partial(prefix,[padding],suffix)
We will apply the Custom String DDM function on Student_Name column with the below values : 在我们的案例中,将会用以下值对表的数据做自定义屏蔽。
|
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|