InfoType 及 infoType 偵測工具

Sensitive Data Protection 使用「資訊類型」(「infoType」) 定義其掃描的內容。infoType 是一種機密資料,如姓名、電子郵件地址、電話號碼、身分證號碼、信用卡號等等。infoType 偵測工具是相應的偵測機制,可根據 infoType 的比對條件進行比對。

選取 infoType 的最佳做法

瞭解資料是保護資料的第一步。最佳做法是只蒐集、儲存及處理您業務所需的資訊。識別您處理的資料後,即可為商家、使用者、資料安全和隱私權保護機制做出明智決策。

部分業務用途可能需要特定私密資訊,其他則不需要。沒有單一解決方案可支援所有用途。 因此,Sensitive Data Protection 提供彈性控制選項,可掃描特定類型的資料。如果您使用 infoType 進行去識別化或遮蓋,也可以控管資料轉換的時間和方式。

一般指南

選取 infoType 時,請考量下列一般準則。

使用一般 infoType 取代特定 infoType

如果不需要掃描結果顯示偵測到的特定 infoType,請考慮在檢查設定中使用一般 infoType,而非特定 infoType。如要瞭解在要求中使用一般 infoType 偵測工具的優點,請參閱本頁的「一般和特定 infoType 偵測工具」一節。

如需一般 infoType 的完整清單,以及這些 infoType 包含的特定 infoType,請參閱「一般 infoType」。

您不需要收集的私密資訊

貴商家提供的每項服務都應只收集該服務所需的資料。舉例來說,貴商家中的特定服務不需要收集財務資訊。對於這些服務,建議啟用 infoType 偵測工具,例如 CREDIT_CARD_NUMBERFINANCIAL_ACCOUNT_NUMBER 和產業類別 FINANCE 中的其他 infoType。

您需要收集資訊,但不想與團隊廣泛分享

收集個人資訊可能有正當用途,但您不應廣泛地與團隊分享。舉例來說,提出支援單的顧客可能會提供聯絡資訊,方便您與他們聯絡以解決問題。您不希望團隊中查看工單的所有人看到個人識別資訊 (PII)。建議啟用 infoType 偵測工具,例如 PHONE_NUMBEREMAIL_ADDRESS 和類型類別 PII 中的其他 infoType。

受產業、資料隱私權或管轄區法規規範的敏感資料類別

某些資訊類型因核發方式或用途而屬於私密資訊。在其他情況下,情境和客層資訊則屬於受保護類別。這類資訊的收集、使用和管理方式可能受到額外限制。建議啟用下列類別的 infoType 偵測工具:

選擇類似的 infoType

在類似的 infoType 偵測工具之間選擇時,請考慮下列事項。

護照

如果不需要掃描特定國家/地區的護照 ID,請選擇一般偵測器:PASSPORT

您可以使用特定國家/地區的護照偵測器,例如 UK_PASSPORT。不過,部分國家/地區專用的護照偵測器只能識別特定格式的護照,或含有情境線索的護照。

人名

掃描使用者姓名時,在多數使用案例中,請使用 PERSON_NAME,而非 FIRST_NAMELAST_NAME

PERSON_NAME 是人名偵測工具。包括單字名稱和全名。這項偵測工具會運用各種技術 (包括自然語言解讀),嘗試偵測姓名,例如「Jane」、「Jane Smith」和「Jane Marie Smith」。FIRST_NAMELAST_NAME 是這個偵測器的子集,可嘗試識別名稱的各個部分。這些偵測工具的結果一律是 PERSON_NAME 結果的子集。

日期和時間

如果不需要掃描所有日期,請考慮使用目標日期偵測工具,例如 DATE_OF_BIRTH。這個偵測工具會嘗試找出表示日期與某人出生時間相關的內容。

DATE 偵測器會嘗試找出所有日期,不論前後文為何。此外,這項功能也會標示相對日期,例如「今天」或「昨天」。同樣地,TIME 會嘗試找出所有時間戳記。

位置

如果不需要掃描所有位置,請考慮使用 STREET_ADDRESS,而非 LOCATION 偵測器。STREET_ADDRESS 偵測器會嘗試尋找完整地址,這類地址通常比一般地點更精確,因此可視為較為敏感的資訊。

LOCATION infoType 偵測工具會嘗試尋找任何位置,不論內容為何,例如「巴黎」或「加拿大」

