Use SQL to set up sensitive data classification¶
다음 섹션에서는 SQL을 사용하여 데이터베이스 내에서 민감한 데이터의 자동 분류를 설정하는 방법에 대해 설명합니다. 웹 인터페이스를 사용하여 민감한 데이터 분류를 설정하려면 Trust Center를 사용하여 민감한 데이터 분류 설정하기 섹션을 참조하세요.
The basic workflow for using SQL to classify sensitive data consists of the following steps:
Create a classification profile that controls what happens during sensitive data classification.
Set the classification profile on a database or schema to automatically classify tables in the entity.
이 워크플로의 전체 예제는 예 섹션을 참조하십시오.
분류 프로필 정보¶
A classification profile defines the criteria that are used to automatically classify tables in a database. This criteria includes:
테이블을 자동으로 분류하기 전에 테이블이 존재해야 하는 기간입니다.
이전에 분류된 테이블을 재분류해야 하는 기간입니다.
분류 후 시스템 및 사용자 정의 태그를 열에 자동으로 설정할지 여부입니다. 추천 태그를 자동으로 적용할지, 아니면 제안된 태그 할당을 검토한 후 직접 적용할지 결정할 수 있습니다.
시스템 분류 태그와 사용자 정의 오브젝트 태그 간의 매핑 을 통해 사용자 정의 태그를 자동으로 적용할 수 있습니다.
데이터를 분류하는 데 :doc:`사용자 지정 분류기</user-guide/classify-custom>`를 사용할지 여부입니다.
When a data engineer assigns the classification profile to a database, sensitive data in the tables that belong to the database is automatically classified on the schedule defined by the profile. A data engineer can assign the same classification profile to multiple databases, or create multiple classification profiles to set different classification criteria for different databases.
To use SQL to create a classification profile, run the CREATE CLASSIFICATION_PROFILE command to create an instance of the CLASSIFICATION_PROFILE class.
For an example of using the CREATE CLASSIFICATION_PROFILE command to create a classification profile, see 예.
태그 매핑 정보¶
You can use the classification profile to map SEMANTIC_CATEGORY system tags to one or more object tags. With this tag mapping, a column with sensitive data can be automatically assigned a user-defined tag based on its classification. The tag map can be added while creating the classification profile or later by calling the <classification_profile_name>!SET_TAG_MAP method.
Regardless of whether you are defining the tag map while creating the classification profile or after, the contents of the map are specified
as a JSON object. This JSON object contains the 'column_tag_map' key, which is an array of objects that specify a user-defined tag,
the string value of that tag, and the semantic categories to which the tag is being mapped.
다음은 태그 매핑의 예입니다.
'tag_map': {
'column_tag_map': [
{
'tag_name':'tag_db.sch.pii',
'tag_value':'Highly Confidential',
'semantic_categories':[
'NAME',
'NATIONAL_IDENTIFIER'
]
},
{
'tag_name': 'tag_db.sch.pii',
'tag_value':'Confidential',
'semantic_categories': [
'EMAIL'
]
}
]
}
이 매핑을 기반으로 이메일 주소 열이 있고 분류 프로세스에서 해당 열에 이러한 주소가 포함되어 있다고 판단되면 이메일 주소가 포함된 열에 tag_db.sch.pii = 'Confidential' 태그가 설정됩니다.
여러 개의 JSON 오브젝트가 태그 맵에 포함되어 있고, 태그, 태그 값, 범주 값을 매핑하는 경우, JSON 오브젝트의 순서에 따라 충돌이 발생할 때 열에 설정할 태그와 값이 결정됩니다. JSON 오브젝트를 왼쪽에서 오른쪽으로, JSON 형식으로 지정하는 경우 위에서 아래로 원하는 할당 순서대로 지정합니다.
팁
column_tag_map 필드의 각 오브젝트에는 1개의 필수 키(tag_name)만 있습니다. tag_value 및 semantic_categories 키를 생략하면 SEMANTIC_CATEGORY 시스템 태그가 적용되는 모든 열에 사용자 정의 태그가 적용되며, 사용자 정의 태그의 값은 지정된 열의 SEMANTIC_CATEGORY 태그 값과 일치합니다.
If there is a conflict with a manually assigned tag and a tag applied by automatic classification, an error occurs. For information about tracking these errors, see 민감한 데이터 분류 문제 해결하기.
데이터베이스에 분류 프로필 설정¶
Implement sensitive data classification by setting a classification profile on a database. After you set the classification profile on the database, all tables and views within that database are automatically monitored by sensitive data classification.
스키마에도 분류를 설정할 수 있습니다. 분류 프로필에도 연결된 데이터베이스 내에 존재하는 스키마에 분류 프로필을 설정하면, 스키마에 설정된 프로필이 데이터베이스에 설정된 프로필을 재정의합니다.
To set a classification profile, use an ALTER DATABASE or ALTER SCHEMA command to set
the CLASSIFICATION_PROFILE parameter. For example, to set a classification profile my_profile so all tables and views in the my_db
database are monitored by sensitive data classification, run the following command:
ALTER DATABASE my_db
SET CLASSIFICATION_PROFILE = 'governance_db.classify_sch.my_profile';
액세스 제어¶
Here are the privileges and roles that let you work with classification profiles and enable sensitive data classification.
작업 |
필수 권한/역할 |
참고 |
|---|---|---|
분류 프로필 만들기 |
SNOWFLAKE.CLASSIFICATION_ADMIN 데이터베이스 역할 |
이 데이터베이스 역할을 다른 역할에 부여하는 방법에 대한 자세한 내용은 SNOWFLAKE 데이터베이스 역할 사용하기 섹션을 참조하십시오. |
스키마에 대한 CREATE SNOWFLAKE.DATA_PRIVACY.CLASSIFICATION_PROFILE |
이 권한은 분류 프로필 인스턴스를 생성할 스키마에 필요합니다. |
|
데이터베이스 및 스키마에 대한 USAGE |
분류 프로필 인스턴스를 생성할 스키마에 권한이 필요합니다. |
|
데이터베이스 및 스키마에 분류 프로필 설정하기 |
다음 중 하나:
|
기본적으로 데이터베이스 및 스키마의 소유자에게는 해당 EXECUTE AUTO CLASSIFICATION 권한이 있습니다. |
스키마의 데이터베이스에 대한 모든 권한 |
스키마에 분류 프로필을 설정하는 경우 해당 스키마가 포함된 데이터베이스에 대해 하나 이상의 권한이 필요합니다. |
|
데이터베이스 및 스키마에 대한 모든 권한 |
자동으로 분류할 테이블이 포함된 데이터베이스 및 스키마에 대해 하나 이상의 권한이 필요합니다. EXECUTE AUTO CLASSIFICATION 권한이 이 요구 사항을 충족합니다. |
|
다음 중 하나:
|
PRIVACY_USER 인스턴스 역할을 다른 역할에 부여하는 방법에 대한 자세한 내용은 인스턴스 역할 섹션을 참조하십시오. |
|
계정에 대한 APPLY TAG |
||
분류 프로필 인스턴스에서 메서드 를 호출합니다 |
<classification_profile>!PRIVACY_USER 인스턴스 역할 |
이 인스턴스 역할을 다른 역할에 부여하는 방법에 대한 자세한 내용은 인스턴스 역할 섹션을 참조하십시오. |
분류 프로필 나열 |
<classification_profile>!PRIVACY_USER 인스턴스 역할 |
|
분류 프로필 삭제 |
분류 프로필 인스턴스에 대한 OWNERSHIP |
데이터 엔지니어 역할에 이러한 권한과 데이터베이스 역할을 부여하는 예제는 기본 예제: 데이터베이스에서 테이블 자동 분류 섹션을 참조하십시오.
예¶
기본 예제: 데이터베이스에서 테이블 자동 분류¶
데이터베이스에서 테이블을 자동으로 분류하려면 다음 단계를 완료합니다.
관리자 역할로 데이터 엔지니어에게 데이터베이스의 테이블을 자동으로 분류하는 데 필요한 :ref:`역할과 권한<label-classify_auto_access_control>`을 부여합니다.
USE ROLE ACCOUNTADMIN; GRANT USAGE ON DATABASE mydb TO ROLE data_engineer; GRANT EXECUTE AUTO CLASSIFICATION ON DATABASE mydb TO ROLE data_engineer; GRANT DATABASE ROLE SNOWFLAKE.CLASSIFICATION_ADMIN TO ROLE data_engineer; GRANT CREATE SNOWFLAKE.DATA_PRIVACY.CLASSIFICATION_PROFILE ON SCHEMA mydb.sch TO ROLE data_engineer; GRANT APPLY TAG ON ACCOUNT TO ROLE data_engineer;
데이터 엔지니어 역할로 전환합니다.
USE ROLE data_engineer;
분류 프로필 을 CLASSIFICATION_PROFILE 클래스의 인스턴스로 생성합니다.
CREATE OR REPLACE SNOWFLAKE.DATA_PRIVACY.CLASSIFICATION_PROFILE my_classification_profile( { 'minimum_object_age_for_classification_days': 0, 'maximum_classification_validity_days': 30, 'auto_tag': true, 'classify_views': true });
인스턴스에서 DESCRIBE 메서드를 호출하여 속성을 확인합니다.
SELECT my_classification_profile!DESCRIBE();
스키마에 분류 프로필 인스턴스를 설정하면 스키마에서 테이블을 모니터링하고 민감한 데이터를 자동으로 분류하는 백그라운드 프로세스가 시작됩니다.
ALTER DATABASE mydb SET CLASSIFICATION_PROFILE = 'mydb.sch.my_classification_profile';
참고
스키마에 분류 프로필을 설정한 후 Snowflake가 스키마 분류를 시작하기까지 1시간 정도의 지연이 있습니다.
1시간 정도 기다린 후 SYSTEM$GET_CLASSIFICATION_RESULT 저장 프로시저를 호출하여 자동 분류 결과를 확인합니다.
CALL SYSTEM$GET_CLASSIFICATION_RESULT('mydb.sch.t1');
예제: 태그 매핑 및 사용자 지정 분류기 사용하기¶
관리자 역할로 데이터 엔지니어에게 데이터베이스의 테이블을 자동으로 분류하고 열에 태그를 설정하는 데 필요한 :ref:`역할과 권한<label-classify_auto_access_control>`을 부여합니다.
분류 프로필을 만듭니다.
CREATE OR REPLACE SNOWFLAKE.DATA_PRIVACY.CLASSIFICATION_PROFILE my_classification_profile( { 'minimum_object_age_for_classification_days': 0, 'maximum_classification_validity_days': 30, 'auto_tag': true, 'classify_views': true });
인스턴스에서 SET_TAG_MAP 메서드를 호출하여 태그 매핑 을 분류 프로필에 추가합니다. 이렇게 하면 민감한 데이터가 포함된 열에 사용자 지정 태그를 자동으로 적용할 수 있습니다.
CALL my_classification_profile!SET_TAG_MAP( {'column_tag_map':[ { 'tag_name':'my_db.sch1.pii', 'tag_value':'sensitive', 'semantic_categories':['NAME'] }]});
또는 분류 프로필을 만들 때 이 태그 매핑을 추가할 수도 있습니다.
SET_CUSTOM_CLASSIFIERS 메서드를 호출하여 사용자 정의 분류기 를 분류 프로필에 추가합니다. 이를 통해 민감한 데이터를 사용자가 정의한 의미 체계 및 개인정보 보호 범주로 자동 분류할 수 있습니다.
CALL my_classification_profile!set_custom_classifiers( { 'medical_codes': medical_codes!list(), 'finance_codes': finance_codes!list() });
또는 분류 프로필을 만들 때 사용자 지정 분류자를 추가할 수도 있습니다.
인스턴스에서 DESCRIBE 메서드를 호출하여 태그 매핑과 사용자 정의 분류기가 분류 프로필에 추가되었는지 확인합니다.
SELECT my_classification_profile!DESCRIBE();
데이터베이스에서 분류 프로필 인스턴스를 설정합니다.
ALTER DATABASE mydb SET CLASSIFICATION_PROFILE = 'mydb.sch.my_classification_profile';
tag_db.sch.pii태그에 마스킹 정책을 첨부하여 태그 기반 마스킹을 사용하도록 설정합니다.ALTER TAG tag_db.sch.pii SET MASKING POLICY pii_mask;
예제: 자동 분류를 활성화하기 전에 분류 프로필 테스트하기¶
관리자로 데이터 엔지니어에게 스키마의 테이블을 자동으로 분류하고 열에 태그를 설정하는 데 필요한 역할과 권한 을 부여하십시오.
태그 매핑과 사용자 지정 분류기로 분류 프로필을 만듭니다.
CREATE OR REPLACE SNOWFLAKE.DATA_PRIVACY.CLASSIFICATION_PROFILE my_classification_profile( { 'minimum_object_age_for_classification_days':0, 'auto_tag':true, 'tag_map': { 'column_tag_map':[ { 'tag_name':'tag_db.sch.pii', 'tag_value':'highly sensitive', 'semantic_categories':['NAME','NATIONAL_IDENTIFIER'] }, { 'tag_name':'tag_db.sch.pii', 'tag_value':'sensitive', 'semantic_categories':['EMAIL','MEDICAL_CODE'] } ] }, 'classify_views': true 'custom_classifiers': { 'medical_codes': medical_codes!list(), 'finance_codes': finance_codes!list() } } );
자동 분류를 활성화하기 전에 SYSTEM$CLASSIFY 저장 프로시저를 호출하여
table1테이블의 태그 매핑을 테스트하십시오.CALL SYSTEM$CLASSIFY( 'db.sch.table1', 'db.sch.my_classification_profile' );
출력의
tags키에는 태그 설정 여부(설정된 경우true, 그렇지 않은 경우false), 설정된 태그의 이름 및 태그 값에 대한 세부 정보가 포함되어 있습니다.{ "classification_profile_config": { "classification_profile_name": "db.schema.my_classification_profile" }, "classification_result": { "EMAIL": { "alternates": [], "recommendation": { "confidence": "HIGH", "coverage": 1, "details": [], "privacy_category": "IDENTIFIER", "semantic_category": "EMAIL", "tags": [ { "tag_applied": true, "tag_name": "snowflake.core.semantic_category", "tag_value": "EMAIL" }, { "tag_applied": true, "tag_name": "snowflake.core.privacy_category", "tag_value": "IDENTIFIER" }, { "tag_applied": true, "tag_name": "tag_db.sch.pii", "tag_value": "sensitive" } ] }, "valid_value_ratio": 1 }, "FIRST_NAME": { "alternates": [], "recommendation": { "confidence": "HIGH", "coverage": 1, "details": [], "privacy_category": "IDENTIFIER", "semantic_category": "NAME", "tags": [ { "tag_applied": true, "tag_name": "snowflake.core.semantic_category", "tag_value": "NAME" }, { "tag_applied": true, "tag_name": "snowflake.core.privacy_category", "tag_value": "IDENTIFIER" }, { "tag_applied": true, "tag_name": "tag_db.sch.pii", "tag_value": "highly sensitive" } ] }, "valid_value_ratio": 1 } } }
분류 프로필을 기준으로 한 자동 분류가 원하는 결과를 가져오는지 확인한 후 데이터베이스에 분류 프로필 인스턴스를 설정합니다.
ALTER DATABASE mydb SET CLASSIFICATION_PROFILE = 'mydb.sch.my_classification_profile';