표 형식 데이터 익명화 예시

Sensitive Data Protection은 구조화된 데이터 내에서 민감한 정보를 감지, 분류, 익명화할 수 있습니다. 콘텐츠를 테이블을 익명화할 때 구조 및 열은 Sensitive Data Protection에 일부 사용 사례에 더 나은 결과를 제공하는 데 사용할 수 있는 추가 정보를 제공합니다. 예를 들어 전체 테이블 구조 대신 단일 열에서 특정 데이터 유형을 스캔할 수 있습니다.

이 주제에서는 구조화된 텍스트 내에서 민감한 정보의 익명화를 구성하는 방법을 예시로 제공합니다. 익명화는 레코드 변환을 통해 사용 설정됩니다. 이러한 변환은 표 형식 텍스트 데이터에서 특정 infoType으로 식별되는 값 또는 표 형식 데이터의 전체 열에 적용됩니다.

이 주제에서는 암호화 해시 방법을 사용하는 표 형식 데이터 변환도 예시로 제공합니다. 암호화 변환 메서드는 암호화 키 요구 사항으로 인해 고유합니다.

다음 예시에서 제공된 JSON은 "deidentifyConfig"(DeidentifyConfig) 속성 내에서 모든 익명화 요청에 삽입할 수 있습니다. 'API 탐색기 예시' 링크를 클릭하여 API 탐색기의 JSON 예시를 사용해 보세요.

검사 없이 열 변환

콘텐츠가 이미 알려진 특정 열을 변환하려면 검사를 건너 뛰고 변환을 직접 지정할 수 있습니다. 표 다음에 나오는 예시에서 버킷은 '행복 점수' 열을 10씩 증가시킵니다.

입력 변환된 테이블
연령 환자 행복 점수
101 찰스 디킨스 95
22 제인 오스틴 21
55 마크 트웨인 75
연령 환자 행복 점수
101 찰스 디킨스 90:100
22 제인 오스틴 20:30
55 마크 트웨인 70:80

C#

Sensitive Data Protection의 클라이언트 라이브러리를 설치하고 사용하는 방법은 Sensitive Data Protection 클라이언트 라이브러리를 참조하세요.

Sensitive Data Protection에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.


using System;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Dlp.V2;

public class DeidentifyUsingTableBucketing
{
    public static Table DeidentifyData(
        string projectId,
        Table tableToInspect = null)
    {
        // Instantiate dlp client.
        var dlp = DlpServiceClient.Create();

        // Construct the table if null.
        if (tableToInspect == null)
        {
            var row1 = new Value[]
            {
                new Value { StringValue = "101" },
                new Value { StringValue = "Charles Dickens" },
                new Value { StringValue = "95" }
            };
            var row2 = new Value[]
            {
                new Value { StringValue = "22" },
                new Value { StringValue = "Jane Austin" },
                new Value { StringValue = "21" }
            };
            var row3 = new Value[]
            {
                new Value { StringValue = "55" },
                new Value { StringValue = "Mark Twain" },
                new Value { StringValue = "75" }
            };

            tableToInspect = new Table
            {
                Headers =
                {
                    new FieldId { Name = "AGE" },
                    new FieldId { Name = "PATIENT" },
                    new FieldId { Name = "HAPPINESS SCORE" }
                },
                Rows =
                {
                    new Table.Types.Row { Values = { row1 } },
                    new Table.Types.Row { Values = { row2 } },
                    new Table.Types.Row { Values = { row3 } }
                }
            };
        }

        // Construct the table content item.
        var contentItem = new ContentItem { Table = tableToInspect };

        // Specify how the content should be de-identified.
        var fixedSizeBucketingConfig = new FixedSizeBucketingConfig
        {
            BucketSize = 10,
            LowerBound = new Value { IntegerValue = 0 },
            UpperBound = new Value { IntegerValue = 100 },
        };

        // Specify the fields to be encrypted.
        var fields = new FieldId[] { new FieldId { Name = "HAPPINESS SCORE" } };

        // Associate the encryption with the specified field.
        var fieldTransformation = new FieldTransformation
        {
            PrimitiveTransformation = new PrimitiveTransformation
            {
                FixedSizeBucketingConfig = fixedSizeBucketingConfig
            },
            Fields = { fields }
        };

        // Construct the deidentify config.
        var deidentifyConfig = new DeidentifyConfig
        {
            RecordTransformations = new RecordTransformations
            {
                FieldTransformations = { fieldTransformation }
            }
        };

        // Construct the request.
        var request = new DeidentifyContentRequest
        {
            ParentAsLocationName = new LocationName(projectId, "global"),
            DeidentifyConfig = deidentifyConfig,
            Item = contentItem,
        };

        // Call the API.
        var response = dlp.DeidentifyContent(request);

        // Inspect the response.
        Console.WriteLine(response.Item.Table);

        return response.Item.Table;
    }
}