需要情境的 infoType 偵測工具

許多 infoType 偵測器需要情境線索,才能識別相符項目。如果內建 infoType 偵測工具未標記您預期會標記的項目,可能是因為這些項目附近沒有內容相關線索,請考慮改用 GENERIC_ID自訂 infoType 偵測工具

缺乏通用業界定義的資訊類型

部分資訊類型缺乏通用的產業定義。例如病歷號碼、帳號、PIN 碼和安全碼。對於這類模式,建議使用 GENERIC_IDFINANCIAL_ACCOUNT_NUMBERMEDICAL_RECORD_NUMBER 等 infoType。這些偵測工具會結合實體偵測和情境,找出潛在的敏感元素。

延遲時間較長的 infoType 偵測工具

  • 請避免啟用不需要的 infoType 偵測工具。雖然下列資訊類型在特定情境中很有用,但與不含這些資訊類型的要求相比,這些資訊類型可能會導致要求執行速度慢上許多:

    • PERSON_NAME
    • FEMALE_NAME
    • MALE_NAME
    • FIRST_NAME
    • LAST_NAME
    • DATE_OF_BIRTH
    • LOCATION
    • STREET_ADDRESS
    • ORGANIZATION_NAME
  • 請務必明確指定 infoType 偵測工具。請勿使用空白 infoTypes 清單。

如何使用 infoType

Sensitive Data Protection 使用掃描設定中的 infoType 偵測工具,來決定要檢查的內容,以及如何轉換發現事項。顯示或報告掃描結果時,也會使用 InfoType 名稱。

舉例來說,如要在一段文字中尋找電子郵件地址,您可以在檢查設定中指定 EMAIL_ADDRESS infoType 偵測工具。如要從文字區塊中遮蓋電子郵件地址,您可以在檢查設定和去識別化設定中指定 EMAIL_ADDRESS,指明如何遮蓋或轉換該類型。

此外,您也可以結合使用內建和自訂 infoType 偵測工具,從掃描結果中排除部分電子郵件地址。首先,請建立名為 INTERNAL_EMAIL_ADDRESS 的自訂 infoType,並設定排除內部測試電子郵件地址。接著,您可以設定掃描作業,納入 EMAIL_ADDRESS 的結果,但加入排除規則,排除符合 INTERNAL_EMAIL_ADDRESS 的任何結果。如要進一步瞭解排除規則和自訂 infoType 偵測工具的其他功能,請參閱「建立自訂 infoType 偵測工具」一文。

Sensitive Data Protection 提供一組內建 infoType 偵測工具,您可以依名稱指定這些工具,每項工具都會列在 InfoType 偵測工具參考資料中。這些偵測工具會使用各種技術來探索及分類各類型內容。舉例來說,有些類型需要符合模式,有些可能會有數學檢查碼,有些則有特殊數字限制,其他類型可能會有特定前置字元或發現結果的相關背景資訊。

範例

設定機密資料保護功能掃描內容時,請在掃描設定中加入要使用的 infoType 偵測工具。

舉例來說,以下 JSON 和程式碼範例示範傳送至 DLP API 的簡單掃描要求。請注意,PHONE_NUMBER 偵測工具是在 inspectConfig 中指定,用於指示 Sensitive Data Protection 掃描指定字串中的電話號碼。

C#

如要瞭解如何安裝及使用 Sensitive Data Protection 的用戶端程式庫,請參閱這篇文章

如要驗證 Sensitive Data Protection,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


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

public class InspectPhoneNumber
{
    public static InspectContentResponse Inspect(
        string projectId,
        string text,
        Likelihood minLikelihood = Likelihood.Possible)
    {
        // Instantiate a client.
        var dlp = DlpServiceClient.Create();

        // Set content item.
        var contentItem = new ContentItem { Value = text };

        // Construct inspect config.
        var inspectConfig = new InspectConfig
        {
            InfoTypes = { new InfoType { Name = "PHONE_NUMBER" } },
            IncludeQuote = true,
            MinLikelihood = minLikelihood
        };

        // Construct a request.
        var request = new InspectContentRequest
        {
            ParentAsLocationName = new LocationName(projectId, "global"),
            InspectConfig = inspectConfig,
            Item = contentItem,
        };

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

        // Inspect the results.
        var resultFindings = response.Result.Findings;

        Console.WriteLine($"Findings: {resultFindings.Count}");

        foreach (var f in resultFindings)
        {
            Console.WriteLine("\tQuote: " + f.Quote);
            Console.WriteLine("\tInfo type: " + f.InfoType.Name);
            Console.WriteLine("\tLikelihood: " + f.Likelihood);
        }

        return response;
    }
}

Go

如要瞭解如何安裝及使用 Sensitive Data Protection 的用戶端程式庫,請參閱這篇文章

如要驗證 Sensitive Data Protection,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

import (
	"context"
	"fmt"
	"io"

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

// inspectPhoneNumber demonstrates a simple scan request to the Cloud DLP API.
// Notice that the PHONE_NUMBER detector is specified in inspectConfig,
// which instructs Cloud DLP to scan the given string for a phone number.
func inspectPhoneNumber(w io.Writer, projectID, textToInspect string) error {
	// projectID := "my-project-id"
	// textToInspect := "My phone number is (123) 555-6789"

	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()

	// Create and send the request.
	req := &dlppb.InspectContentRequest{
		Parent: fmt.Sprintf("projects/%s/locations/global", projectID),
		Item: &dlppb.ContentItem{
			DataItem: &dlppb.ContentItem_Value{
				Value: textToInspect,
			},
		},
		InspectConfig: &dlppb.InspectConfig{
			// Specify the type of info the inspection will look for.
			// See https://cloud.google.com/dlp/docs/infotypes-reference
			// for complete list of info types
			InfoTypes: []*dlppb.InfoType{
				{Name: "PHONE_NUMBER"},
			},
			IncludeQuote: true,
		},
	}

	// Send the request.
	resp, err := client.InspectContent(ctx, req)
	if err != nil {
		fmt.Fprintf(w, "receive: %v", err)
		return err
	}

	// Process the results.
	result := resp.Result
	fmt.Fprintf(w, "Findings: %d\n", len(result.Findings))
	for _, f := range result.Findings {
		fmt.Fprintf(w, "\tQuote: %s\n", f.Quote)
		fmt.Fprintf(w, "\tInfo type: %s\n", f.InfoType.Name)
		fmt.Fprintf(w, "\tLikelihood: %s\n", f.Likelihood)
	}
	return nil
}

Java

如要瞭解如何安裝及使用 Sensitive Data Protection 的用戶端程式庫,請參閱這篇文章

如要驗證 Sensitive Data Protection,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。


import com.google.cloud.dlp.v2.DlpServiceClient;
import com.google.privacy.dlp.v2.ContentItem;
import com.google.privacy.dlp.v2.Finding;
import com.google.privacy.dlp.v2.InfoType;
import com.google.privacy.dlp.v2.InspectConfig;
import com.google.privacy.dlp.v2.InspectContentRequest;
import com.google.privacy.dlp.v2.InspectContentResponse;
import com.google.privacy.dlp.v2.Likelihood;
import com.google.privacy.dlp.v2.LocationName;
import java.io.IOException;

public class InspectPhoneNumber {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "your-project-id";
    String textToInspect = "My name is Gary and my email is gary@example.com";
    inspectString(projectId, textToInspect);
  }

  // Inspects the provided text.
  public static void inspectString(String projectId, String textToInspect) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (DlpServiceClient dlp = DlpServiceClient.create()) {
      // Specify the type and content to be inspected.
      ContentItem item = ContentItem.newBuilder().setValue(textToInspect).build();

      // Specify the type of info the inspection will look for.
      // See https://cloud.google.com/dlp/docs/infotypes-reference for complete list of info types
      InfoType infoType = InfoType.newBuilder().setName("PHONE_NUMBER").build();

      // Construct the configuration for the Inspect request.
      InspectConfig config =
          InspectConfig.newBuilder()
              .setIncludeQuote(true)
              .setMinLikelihood(Likelihood.POSSIBLE)
              .addInfoTypes(infoType)
              .build();

      // Construct the Inspect request to be sent by the client.
      InspectContentRequest request =
          InspectContentRequest.newBuilder()
              .setParent(LocationName.of(projectId, "global").toString())
              .setItem(item)
              .setInspectConfig(config)
              .build();

      // Use the client to send the API request.
      InspectContentResponse response = dlp.inspectContent(request);

      // Parse the response and process results
      System.out.println("Findings: " + response.getResult().getFindingsCount());
      for (Finding f : response.getResult().getFindingsList()) {
        System.out.println("\tQuote: " + f.getQuote());
        System.out.println("\tInfo type: " + f.getInfoType().getName());
        System.out.println("\tLikelihood: " + f.getLikelihood());
      }
    }
  }
}