Go

민감한 정보 보호의 클라이언트 라이브러리를 설치하고 사용하는 방법은 민감한 정보 보호 클라이언트 라이브러리를 참조하세요.

Sensitive Data Protection에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

import (
	"context"
	"fmt"
	"io"

	dlp "cloud.google.com/go/dlp/apiv2"
	"cloud.google.com/go/dlp/apiv2/dlppb"
)

// deIdentifyTableBucketing de-identifies data using table bucketing
func deIdentifyTableBucketing(w io.Writer, projectID string) error {
	// projectId := "your-project-id"
	// table := "your-table-value"

	row1 := &dlppb.Table_Row{
		Values: []*dlppb.Value{
			{Type: &dlppb.Value_StringValue{StringValue: "22"}},
			{Type: &dlppb.Value_StringValue{StringValue: "Jane Austen"}},
			{Type: &dlppb.Value_StringValue{StringValue: "21"}},
		},
	}

	row2 := &dlppb.Table_Row{
		Values: []*dlppb.Value{
			{Type: &dlppb.Value_StringValue{StringValue: "55"}},
			{Type: &dlppb.Value_StringValue{StringValue: "Mark Twain"}},
			{Type: &dlppb.Value_StringValue{StringValue: "75"}},
		},
	}

	row3 := &dlppb.Table_Row{
		Values: []*dlppb.Value{
			{Type: &dlppb.Value_StringValue{StringValue: "101"}},
			{Type: &dlppb.Value_StringValue{StringValue: "Charles Dickens"}},
			{Type: &dlppb.Value_StringValue{StringValue: "95"}},
		},
	}

	table := &dlppb.Table{
		Headers: []*dlppb.FieldId{
			{Name: "AGE"},
			{Name: "PATIENT"},
			{Name: "HAPPINESS SCORE"},
		},
		Rows: []*dlppb.Table_Row{
			{Values: row1.Values},
			{Values: row2.Values},
			{Values: row3.Values},
		},
	}

	ctx := context.Background()

	// Initialize a client once and reuse it to send multiple requests. Clients
	// are safe to use across goroutines. When the client is no longer needed,
	// call the Close method to cleanup its resources.
	client, err := dlp.NewClient(ctx)
	if err != nil {
		return err
	}

	// Closing the client safely cleans up background resources.
	defer client.Close()

	// Specify what content you want the service to de-identify.
	contentItem := &dlppb.ContentItem{
		DataItem: &dlppb.ContentItem_Table{
			Table: table,
		},
	}

	// Specify how the content should be de-identified.
	fixedSizeBucketingConfig := &dlppb.FixedSizeBucketingConfig{
		BucketSize: 10,
		LowerBound: &dlppb.Value{
			Type: &dlppb.Value_IntegerValue{
				IntegerValue: 0,
			},
		},
		UpperBound: &dlppb.Value{
			Type: &dlppb.Value_IntegerValue{
				IntegerValue: 100,
			},
		},
	}
	primitiveTransformation := &dlppb.PrimitiveTransformation_FixedSizeBucketingConfig{
		FixedSizeBucketingConfig: fixedSizeBucketingConfig,
	}

	// Specify field to be encrypted.