Node.js

如要瞭解如何安裝及使用 Sensitive Data Protection 的用戶端程式庫,請參閱這篇文章

如要驗證 Sensitive Data Protection,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

// Imports the Google Cloud Data Loss Prevention library
const DLP = require('@google-cloud/dlp');

// Instantiates a client
const dlp = new DLP.DlpServiceClient();

// The project ID to run the API call under
// const projectId = 'my-project';

// The string to inspect
// const string = 'My email is gary@example.com and my phone number is (223) 456-7890.';

// The minimum likelihood required before returning a match
// const minLikelihood = 'LIKELIHOOD_UNSPECIFIED';

// The maximum number of findings to report per request (0 = server maximum)
// const maxFindings = 0;

// The infoTypes of information to match
// See https://cloud.google.com/dlp/docs/concepts-infotypes for more information
// about supported infoTypes.
// const infoTypes = [{ name: 'PHONE_NUMBER' }];

// The customInfoTypes of information to match
// const customInfoTypes = [{ infoType: { name: 'DICT_TYPE' }, dictionary: { wordList: { words: ['foo', 'bar', 'baz']}}},
//   { infoType: { name: 'REGEX_TYPE' }, regex: {pattern: '\\(\\d{3}\\) \\d{3}-\\d{4}'}}];

// Whether to include the matching string
// const includeQuote = true;

async function inspectPhoneNumber() {
  // Construct item to inspect
  const item = {value: string};

  // Construct request
  const request = {
    parent: `projects/${projectId}/locations/global`,
    inspectConfig: {
      infoTypes: infoTypes,
      customInfoTypes: customInfoTypes,
      minLikelihood: minLikelihood,
      includeQuote: includeQuote,
      limits: {
        maxFindingsPerRequest: maxFindings,
      },
    },
    item: item,
  };

  // Run request
  const [response] = await dlp.inspectContent(request);
  const findings = response.result.findings;
  if (findings.length > 0) {
    console.log('Findings:');
    findings.forEach(finding => {
      if (includeQuote) {
        console.log(`\tQuote: ${finding.quote}`);
      }
      console.log(`\tInfo type: ${finding.infoType.name}`);
      console.log(`\tLikelihood: ${finding.likelihood}`);
    });
  } else {
    console.log('No findings.');
  }
}
inspectPhoneNumber();

PHP

如要瞭解如何安裝及使用 Sensitive Data Protection 的用戶端程式庫,請參閱這篇文章

如要驗證 Sensitive Data Protection,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

use Google\Cloud\Dlp\V2\Client\DlpServiceClient;
use Google\Cloud\Dlp\V2\ContentItem;
use Google\Cloud\Dlp\V2\InfoType;
use Google\Cloud\Dlp\V2\InspectConfig;
use Google\Cloud\Dlp\V2\InspectContentRequest;
use Google\Cloud\Dlp\V2\Likelihood;

/**
 * Inspect data for phone numbers
 * Demonstrates a simple scan request to the Cloud DLP API. Notice that the PHONE_NUMBER detector is specified in inspectConfig, which instructs Cloud DLP to scan the given string for a phone number.
 *
 * @param string $projectId         The Google Cloud project id to use as a parent resource.
 * @param string $textToInspect     The string to inspect.
 */
function inspect_phone_number(
    // TODO(developer): Replace sample parameters before running the code.
    string $projectId,
    string $textToInspect = 'My name is Gary and my phone number is (415) 555-0890'
): void {
    // Instantiate a client.
    $dlp = new DlpServiceClient();

    $parent = "projects/$projectId/locations/global";

    // Specify what content you want the service to Inspect.
    $item = (new ContentItem())
        ->setValue($textToInspect);

    $inspectConfig = (new InspectConfig())
        // The infoTypes of information to match
        ->setInfoTypes([
            (new InfoType())->setName('PHONE_NUMBER'),
        ])
        // Whether to include the matching string
        ->setIncludeQuote(true)
        ->setMinLikelihood(Likelihood::POSSIBLE);

    // Run request
    $inspectContentRequest = (new InspectContentRequest())
        ->setParent($parent)
        ->setInspectConfig($inspectConfig)
        ->setItem($item);
    $response = $dlp->inspectContent($inspectContentRequest);

    // Print the results
    $findings = $response->getResult()->getFindings();
    if (count($findings) == 0) {
        printf('No findings.' . PHP_EOL);
    } else {
        printf('Findings:' . PHP_EOL);
        foreach ($findings as $finding) {
            printf('  Quote: %s' . PHP_EOL, $finding->getQuote());
            printf('  Info type: %s' . PHP_EOL, $finding->getInfoType()->getName());
            printf('  Likelihood: %s' . PHP_EOL, Likelihood::name($finding->getLikelihood()));
        }
    }
}

Python

如要瞭解如何安裝及使用 Sensitive Data Protection 的用戶端程式庫,請參閱這篇文章

如要驗證 Sensitive Data Protection,請設定應用程式預設憑證。 詳情請參閱「為本機開發環境設定驗證」。

import google.cloud.dlp


def inspect_phone_number(
    project: str,
    content_string: str,
) -> None:
    """Uses the Data Loss Prevention API to analyze strings for protected data.
    Args:
        project: The Google Cloud project id to use as a parent resource.
        content_string: The string to inspect phone number from.
    """

    # Instantiate a client.
    dlp = google.cloud.dlp_v2.DlpServiceClient()

    # Prepare info_types by converting the list of strings into a list of
    # dictionaries (protos are also accepted).
    info_types = [{"name": "PHONE_NUMBER"}]

    # Construct the configuration dictionary.
    inspect_config = {
        "info_types": info_types,
        "include_quote": True,
    }

    # Construct the `item`.
    item = {"value": content_string}

    # Convert the project id into a full resource id.
    parent = f"projects/{project}"

    # Call the API.
    response = dlp.inspect_content(
        request={"parent": parent, "inspect_config": inspect_config, "item": item}
    )

    # Print out the results.
    if response.result.findings:
        for finding in response.result.findings:
            print(f"Quote: {finding.quote}")
            print(f"Info type: {finding.info_type.name}")
            print(f"Likelihood: {finding.likelihood}")
    else:
        print("No findings.")

REST

JSON 輸入:

POST https://dlp.googleapis.com/v2/projects/[PROJECT-ID]/content:inspect?key={YOUR_API_KEY}

{
  "item":{
    "value":"My phone number is (415) 555-0890"
  },
  "inspectConfig":{
    "includeQuote":true,
    "minLikelihood":"POSSIBLE",
    "infoTypes":{
      "name":"PHONE_NUMBER"
    }
  }
}

當您將上述要求傳送至指定端點時,資訊保護服務會傳回下列內容:

JSON 輸出:

{
  "result":{
    "findings":[
      {
        "quote":"(415) 555-0890",
        "infoType":{
          "name":"PHONE_NUMBER"
        },
        "likelihood":"VERY_LIKELY",
        "location":{
          "byteRange":{
            "start":"19",
            "end":"33"
          },
          "codepointRange":{
            "start":"19",
            "end":"33"
          }
        },
        "createTime":"2018-10-29T23:46:34.535Z"
      }
    ]
  }
}

您必須在檢查設定中指定參考資料列出的特定 infoType。如未指定任何 infoType,Sensitive Data Protection 會使用預設的 infoType 清單,但僅供測試用途。預設清單可能不適合您的用途。

要進一步瞭解如何使用 infoType 偵測工具掃描您的內容,請參閱有關檢查、遮蓋或去識別化的操作教學主題

確定度與測試

系統會回報發現項目,並提供稱為「可能性」的確定度分數。可能性分數代表發現項目與相應類型相符的可能性。舉例來說,如果類型只符合模式,可能會傳回較低的可能性;如果類型符合模式,且周圍有正向內容,則可能會傳回較高的可能性。因此,您可能會發現單一發現項目在較低可能性下,可能符合多種型別。此外,如果發現項目不符或周圍有負面內容,可能不會顯示或確定度較低。舉例來說,如果發現項目符合指定 infoType 的結構,但未通過 infoType 的檢查碼,系統可能就不會回報該項目。或者,發現項目可能符合多個 infoType,但其中一個 infoType 的背景資訊較為豐富,因此只會回報該類型。

如果您測試各種偵測器,可能會發現系統不會回報虛假或樣本資料,因為這些資料未通過足夠的檢查,因此無法回報。

infoType 偵測工具的種類

Sensitive Data Protection 包括數種 infoType 偵測工具,分別摘要如下:

  • 內建 infoType 偵測工具內建於 Sensitive Data Protection,包括用於掃描特定國家/地區機密資料類型及全球適用資料類型的偵測工具。您也可以使用一般 infoType 簡化設定。
  • 自訂 infoType 偵測工具是您自行建立的偵測工具。自訂 infoType 偵測工具分為三種:
    • 「小型自訂字典偵測工具」是 Sensitive Data Protection 用於比對的簡單字詞清單。如果您的清單包含多達數萬個字詞或詞組,請使用小型自訂字典偵測工具。如果您的字詞清單不會大幅變動,建議採用小型自訂字典偵測工具。
    • 「大型自訂字典偵測工具」是由 Sensitive Data Protection 使用儲存在 Cloud Storage 或 BigQuery 中的龐大字詞或詞組清單所產生。字詞或詞組清單龐大 (即高達數千萬個) 時,宜使用大型自訂字典偵測工具。
    • 「規則運算式 (regex)」可讓敏感性資料保護功能根據規則運算式模式偵測相符項目。

此外,Sensitive Data Protection 引進檢查規則的概念,可讓您使用以下項目微調掃描結果:

  • 「排除規則」可讓您將規則新增到內建或自訂 infoType 偵測工具中,藉此減少傳回的發現項目數。
  • 「啟動字詞規則」可讓您將規則新增到內建或自訂 infoType 偵測工具中,藉此提高傳回的發現項目數量,或變更傳回發現項目的可能性值

內建 InfoType 偵測工具

內建 infoType 偵測工具內建於機密資料保護服務中,包括用於掃描特定國家/地區機密資料類型的偵測工具,如法國的「Numéro d'Inscription au Répertoire (NIR)」 (FRANCE_NIR)、英國的駕照號碼 (UK_DRIVERS_LICENSE_NUMBER),以及美國社會安全號碼 (US_SOCIAL_SECURITY_NUMBER) 等。此外,也包括全球適用資料類型,如個人姓名 (PERSON_NAME)、電話號碼 (PHONE_NUMBER)、電子郵件地址 (EMAIL_ADDRESS) 和信用卡號 (CREDIT_CARD_NUMBER) 等。如要偵測與 infoType 相符的內容,機密資料保護服務會運用各種技術,包括模式比對、檢查碼、機器學習、內容分析等。

內建 infoType 偵測工具的清單會隨時更新。如需目前支援的內建 infoType 偵測工具的完整清單,請參閱 InfoType 偵測工具參考資料

您也可以呼叫 Sensitive Data Protection 的 infoTypes.list 方法,查看所有內建 infoType 偵測工具的完整清單。

語言支援

特定國家/地區的 infoType 支援英文和該國家/地區的語言。大多數全球 infoType 支援多種語言。 使用您的資料測試 Sensitive Data Protection,確認是否符合需求。

一般和特定 infoType 偵測工具

一般 infoType 偵測工具的定義比一般 infoType 偵測工具更廣泛,可比對各種可能屬於機密資訊的類型。一般 infoType 偵測工具是特定 infoType 偵測工具的超集,這些偵測工具共用屬性或用途。舉例來說,DRIVERS_LICENSE_NUMBER infoType 偵測工具可以偵測符合 GERMANY_DRIVERS_LICENSE_NUMBERCANADA_DRIVERS_LICENSE_NUMBER infoType 的內容。

在許多情況下,一般 infoType 偵測工具也能找到特定 infoType 偵測工具無法比對的項目。舉例來說,PASSPORT 偵測工具比特定國家/地區的護照偵測工具更擅長找出護照號碼,因為後者有時需要有脈絡線索或特定格式的內容。

在檢查設定中,您可以使用一般 infoType 偵測工具,取代特定 infoType 偵測工具。Sensitive Data Protection 會根據您在要求中指定的偵測器,顯示結果。舉例來說,如果您檢查的字串符合 GERMANY_DRIVERS_LICENSE_NUMBER infoType,且您在要求中同時掃描 DRIVERS_LICENSE_NUMBERGERMANY_DRIVERS_LICENSE_NUMBER,則系統會針對同一字串提供兩項發現項目,分別對應 DRIVERS_LICENSE_NUMBERGERMANY_DRIVERS_LICENSE_NUMBER。不過,如果要求中只掃描 DRIVERS_LICENSE_NUMBER,檢查結果就只會顯示 DRIVERS_LICENSE_NUMBER 的發現。

使用一般 infoType 偵測工具有以下優點:

  • 在許多情況下,一般 infoType 偵測工具的召回率會高於特定 infoType 偵測工具。喚回率是指真陽性例項數除以相關例項總數。

  • 您不必指定要掃描的每個特定 infoType,因此可以簡化 Sensitive Data Protection 要求。舉例來說,光是 GOVERNMENT_ID infoType 偵測工具就包含超過 100 種不同的 infoType 偵測工具。

  • 您較不可能達到每個要求 150 個 infoType 偵測工具的上限。

  • 如果 Sensitive Data Protection 發布新的 infoType,並將其新增至現有設定中已指定的一般 infoType,則 Sensitive Data Protection 會自動將新的 infoType 納入掃描範圍。您不必手動將新發布的 infoType 新增至現有設定。

一般和特定 infoType 之間為多對多關係。也就是說,一般 infoType 可以包含許多特定 infoType,而特定 infoType 可以屬於許多一般 infoType。如需一般 infoType 的完整清單,以及這些 infoType 包含的特定 infoType,請參閱「一般 infoType」。

自訂 infoType 偵測工具

自訂 infoType 偵測工具分為三種:

此外,Sensitive Data Protection 包含檢查規則,讓您為現有偵測工具新增以下規則以微調掃描結果:

小型自訂字典偵測工具

請使用小型自訂字典偵測工具 (也稱為「一般自訂字典偵測工具」),來比對較小的 (最多數萬個) 字詞或詞組清單。小型自訂字典可用做自己唯一的偵測工具。

如果您要掃描的字詞或詞組清單不易使用規則運算式或內建偵測工具進行比對時,即適合使用自訂字典偵測工具。例如,假設您要掃描會議室,一般會使用指定名稱而非號碼來稱呼會議室,如州或地區名稱、地標、虛構角色等。那麼您可以建立包含這些會議室名稱清單的小型自訂字典偵測工具。Sensitive Data Protection 服務會掃描您的內容,查看是否包含這些會議室名稱,在上下文中發現這些名稱時傳回相符項目。如要進一步瞭解 Sensitive Data Protection 如何比對字典字詞和詞組,請參閱「建立一般自訂字典偵測工具」一文的「字典比對細節」部分。

如要進一步瞭解小型字典自訂 infoType 偵測工具的運作原理及應用範例,請參閱建立一般自訂字典偵測工具一文。

大型自訂字典偵測工具

當您要掃描的字詞或詞組不是只有幾個,或是字詞或詞組清單經常變動時,請使用大型自訂字典偵測工具 (也稱為「儲存的自訂字典偵測工具」)。大型自訂字典偵測工具可以比對高達數千萬個字詞或詞組。

大型自訂字典偵測工具的建立方式,與規則運算式自訂偵測工具和小型自訂字典偵測工具不同。每個大型自訂字典都有兩個元件:

  • 建立及定義的詞組清單。這個清單會存成 Cloud Storage 中的文字檔或存成 BigQuery 表格中的資料欄。
  • 由敏感資料保護服務根據您的詞組清單產生的字典檔案。字典檔案儲存在 Cloud Storage 中,由來源詞組資料加上 Bloom 篩選器所組成,用於輔助搜尋和比對。這些檔案無法直接編輯。

建立字詞清單,然後使用 Sensitive Data Protection 產生自訂字典後,即可使用大型自訂字典偵測工具啟動或排程掃描,方式與其他 infoType 偵測工具類似。

如要進一步瞭解大型自訂字典偵測工具的運作原理及應用範例,請參閱建立儲存的自訂字典偵測工具一文。

規則運算式

規則運算式 (regex) 自訂 infoType 偵測工具方便您建立自己的 infoType 偵測工具,以讓機密資料保護功能根據規則運算式模式偵測相符項目。舉例來說,假設您的病歷編號格式為 ###-#-#####,則可定義如下所示的規則運算式:

[1-9]{3}-[1-9]{1}-[1-9]{5}

Sensitive Data Protection 隨後會比對類似以下的項目:

123-4-56789

您也可以指定指派給每個自訂 infoType 相符項目的可能性。也就是說,當 Sensitive Data Protection 比對您指定的序列時,將會指派您指定的可能性。這項功能非常實用,因為如果自訂規則運算式定義的序列夠常見,就很容易與其他隨機序列相符,您不會希望敏感資料保護功能將每個相符項目都標示為 VERY_LIKELY。這麼做會降低掃描結果的可信度,並可能導致系統比對或去識別化錯誤的資訊。

如需進一步瞭解規則運算式自訂 infoType 偵測工具及其應用實例,請參閱建立自訂規則運算式偵測工具一文。

檢查規則

您可使用檢查規則來微調現有的內建或自訂 infoType 偵測工具傳回的結果。當 Sensitive Data Protection 傳回的結果必須透過某種方式擴增時,不論是從現有 infoType 偵測工具中進行增減,檢查規則可能會很有幫助。

檢查規則有以下兩種類型:

  • 排除規則
  • 啟動字詞規則

如要進一步瞭解檢查規則,請參閱修改 infoType 偵測工具以修正掃描結果一文。

排除規則

排除規則可讓您將規則新增到內建或自訂 infoType 偵測工具中,藉此減少傳回的發現項目數或精確度。排除規則可以協助您降低 infoType 偵測工具傳回的雜訊或其他不需要的發現項目。

舉例來說,如果您掃描資料庫中的電子郵件地址,可以使用自訂規則運算式的格式來新增排除規則,指示 Sensitive Data Protection 排除結尾是「@example.com」的任何發現項目。

排除規則無法套用至物件 InfoType

如要進一步瞭解排除規則,請參閱修改 infoType 偵測工具以修正掃描結果一文。

啟動字詞規則

啟動字詞規則可讓您將規則新增到內建或自訂 infoType 偵測工具中,藉此提高傳回的發現項目數量或準確性。啟動字詞規則可以有效協助您放寬現有 infoType 偵測工具的規則。

例如,假設您要掃描醫療資料庫中的患者姓名,您可以使用 Sensitive Data Protection 內建的 PERSON_NAME infoType 偵測工具,不過 Sensitive Data Protection 會因此比對所有人的姓名,而不是只比對患者的姓名。為解決這種情況,您可以利用規則運算式自訂 infoType 的形式來加入啟動字詞規則,從潛在相符項目的第一個字元向旁邊延伸特定字元,並在這個範圍中尋找「患者」一詞。接著,您可以為符合此模式的搜尋項目指派「非常可能」的可能性,原因是這些搜尋項目可對應至您的特殊條件。

如要進一步瞭解啟動字詞規則,請參閱修改 infoType 偵測工具以修正掃描結果一文。

範例

如要進一步瞭解資訊類型如何與發現項目相符,請參閱下列一系列數字的比對範例,判斷這些數字是否構成美國社會安全號碼或美國個人納稅識別號碼。請注意,這些範例適用於內建的 infoType 偵測工具。建立自訂 infoType 偵測工具時,您會指定決定掃描相符項目可能性的條件。

範例 1

"SSN 222-22-2222"

報告指出 US_SOCIAL_SECURITY_NUMBER 的可能性分數為 VERY_LIKELY,原因如下:

  • 該號碼採用標準身分證字號格式,因此確定度較高。
  • 附近有可提升US_SOCIAL_SECURITY_NUMBER的內容 (「SSN」)。

範例 2

"999-99-9999"

由於下列原因,系統回報 US_SOCIAL_SECURITY_NUMBER 的可能性分數偏低 (VERY_UNLIKELY):

  • 採用標準格式,因此確定度較高。
  • 開頭為 9,但社會安全號碼不得以 9 開頭,因此確定度較低。
  • 但這類資訊缺乏背景資訊,因此確定度較低。

範例 3

"999-98-9999"

回報 US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBERVERY_UNLIKELYPOSSIBLE 分數,因為:US_SOCIAL_SECURITY_NUMBER

  • 這兩種格式都採用標準格式。US_SOCIAL_SECURITY_NUMBERUS_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER
  • 開頭為 9,且有另一項數字檢查,可提高US_INDIVIDUAL_TAXPAYER_IDENTIFICATION_NUMBER的確定度。
  • 由於缺少背景資訊,兩者確定度都會降低。

後續步驟

Sensitive Data Protection 團隊會定期發布最新的 infoType 偵測工具與群組。如要瞭解如何取得最新的內建 infoType 清單,請參閱列出內建的 InfoType 偵測工具