하이브리드 작업을 사용하여 외부 소스의 데이터 검사

이 주제에서는 하이브리드 작업 및 하이브리드 작업 트리거를 사용하여 외부 데이터에서 민감한 정보를 검사하는 방법을 설명합니다. 하이브리드 환경을 포함하여 하이브리드 작업 및 하이브리드 작업 트리거에 대한 자세한 내용은 하이브리드 작업 및 하이브리드 작업 트리거를 참조하세요.

하이브리드 작업 및 하이브리드 작업 트리거 소개

하이브리드 작업 및 하이브리드 작업 트리거를 사용하면 Sensitive Data Protection이 제공하는 보호 범위를 단순 콘텐츠 검사 요청Google Cloud Storage 저장소 검사보다 넓게 확장할 수 있습니다. 하이브리드 작업 및 하이브리드 작업 트리거를 사용하면 Google Cloud 외부를 포함하여 거의 모든 소스에서Sensitive Data Protection으로 직접 데이터를 스트리밍할 수 있고 Sensitive Data Protection에서 데이터의 민감한 정보를 검사할 수 있습니다. Sensitive Data Protection은 추가 분석을 위해 스캔 결과를 자동으로 저장하고 집계합니다.

하이브리드 작업 및 하이브리드 작업 트리거 비교

하이브리드 작업을 만들면 중지할 때까지 실행됩니다. 데이터가 올바르게 라우팅되고 및 형식이 지정되는 한 모든 수신 데이터를 허용합니다.

하이브리드 작업 트리거는 하이브리드 작업과 비슷한 방식으로 작동하지만 하이브리드 작업 트리거 내에서 작업을 명시적으로 중지할 필요가 없습니다. Sensitive Data Protection은 하루가 끝날 때 하이브리드 작업 트리거 내에서 작업을 자동으로 중지합니다.

또한 하이브리드 작업 트리거를 사용하면 hybridInspect 요청을 재구성할 필요 없이 트리거 내에서 새 작업을 중지하고 시작할 수 있습니다. 예를 들어 데이터를 하이브리드 작업 트리거로 전송한 다음 활성 작업을 중지하고, 구성을 변경하고, 해당 트리거 내에서 새 작업을 시작한 후 동일한 트리거로 데이터를 계속 전송할 수 있습니다.

사용 사례에 적합한 옵션에 대한 자세한 내용은 이 페이지의 일반 하이브리드 검사 시나리오를 참조하세요.

용어 정의

이 주제에서는 다음 용어를 사용합니다.

  • 외부 데이터: Google Cloud 외부에 저장된 데이터 또는 Sensitive Data Protection이 기본적으로 지원하지 않는 데이터입니다.

  • 하이브리드 작업: 거의 모든 소스에서 데이터를 스캔하도록 구성된 검사 작업입니다.

  • 하이브리드 작업 트리거: 거의 모든 소스에서 데이터를 스캔하도록 구성된 작업 트리거입니다.

  • hybridInspect 요청: 검사할 외부 데이터가 포함된 요청입니다. 이 요청을 전송할 때 요청을 전송할 하이브리드 작업 또는 하이브리드 작업 트리거를 지정합니다.

작업 및 작업 트리거에 대한 일반적인 내용은 작업 및 작업 트리거를 참조하세요.

하이브리드 검사 프로세스

하이브리드 검사 프로세스에는 세 가지 단계가 있습니다.

  1. Sensitive Data Protection로 전송할 데이터를 선택합니다.

    데이터는 Google Cloud 내부 또는 외부를 출처로 할 수 있습니다. 예를 들어 Sensitive Data Protection으로 데이터를 전송하도록 커스텀 스크립트 또는 애플리케이션을 구성하여 다른 클라우드 서비스, 온프레미스 데이터 저장소 또는 거의 모든 다른 데이터 소스에서 전송 중인 데이터를 검사할 수 있습니다.

  2. Sensitive Data Protection에서 하이브리드 작업 또는 하이브리드 작업 트리거를 처음부터 설정하거나 검사 템플릿을 사용하여 설정합니다.

    하이브리드 작업 또는 하이브리드 작업 트리거를 설정한 후에는 Sensitive Data Protection이 전송되는 데이터를 적극적으로 리슨합니다. 커스텀 스크립트 또는 애플리케이션이 이 하이브리드 작업 또는 하이브리드 작업 트리거로 데이터를 전송하면 데이터가 검사되고 구성에 따라 결과가 저장됩니다.

    하이브리드 작업 또는 하이브리드 작업 트리거를 설정할 때 발견 항목을 저장하거나 게시할 위치를 지정할 수 있습니다. 옵션에는 BigQuery에 저장 및 Pub/Sub, Cloud Monitoring, 이메일에 알림 게시가 포함됩니다.

  3. 하이브리드 작업 또는 하이브리드 작업 트리거에 hybridInspect 요청을 전송합니다.

    hybridInspect 요청에는 스캔할 데이터가 포함됩니다. 요청에서 콘텐츠를 설명하고 추적하려는 정보가 Sensitive Data Protection에서 식별될 수 있게 해주는 메타데이터(라벨테이블 식별자라고도 함)를 포함하세요. 예를 들어 여러 요청(예: 동일한 데이터베이스 테이블의 행)에서 관련 데이터를 스캔하는 경우 해당 관련 요청에서 동일한 메타데이터를 사용할 수 있습니다. 그런 다음 해당 데이터베이스 테이블의 발견 항목을 수집, 집계, 분석할 수 있습니다.

하이브리드 작업이 실행되고 요청을 검사하면 Sensitive Data Protection에서 생성되는 즉시 검사 결과를 사용할 수 있습니다. 반면에 Pub/Sub 알림과 같은 작업은 애플리케이션이 하이브리드 작업을 종료할 때까지 발생하지 않습니다.

하이브리드 작업 검사 프로세스를 보여주는 다이어그램

고려사항

하이브리드 작업 및 작업 트리거로 작업할 때는 다음 사항을 고려하세요.

  • 하이브리드 작업 및 하이브리드 작업 트리거는 필터링 및 샘플링을 지원하지 않습니다.
  • 작업 및 작업 트리거에는 서비스 수준 목표(SLO)가 적용되지 않지만 지연 시간을 줄이기 위해 취할 수 있는 단계가 있습니다. 자세한 내용은 작업 지연 시간을 참조하세요.

시작하기 전에

하이브리드 작업 또는 하이브리드 작업 트리거를 설정하고 사용하기 전에 다음 작업을 완료했는지 확인합니다.

새 프로젝트 만들기, 결제 사용 설정, Sensitive Data Protection 사용 설정

  1. Google Cloud 계정에 로그인합니다. Google Cloud를 처음 사용하는 경우 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $300의 무료 크레딧이 제공됩니다.
  2. Google Cloud Console의 프로젝트 선택기 페이지에서 Google Cloud 프로젝트를 선택하거나 만듭니다.

    프로젝트 선택기로 이동

  3. Google Cloud 프로젝트에 결제가 사용 설정되어 있는지 확인합니다.

  4. Google Cloud Console의 프로젝트 선택기 페이지에서 Google Cloud 프로젝트를 선택하거나 만듭니다.

    프로젝트 선택기로 이동

  5. Google Cloud 프로젝트에 결제가 사용 설정되어 있는지 확인합니다.

  6. Sensitive Data Protection API 사용 설정

    API 사용 설정

데이터 소스 구성

Sensitive Data Protection이 데이터를 검사하려면 먼저 데이터를 Sensitive Data Protection으로 전송해야 합니다. 하이브리드 작업 또는 하이브리드 작업 트리거를 구성하는 데 사용하는 방법에 관계없이 데이터를 DLP API로 전송하도록 외부 소스를 설정해야 합니다.

하이브리드 검사 요청에 필요한 형식에 대한 자세한 내용은 하이브리드 콘텐츠 항목 형식 지정을 참조하세요. 요청의 데이터에 포함할 수 있는 메타데이터 유형에 대한 자세한 내용은 제공할 수 있는 메타데이터 유형을 참조하세요.

하이브리드 작업 또는 하이브리드 작업 트리거 만들기

전송하려는 데이터를 Sensitive Data Protection에서 검사하도록 하려면 먼저 하이브리드 작업 또는 하이브리드 작업 트리거를 설정해야 합니다. 무엇을 만들어야 하는지에 대해서는 이 페이지의 일반 하이브리드 검사 시나리오를 참조하세요.

콘솔

Google Cloud 콘솔에서 작업 또는 작업 트리거 만들기 페이지로 이동합니다.

작업 또는 작업 트리거 만들기로 이동

다음 섹션에서는 하이브리드 검사 작업과 관련된 작업 또는 작업 트리거 만들기 페이지에서 섹션을 채우는 방법을 설명합니다.

입력 데이터 선택

이 섹션에서는 Sensitive Data Protection에서 검사할 입력 데이터를 지정합니다.

  1. 선택 사항: 이름에서 작업 ID 필드에 값을 입력하여 작업 이름을 지정합니다. 이 필드를 비워 두면 Sensitive Data Protection이 식별자를 자동으로 생성합니다.
  2. 선택사항: 리소스 위치 메뉴에서 하이브리드 작업 또는 하이브리드 작업 트리거를 저장할 리전을 선택합니다. 자세한 내용은 처리 위치 지정을 참조하세요.
  3. 스토리지 유형으로 하이브리드를 선택합니다.

  4. 선택사항: 설명에 만들려는 하이브리드 작업 또는 하이브리드 작업 트리거에 대해 설명합니다. 예를 들어 검사할 데이터 소스에 대한 정보를 포함할 수 있습니다.

  5. 선택사항: 필수 라벨라벨 추가를 클릭하고 hybridInspect 요청에 필요한 라벨을 입력합니다. 이 라벨을 지정하지 않은 hybridInspect 요청은 이 하이브리드 작업 또는 하이브리드 작업 트리거에서 처리되지 않습니다. 필요한 라벨은 10개까지 추가할 수 있습니다. 자세한 내용은 이 페이지의 hybridInspect 요청에 필요한 라벨을 참조하세요.

  6. 선택사항: 선택적 라벨에는 이 작업 또는 작업 트리거로 전송되는 모든 hybridInspect 요청의 결과에 연결할 키-값 쌍을 입력합니다. 선택적 라벨은 10개까지 추가할 수 있습니다. 자세한 내용은 선택적 라벨을 참조하세요.

  7. 선택사항: hybridInspect 요청에서 테이블 형식 데이터를 전송하려는 경우 테이블 형식 데이터 옵션에 기본 키 열의 필드 이름을 입력합니다. 자세한 내용은 테이블 형식 데이터 옵션을 참조하세요.

  8. 계속을 클릭합니다.

감지 구성

이 섹션에서는 Sensitive Data Protection에서 입력 데이터를 검사할 민감한 정보 유형을 지정합니다. 이때 다음과 같은 옵션을 선택할 수 있습니다.

  • 템플릿: 현재 프로젝트에서 Sensitive Data Protection 감지 매개변수를 정의하는 데 사용할 템플릿을 이미 만든 경우 템플릿 이름 필드를 클릭한 다음 표시되는 목록에서 템플릿을 선택합니다.
  • InfoType: Sensitive Data Protection은 감지할 가장 일반적인 기본 제공 infoType을 선택합니다. infoType을 변경하거나 사용할 커스텀 infoType을 선택하려면 infoType 관리를 클릭합니다. 검사 규칙 세트신뢰도 기준 섹션에서 감지 기준을 세밀하게 조정할 수도 있습니다. 자세한 내용은 감지 구성을 참조하세요.

감지 매개변수를 구성한 후 계속을 클릭합니다.

작업 추가

이 섹션에서는 각 검사 스캔의 발견 항목을 저장할 위치와 스캔을 완료할 때마다 이메일 또는 Pub/Sub 알림 메시지로 알림을 받을지 여부를 지정합니다. BigQuery에 발견 항목을 저장하지 않으면 발견 항목의 개수 및 infoType에 대한 통계만 스캔 결과에 포함됩니다.

  • BigQuery에 저장: 스캔이 실행될 때마다 Sensitive Data Protection안 여기에서 지정한 BigQuery 테이블에 스캔 결과를 저장합니다. 테이블 ID를 지정하지 않으면 스캔이 처음 실행될 때 BigQuery가 새 테이블에 기본 이름을 할당합니다. 기존 테이블을 지정하면 Sensitive Data Protection이 스캔 발견 항목을 테이블에 추가합니다.
  • Pub/Sub에 게시: 작업이 완료되면 Pub/Sub 메시지가 표시됩니다.

  • 이메일로 알림: 작업이 완료되면 이메일 메시지가 전송됩니다.

  • Cloud Monitoring에 게시: 작업이 완료되면 발견 항목이 Monitoring에 게시됩니다.

작업을 선택한 후 계속을 클릭합니다.

예약

이 섹션에서는 즉시 실행되는 단일 작업을 생성할지 또는 올바르게 라우팅되고 형식이 지정된 데이터가 Sensitive Data Protection에 수신될 때마다 실행되는 작업 트리거를 생성할지 여부를 지정합니다.

다음 중 하나를 수행합니다.

  • 하이브리드 작업을 즉시 실행하려면 없음(생성 즉시 일회성 작업 실행)을 선택합니다.

  • 소스에서 수신한 데이터가 작업을 트리거하도록 작업을 구성하려면 주기적인 일정으로 작업을 실행하는 트리거 만들기를 선택합니다.

    하이브리드 작업 트리거가 API 호출을 집계하여 시간에 따른 발견 항목 결과 및 트렌드를 볼 수 있습니다.

자세한 내용은 하이브리드 작업 및 하이브리드 작업 트리거 비교를 참조하세요.

검토

여기에서 스캔의 JSON 요약을 검토할 수 있습니다. 하이브리드 작업 또는 하이브리드 작업 트리거의 이름을 기록해 둡니다. 이 정보는 검사를 위해 Sensitive Data Protection으로 데이터를 전송할 때 필요합니다.

JSON 요약을 검토한 후 만들기를 클릭합니다.

Sensitive Data Protection이 하이브리드 작업 또는 하이브리드 작업 트리거를 즉시 시작합니다. 이 하이브리드 작업 또는 하이브리드 작업 트리거에 hybridInspect 요청을 전송하면 검사 스캔이 시작됩니다.

API

작업은 DLP API에서 DlpJobs 리소스로 표시됩니다. 하이브리드 작업을 만들려면 projects.locations.dlpJobs.create 메서드를 호출합니다.

작업 트리거는 DLP API에서 JobTrigger 리소스로 표시됩니다. 하이브리드 작업 트리거를 만들려면 projects.locations.jobTriggers.create 메서드를 호출합니다.

만들려는 DlpJobs 또는 JobTrigger 객체에는 다음 설정이 포함되어야 합니다.

  1. inspectJob 필드에서 InspectJobConfig 객체를 설정합니다.
  2. InspectJobConfig 객체의 storageConfig 필드에서 StorageConfig 객체를 설정합니다.
  3. StorageConfig 객체의 hybridOptions 필드에서 HybridOptions 객체를 설정합니다. 이 객체에는 검사할 데이터에 대한 메타데이터가 포함되어 있습니다.
  4. InspectJobConfig 객체의 actions 필드에서 각 작업이 종료될 때 Sensitive Data Protection이 수행할 작업(Action)을 추가합니다.

    이 작업에는 publishSummaryToCsccpublishFindingsToCloudDataCatalog 작업이 지원되지 않습니다. 작업에 대한 자세한 내용은 작업을 참조하세요.

  5. 다음 중 하나 또는 모두를 수행하여 스캔할 대상과 방법을 지정합니다.

    • 가능한 경우 inspectTemplateName 필드를 사용하려는 검사 템플릿의 전체 리소스 이름으로 설정합니다.

    • inspectConfig 필드를 설정합니다.

    inspectTemplateNameinspectConfig 필드를 모두 설정하면 해당 설정이 결합됩니다.

JSON 예시 정보

다음 탭에는 하이브리드 작업 또는 하이브리드 작업 트리거를 만들기 위해 Sensitive Data Protection에 전송할 수 있는 JSON 예시가 포함되어 있습니다. 이러한 하이브리드 작업 및 하이브리드 작업 트리거 예시는 다음을 수행하도록 구성되어 있습니다.

  • 요청에 appointment-bookings-comments 라벨이 있으면 모든 hybridInspect 요청을 처리합니다.
  • hybridInspect 요청의 콘텐츠에서 이메일 주소를 스캔합니다.
  • 발견 항목에 "env": "prod" 라벨을 연결합니다.
  • 테이블 형식 데이터의 경우 민감한 정보가 발견된 셀과 동일한 행에 있는 booking_id 열(기본 키)에서 셀 값을 가져옵니다. 민감한 정보 보호에서 이 식별자를 발견 항목에 연결하므로 발견 항목이 시작된 특정 행으로 발견 항목을 추적할 수 있습니다.
  • 작업이 중지되면 이메일을 전송합니다. 이메일은 IAM 프로젝트 소유자 및 기술 필수 연락처로 전송됩니다.
  • 작업이 중지되면 Cloud Monitoring에 발견 항목을 전송합니다.

JSON 예시를 보려면 다음 탭을 참조하세요.

하이브리드 작업

이 탭에는 하이브리드 작업을 만드는 데 사용할 수 있는 JSON 예시가 포함되어 있습니다.

하이브리드 작업을 만들려면 다음 엔드포인트로 POST 요청을 전송합니다.

HTTP 메서드 및 URL

POST https://dlp.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/dlpJobs

다음을 바꿉니다.

  • PROJECT_ID: 하이브리드 작업을 저장할 프로젝트 ID입니다.
  • REGION: 하이브리드 작업을 저장할 지리적 리전입니다.

JSON 입력

{
  "jobId": "postgresql-table-comments",
  "inspectJob": {
    "actions": [
      {
        "jobNotificationEmails": {}
      },
      {
        "publishToStackdriver": {}
      }
    ],
    "inspectConfig": {
      "infoTypes": [
        {
          "name": "EMAIL_ADDRESS"
        }
      ],
      "minLikelihood": "POSSIBLE",
      "includeQuote": true
    },
    "storageConfig": {
      "hybridOptions": {
        "description": "Hybrid job for data from the comments field of a table that contains customer appointment bookings",
        "requiredFindingLabelKeys": [
          "appointment-bookings-comments"
        ],
        "labels": {
          "env": "prod"
        },
        "tableOptions": {
          "identifyingFields": [
            {
              "name": "booking_id"
            }
          ]
        }
      }
    }
  }
}

JSON 출력

{
"name": "projects/PROJECT_ID/locations/REGION/dlpJobs/i-postgresql-table-comments",
"type": "INSPECT_JOB",
"state": "ACTIVE",
"inspectDetails": {
  "requestedOptions": {
    "snapshotInspectTemplate": {},
    "jobConfig": {
      "storageConfig": {
        "hybridOptions": {
          "description": "Hybrid job for data from the comments field of a table that contains customer appointment bookings",
          "requiredFindingLabelKeys": [
            "appointment-bookings-comments"
          ],
          "labels": {
            "env": "prod"
          },
          "tableOptions": {
            "identifyingFields": [
              {
                "name": "booking_id"
              }
            ]
          }
        }
      },
      "inspectConfig": {
        "infoTypes": [
          {
            "name": "EMAIL_ADDRESS"
          }
        ],
        "minLikelihood": "POSSIBLE",
        "limits": {},
        "includeQuote": true
      },
      "actions": [
        {
          "jobNotificationEmails": {}
        },
        {
          "publishToStackdriver": {}
        }
      ]
    }
  },
  "result": {
    "hybridStats": {}
  }
},
"createTime": "JOB_CREATION_DATETIME",
"startTime": "JOB_START_DATETIME"
}

Sensitive Data Protection이 하이브리드 작업을 만들고 작업 ID를 생성합니다. 이 예시에서 작업 ID는 i-postgresql-table-comments입니다. 작업 ID를 기록해 둡니다. hybridInspect 요청에 필요합니다.

하이브리드 작업을 중지하려면 명시적으로 projects.locations.dlpJobs.finish 메서드를 호출해야 합니다. DLP API는 하이브리드 작업을 자동으로 중지하지 않습니다. 반면에 하루가 끝날 때 DLP API가 하이브리드 작업 트리거 내에서 작업을 자동으로 중지합니다.

하이브리드 작업 트리거

이 탭에는 하이브리드 작업 트리거를 만드는 데 사용할 수 있는 JSON 예시가 포함되어 있습니다.

하이브리드 작업 트리거를 만들려면 다음 엔드포인트로 POST 요청을 전송합니다.

HTTP 메서드 및 URL

POST https://dlp.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/jobTriggers

다음을 바꿉니다.

  • PROJECT_ID: 하이브리드 작업 트리거를 저장할 프로젝트 ID입니다.
  • REGION: 하이브리드 작업 트리거를 저장할 지리적 리전입니다.

JSON 입력

{
    "triggerId": "postgresql-table-comments",
    "jobTrigger": {
      "triggers": [
        {
          "manual": {}
        }
      ],
      "inspectJob": {
        "actions": [
          {
            "jobNotificationEmails": {}
          },
          {
            "publishToStackdriver": {}
          }
        ],
        "inspectConfig": {
          "infoTypes": [
              {
                "name": "EMAIL_ADDRESS"
              }
          ],
          "minLikelihood": "POSSIBLE",
          "limits": {},
          "includeQuote": true
        },
        "storageConfig": {
          "hybridOptions": {
            "description": "Hybrid job trigger for data from the comments field of a table that contains customer appointment bookings",
            "requiredFindingLabelKeys": [
                "appointment-bookings-comments"
              ],
            "labels": {
              "env": "prod"
            },
            "tableOptions": {
              "identifyingFields": [
                {
                  "name": "booking_id"
                }
              ]
            }
          }
        }
      }
    }
  }

JSON 출력

{
"name": "projects/PROJECT_ID/locations/REGION/jobTriggers/postgresql-table-comments",
"inspectJob": {
  "storageConfig": {
    "hybridOptions": {
      "description": "Hybrid job trigger for data from the comments field of a table that contains customer appointment bookings",
      "requiredFindingLabelKeys": [
        "appointment-bookings-comments"
      ],
      "labels": {
        "env": "prod"
      },
      "tableOptions": {
        "identifyingFields": [
          {
            "name": "booking_id"
          }
        ]
      }
    }
  },
  "inspectConfig": {
    "infoTypes": [
      {
        "name": "EMAIL_ADDRESS"
      }
    ],
    "minLikelihood": "POSSIBLE",
    "limits": {},
    "includeQuote": true
  },
  "actions": [
    {
      "jobNotificationEmails": {}
    },
    {
      "publishToStackdriver": {}
    }
  ]
},
"triggers": [
  {
    "manual": {}
  }
],
"createTime": ""JOB_CREATION_DATETIME",
"updateTime": "TRIGGER_UPDATE_DATETIME",
"status": "HEALTHY"
}

Sensitive Data Protection이 하이브리드 작업 트리거를 만듭니다. 출력에 하이브리드 작업 트리거의 이름이 포함됩니다. 이 예시에서는 postgresql-table-comments입니다. 이름을 기록해 둡니다. hybridInspect 요청에 필요합니다.

하이브리드 작업과 달리 하루가 끝날 때 DLP API가 하이브리드 작업 트리거 내에서 작업을 자동으로 중지합니다. 따라서 projects.locations.dlpJobs.finish 메서드를 명시적으로 호출할 필요가 없습니다.

하이브리드 작업 또는 하이브리드 작업 트리거를 만들 때는 각각 다음 API 참조 페이지에서 API 탐색기를 사용할 수 있습니다.

요청 매개변수 필드에 projects/PROJECT_ID/locations/REGION을 입력합니다. 그런 다음 요청 본문 필드에 만들려는 객체의 샘플 JSON을 붙여넣습니다.

API 탐색기에서 생성된 것이라도, 요청이 성공하면 하이브리드 작업 또는 하이브리드 작업 트리거가 생성됩니다.

JSON을 사용하여 DLP API로 요청을 전송하는 데 대한 일반적인 정보는 JSON 빠른 시작을 참조하세요.

하이브리드 작업 또는 하이브리드 작업 트리거로 데이터 전송

데이터를 검사하려면 하이브리드 작업 또는 하이브리드 작업 트리거에 올바른 형식의 hybridInspect 요청을 전송해야 합니다.

하이브리드 콘텐츠 항목 형식 지정

다음은 하이브리드 작업 또는 하이브리드 작업 트리거로 처리하기 위해 Sensitive Data Protection으로 전송되는 hybridInspect 요청의 간단한 예시입니다. 다음 필드가 포함된 hybridItem 필드를 포함하여 JSON 객체의 구조를 확인하세요.

  • item: 검사할 실제 콘텐츠를 포함합니다.
  • findingDetails: 콘텐츠와 연결할 메타데이터를 포함합니다.
{
  "hybridItem": {
    "item": {
      "value": "My email is test@example.org"
    },
    "findingDetails": {
      "containerDetails": {
        "fullPath": "10.0.0.2:logs1:app1",
        "relativePath": "app1",
        "rootPath": "10.0.0.2:logs1",
        "type": "logging_sys",
        "version": "1.2"
      },
      "labels": {
        "env": "prod",
        "appointment-bookings-comments": ""
      }
    }
  }
}

하이브리드 검사 항목의 콘텐츠에 대한 자세한 내용은 HybridContentItem 객체의 API 참조 콘텐츠를 참조하세요.

하이브리드 검사 엔드포인트

하이브리드 작업 또는 하이브리드 작업 트리거를 사용하여 데이터를 검사하려면 올바른 엔드포인트로 hybridInspect 요청을 전송해야 합니다.

하이브리드 작업을 위한 HTTP 메서드 및 URL

POST https://dlp.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/dlpJobs/JOB_ID:hybridInspect

이 엔드포인트에 대한 자세한 내용은 projects.locations.dlpJobs.hybridInspect 메서드의 API 참조 페이지를 참조하세요.

하이브리드 작업 트리거를 위한 HTTP 메서드 및 URL

https://dlp.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/jobTriggers/TRIGGER_NAME:hybridInspect

이 엔드포인트에 대한 자세한 내용은 projects.locations.jobTriggers.hybridInspect 메서드의 API 참조 페이지를 참조하세요.

다음을 바꿉니다.

  • PROJECT_ID: 프로젝트 식별자입니다.
  • REGION: hybridInspect 요청을 저장할 지리적 리전입니다. 이 리전은 하이브리드 작업의 리전과 동일해야 합니다.
  • JOB_ID: i-를 프리픽스로 사용하여 하이브리드 작업에 지정한 ID입니다.

    작업 ID를 찾으려면 Sensitive Data Protection에서 검사 > 작업 검사를 클릭합니다.

  • TRIGGER_NAME: 하이브리드 작업 트리거에 지정한 이름입니다.

    작업 트리거의 이름을 조회하려면 Sensitive Data Protection에서 검사 > 작업 트리거를 클릭합니다.

hybridInspect 요청에 필요한 라벨

하이브리드 작업 또는 하이브리드 작업 트리거에서 처리할 수 있는 hybridInspect 요청을 제어하려면 필요한 라벨을 설정하면 됩니다. 이러한 필요한 라벨이 포함되지 않은 하이브리드 작업 또는 하이브리드 작업 트리거의 hybridInspect 요청은 거부됩니다.

필요한 라벨을 설정하려면 다음을 수행합니다.

  1. 하이브리드 작업 또는 하이브리드 작업 트리거를 만들 때 requiredFindingLabelKeys 필드를 필요한 라벨 목록으로 설정합니다.

    다음 예시는 appointment-bookings-comments를 하이브리드 작업 또는 하이브리드 작업 트리거에서 필요한 라벨로 설정합니다.

    "hybridOptions": {
      ...
      "requiredFindingLabelKeys": [
        "appointment-bookings-comments"
      ],
      "labels": {
        "env": "prod"
      },
      ...
    }
    
  2. hybridInspect 요청의 labels 필드에서 각 필요한 라벨을 키-값 쌍의 키로 추가합니다. 해당 값은 빈 문자열일 수 있습니다.

    다음 예시에서는 hybridInspect 요청에서 필요한 라벨 appointment-bookings-comments를 설정합니다.

    {
      "hybridItem": {
        "item": {
          "value": "My email is test@example.org"
        },
        "findingDetails": {
          "containerDetails": {...},
          "labels": {
            "appointment-bookings-comments": ""
          }
        }
      }
    }
    

hybridInspect 요청에 필요한 라벨을 포함하지 않으면 다음과 같은 오류가 발생합니다.

{
  "error": {
    "code": 400,
    "message": "Trigger required labels that were not included: [appointment-bookings-comments]",
    "status": "INVALID_ARGUMENT"
  }
}

코드 샘플: 하이브리드 작업 트리거를 만들고 여기에 데이터를 전송합니다.

C#

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

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


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

public class SendDataToTheHybridJobTrigger
{
    public static DlpJob SendToHybridJobTrigger(
       string projectId,
       string jobTriggerId,
       string text = null)
    {
        // Instantiate the dlp client.
        var dlp = DlpServiceClient.Create();

        // Construct the hybrid finding details which will be used as metadata with the content.
        // Refer to this for more information: https://cloud.google.com/dlp/docs/reference/rpc/google.privacy.dlp.v2#google.privacy.dlp.v2.Container
        var findingDetails = new HybridFindingDetails
        {
            ContainerDetails = new Container
            {
                FullPath = "10.0.0.2:logs1:aap1",
                RelativePath = "app1",
                RootPath = "10.0.0.2:logs1",
                Type = "System Logs"
            }
        };

        // Construct the hybrid content item using the finding details and text to be inspected.
        var hybridContentItem = new HybridContentItem
        {
            Item = new ContentItem { Value = text ?? "My email is ariel@example.org and name is Ariel." },
            FindingDetails = findingDetails
        };

        var jobTriggerName = new JobTriggerName(projectId, jobTriggerId);

        // Construct the request to activate the Job Trigger.
        var activate = new ActivateJobTriggerRequest
        {
            JobTriggerName = jobTriggerName
        };

        DlpJob triggerJob = null;

        try
        {
            // Call the API to activate the trigger.
            triggerJob = dlp.ActivateJobTrigger(activate);
        }
        catch (RpcException)
        {
            ListDlpJobsRequest listJobsRequest = new ListDlpJobsRequest
            {
                ParentAsLocationName = new LocationName(projectId, "global"),
                Filter = $"trigger_name={jobTriggerName}"
            };

            PagedEnumerable<ListDlpJobsResponse, DlpJob> res = dlp.ListDlpJobs(listJobsRequest);
            foreach (DlpJob j in res)
            {
                triggerJob = j;
            }
        }

        // Construct the request using hybrid content item.
        var request = new HybridInspectJobTriggerRequest
        {
            HybridItem = hybridContentItem,
            JobTriggerName = jobTriggerName
        };

        // Call the API.
        HybridInspectResponse _ = dlp.HybridInspectJobTrigger(request);

        Console.WriteLine($"Hybrid job created successfully. Job name: {triggerJob.Name}");

        return triggerJob;
    }
}

Go

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

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

import (
	"context"
	"fmt"
	"io"
	"log"
	"time"

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

// inspectDataToHybridJobTrigger uses the Data Loss Prevention API to inspect sensitive
// information using Hybrid jobs trigger that scans payloads of data sent from
// virtually any source and stores findings in Google Cloud.
func inspectDataToHybridJobTrigger(w io.Writer, projectID, textToDeIdentify, jobTriggerName string) error {
	// projectId := "your-project-id"
	// jobTriggerName := "your-job-trigger-name"
	// textToDeIdentify := "My email is test@example.org"

	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 the content to be inspected.
	contentItem := &dlppb.ContentItem{
		DataItem: &dlppb.ContentItem_Value{
			Value: textToDeIdentify,
		},
	}

	// Contains metadata to associate with the content.
	// Refer to https://cloud.google.com/dlp/docs/reference/rpc/google.privacy.dlp.v2#container for specifying the paths in container object.
	container := &dlppb.Container{
		Type:         "logging_sys",
		FullPath:     "10.0.0.2:logs1:app1",
		RelativePath: "app1",
		RootPath:     "10.0.0.2:logs1",
		Version:      "1.2",
	}

	// Set the required label.
	labels := map[string]string{
		"env":                           "prod",
		"appointment-bookings-comments": "",
	}

	hybridFindingDetails := &dlppb.HybridFindingDetails{
		ContainerDetails: container,
		Labels:           labels,
	}

	hybridContentItem := &dlppb.HybridContentItem{
		Item:           contentItem,
		FindingDetails: hybridFindingDetails,
	}

	// Activate the job trigger.
	activateJobreq := &dlppb.ActivateJobTriggerRequest{
		Name: jobTriggerName,
	}

	dlpJob, err := client.ActivateJobTrigger(ctx, activateJobreq)
	if err != nil {
		log.Printf("Error from return part %v", err)
		return err
	}
	// Build the hybrid inspect request.
	req := &dlppb.HybridInspectJobTriggerRequest{
		Name:       jobTriggerName,
		HybridItem: hybridContentItem,
	}

	// Send the hybrid inspect request.
	_, err = client.HybridInspectJobTrigger(ctx, req)
	if err != nil {
		return err
	}

	getDlpJobReq := &dlppb.GetDlpJobRequest{
		Name: dlpJob.Name,
	}

	var result *dlppb.DlpJob
	for i := 0; i < 5; i++ {
		// Get DLP job
		result, err = client.GetDlpJob(ctx, getDlpJobReq)
		if err != nil {
			fmt.Printf("Error getting DLP job: %v\n", err)
			return err
		}

		// Check if processed bytes is greater than 0
		if result.GetInspectDetails().GetResult().GetProcessedBytes() > 0 {
			break
		}

		// Wait for 5 seconds before checking again
		time.Sleep(5 * time.Second)
		i++
	}

	fmt.Fprintf(w, "Job Name: %v\n", result.Name)
	fmt.Fprintf(w, "Job State: %v\n", result.State)

	inspectionResult := result.GetInspectDetails().GetResult()
	fmt.Fprint(w, "Findings: \n")
	for _, v := range inspectionResult.GetInfoTypeStats() {
		fmt.Fprintf(w, "Infotype: %v\n", v.InfoType.Name)
		fmt.Fprintf(w, "Likelihood: %v\n", v.GetCount())
	}

	fmt.Fprint(w, "successfully inspected data using hybrid job trigger ")
	return nil
}

Java

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

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


import com.google.api.gax.rpc.InvalidArgumentException;
import com.google.cloud.dlp.v2.DlpServiceClient;
import com.google.privacy.dlp.v2.ActivateJobTriggerRequest;
import com.google.privacy.dlp.v2.Container;
import com.google.privacy.dlp.v2.ContentItem;
import com.google.privacy.dlp.v2.DlpJob;
import com.google.privacy.dlp.v2.GetDlpJobRequest;
import com.google.privacy.dlp.v2.HybridContentItem;
import com.google.privacy.dlp.v2.HybridFindingDetails;
import com.google.privacy.dlp.v2.HybridInspectJobTriggerRequest;
import com.google.privacy.dlp.v2.InfoTypeStats;
import com.google.privacy.dlp.v2.InspectDataSourceDetails;
import com.google.privacy.dlp.v2.JobTriggerName;
import com.google.privacy.dlp.v2.ListDlpJobsRequest;

public class InspectDataToHybridJobTrigger {

  public static void main(String[] args) throws Exception {
    // TODO(developer): Replace these variables before running the sample.
    // The Google Cloud project id to use as a parent resource.
    String projectId = "your-project-id";
    // The job trigger id used to for processing a hybrid job trigger.
    String jobTriggerId = "your-job-trigger-id";
    // The string to de-identify.
    String textToDeIdentify = "My email is test@example.org and my name is Gary.";
    inspectDataToHybridJobTrigger(textToDeIdentify, projectId, jobTriggerId);
  }

  // Inspects data using a hybrid job trigger.
  // Hybrid jobs trigger allows to scan payloads of data sent from virtually any source for
  // sensitive information and then store the findings in Google Cloud.
  public static void inspectDataToHybridJobTrigger(
      String textToDeIdentify, String projectId, String jobTriggerId) throws Exception {
    // 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 dlpClient = DlpServiceClient.create()) {
      // Specify the content to be inspected.
      ContentItem contentItem = ContentItem.newBuilder().setValue(textToDeIdentify).build();

      // Contains metadata to associate with the content.
      // Refer to https://cloud.google.com/dlp/docs/reference/rest/v2/Container for specifying the
      // paths in container object.
      Container container =
          Container.newBuilder()
              .setFullPath("10.0.0.2:logs1:app1")
              .setRelativePath("app1")
              .setRootPath("10.0.0.2:logs1")
              .setType("logging_sys")
              .setVersion("1.2")
              .build();

      HybridFindingDetails hybridFindingDetails =
          HybridFindingDetails.newBuilder().setContainerDetails(container).build();

      HybridContentItem hybridContentItem =
          HybridContentItem.newBuilder()
              .setItem(contentItem)
              .setFindingDetails(hybridFindingDetails)
              .build();

      // Activate the job trigger.
      ActivateJobTriggerRequest activateJobTriggerRequest =
          ActivateJobTriggerRequest.newBuilder()
              .setName(JobTriggerName.of(projectId, jobTriggerId).toString())
              .build();

      DlpJob dlpJob;

      try {
        dlpJob = dlpClient.activateJobTrigger(activateJobTriggerRequest);
      } catch (InvalidArgumentException e) {
        ListDlpJobsRequest request =
            ListDlpJobsRequest.newBuilder()
                .setParent(JobTriggerName.of(projectId, jobTriggerId).toString())
                .setFilter("trigger_name=" + JobTriggerName.of(projectId, jobTriggerId).toString())
                .build();

        // Retrieve the DLP jobs triggered by the job trigger
        DlpServiceClient.ListDlpJobsPagedResponse response = dlpClient.listDlpJobs(request);
        dlpJob = response.getPage().getResponse().getJobs(0);
      }

      // Build the hybrid inspect request.
      HybridInspectJobTriggerRequest request =
          HybridInspectJobTriggerRequest.newBuilder()
              .setName(JobTriggerName.of(projectId, jobTriggerId).toString())
              .setHybridItem(hybridContentItem)
              .build();

      // Send the hybrid inspect request.
      dlpClient.hybridInspectJobTrigger(request);

      // Build a request to get the completed job
      GetDlpJobRequest getDlpJobRequest =
          GetDlpJobRequest.newBuilder().setName(dlpJob.getName()).build();

      DlpJob result = null;

      do {
        result = dlpClient.getDlpJob(getDlpJobRequest);
        Thread.sleep(5000);
      } while (result.getInspectDetails().getResult().getProcessedBytes() <= 0);

      System.out.println("Job status: " + result.getState());
      System.out.println("Job name: " + result.getName());
      // Parse the response and process results.
      InspectDataSourceDetails.Result inspectionResult = result.getInspectDetails().getResult();
      System.out.println("Findings: ");
      for (InfoTypeStats infoTypeStat : inspectionResult.getInfoTypeStatsList()) {
        System.out.println("\tInfoType: " + infoTypeStat.getInfoType().getName());
        System.out.println("\tCount: " + infoTypeStat.getCount() + "\n");
      }
    }
  }
}

Node.js

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

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

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

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

// The project ID to run the API call under.
// const projectId = "your-project-id";

// The string to de-identify
// const string = 'My email is test@example.org';

// Job Trigger ID
// const jobTriggerId = 'your-job-trigger-id';

async function inspectDataToHybridJobTrigger() {
  // Contains metadata to associate with the content.
  const container = {
    full_path: '10.0.0.2:logs1:app1',
    relative_path: 'app1',
    root_path: '10.0.0.2:logs1',
    type: 'logging_sys',
    version: '1.2',
  };

  const labels = {env: 'prod', 'appointment-bookings-comments': ''};

  // Build the hybrid content item.
  const hybridContentItem = {
    item: {value: string},
    findingDetails: {
      containerDetails: container,
      labels,
    },
  };
  let jobName;
  const fullTriggerName = `projects/${projectId}/jobTriggers/${jobTriggerId}`;
  // Activate the job trigger.
  try {
    const response = await dlpClient.activateJobTrigger({
      name: fullTriggerName,
    });
    jobName = response[0].name;
  } catch (err) {
    console.log(err);
    if (err.code === 3) {
      const response = await dlpClient.listDlpJobs({
        parent: fullTriggerName,
        filter: `trigger_name=${fullTriggerName}`,
      });
      jobName = response[0][0].name;
    }
    // Ignore error related to job trigger already active
    if (err.code !== 3) {
      console.log(err.message);
      return;
    }
  }
  // Build the hybrid inspect request.
  const request = {
    name: `projects/${projectId}/jobTriggers/${jobTriggerId}`,
    hybridItem: hybridContentItem,
  };
  // Send the hybrid inspect request.
  await dlpClient.hybridInspectJobTrigger(request);
  // Waiting for a maximum of 15 minutes for the job to get complete.
  let job;
  let numOfAttempts = 30;
  while (numOfAttempts > 0) {
    // Fetch DLP Job status
    [job] = await dlpClient.getDlpJob({name: jobName});

    if (job.state === 'FAILED') {
      console.log('Job Failed, Please check the configuration.');
      return;
    }
    // Check if the job has completed.
    if (job.inspectDetails.result.processedBytes > 0) {
      break;
    }
    // Sleep for a short duration before checking the job status again.
    await new Promise(resolve => {
      setTimeout(() => resolve(), 30000);
    });
    numOfAttempts -= 1;
  }
  // Finish the job once the inspection is complete.
  await dlpClient.finishDlpJob({name: jobName});

  // Print out the results.
  const infoTypeStats = job.inspectDetails.result.infoTypeStats;
  if (infoTypeStats.length > 0) {
    infoTypeStats.forEach(infoTypeStat => {
      console.log(
        `  Found ${infoTypeStat.count} instance(s) of infoType ${infoTypeStat.infoType.name}.`
      );
    });
  } else {
    console.log('No findings.');
  }
}
await inspectDataToHybridJobTrigger();

PHP

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

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


use Google\ApiCore\ApiException;
use Google\Cloud\Dlp\V2\Container;
use Google\Cloud\Dlp\V2\DlpServiceClient;
use Google\Cloud\Dlp\V2\ContentItem;
use Google\Cloud\Dlp\V2\DlpJob\JobState;
use Google\Cloud\Dlp\V2\HybridContentItem;
use Google\Cloud\Dlp\V2\HybridFindingDetails;

/**
 * Inspect data hybrid job trigger.
 * Send data to the hybrid job or hybrid job trigger.
 *
 * @param string $callingProjectId  The Google Cloud project id to use as a parent resource.
 * @param string $string            The string to inspect (will be treated as text).
 */

function inspect_send_data_to_hybrid_job_trigger(
    // TODO(developer): Replace sample parameters before running the code.
    string $callingProjectId,
    string $jobTriggerId,
    string $string
): void {
    // Instantiate a client.
    $dlp = new DlpServiceClient();

    $content = (new ContentItem())
        ->setValue($string);

    $container = (new Container())
        ->setFullPath('10.0.0.2:logs1:app1')
        ->setRelativePath('app1')
        ->setRootPath('10.0.0.2:logs1')
        ->setType('logging_sys')
        ->setVersion('1.2');

    $findingDetails = (new HybridFindingDetails())
        ->setContainerDetails($container)
        ->setLabels([
            'env' => 'prod',
            'appointment-bookings-comments' => ''
        ]);

    $hybridItem = (new HybridContentItem())
        ->setItem($content)
        ->setFindingDetails($findingDetails);

    $parent = "projects/$callingProjectId/locations/global";
    $name = "projects/$callingProjectId/locations/global/jobTriggers/" . $jobTriggerId;

    $triggerJob = null;
    try {
        $triggerJob = $dlp->activateJobTrigger($name);
    } catch (ApiException $e) {
        $result = $dlp->listDlpJobs($parent, ['filter' => 'trigger_name=' . $name]);
        foreach ($result as $job) {
            $triggerJob = $job;
        }
    }

    $dlp->hybridInspectJobTrigger($name, [
        'hybridItem' => $hybridItem,
    ]);

    $numOfAttempts = 10;
    do {
        printf('Waiting for job to complete' . PHP_EOL);
        sleep(10);
        $job = $dlp->getDlpJob($triggerJob->getName());
        if ($job->getState() != JobState::RUNNING) {
            break;
        }
        $numOfAttempts--;
    } while ($numOfAttempts > 0);

    // Print finding counts.
    printf('Job %s status: %s' . PHP_EOL, $job->getName(), JobState::name($job->getState()));
    switch ($job->getState()) {
        case JobState::DONE:
            $infoTypeStats = $job->getInspectDetails()->getResult()->getInfoTypeStats();
            if (count($infoTypeStats) === 0) {
                printf('No findings.' . PHP_EOL);
            } else {
                foreach ($infoTypeStats as $infoTypeStat) {
                    printf(
                        '  Found %s instance(s) of infoType %s' . PHP_EOL,
                        $infoTypeStat->getCount(),
                        $infoTypeStat->getInfoType()->getName()
                    );
                }
            }
            break;
        case JobState::FAILED:
            printf('Job %s had errors:' . PHP_EOL, $job->getName());
            $errors = $job->getErrors();
            foreach ($errors as $error) {
                var_dump($error->getDetails());
            }
            break;
        case JobState::PENDING:
            printf('Job has not completed. Consider a longer timeout or an asynchronous execution model' . PHP_EOL);
            break;
        default:
            printf('Unexpected job state. Most likely, the job is either running or has not yet started.');
    }
}

Python

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

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

import time

import google.cloud.dlp

def inspect_data_to_hybrid_job_trigger(
    project: str,
    trigger_id: str,
    content_string: str,
) -> None:
    """
    Uses the Data Loss Prevention API to inspect sensitive information
    using Hybrid jobs trigger that scans payloads of data sent from
    virtually any source and stores findings in Google Cloud.
    Args:
        project: The Google Cloud project id to use as a parent resource.
        trigger_id: The job trigger identifier for hybrid job trigger.
        content_string: The string to inspect.
    """

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

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

    # Construct the container details that contains metadata to be
    # associated with the content. For more details, please refer to
    # https://cloud.google.com/dlp/docs/reference/rest/v2/Container
    container_details = {
        "full_path": "10.0.0.2:logs1:app1",
        "relative_path": "app1",
        "root_path": "10.0.0.2:logs1",
        "type_": "logging_sys",
        "version": "1.2",
    }

    # Construct hybrid inspection configuration.
    hybrid_config = {
        "item": item,
        "finding_details": {
            "container_details": container_details,
            "labels": {
                "env": "prod",
                "appointment-bookings-comments": "",
            },
        },
    }

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

    # Activate the job trigger.
    dlp_job = dlp.activate_job_trigger(request={"name": trigger_id})

    # Call the API.
    dlp.hybrid_inspect_job_trigger(
        request={
            "name": trigger_id,
            "hybrid_item": hybrid_config,
        }
    )

    # Get inspection job details.
    job = dlp.get_dlp_job(request={"name": dlp_job.name})

    # Wait for dlp job to get finished.
    while job.inspect_details.result.processed_bytes <= 0:
        time.sleep(5)
        job = dlp.get_dlp_job(request={"name": dlp_job.name})

    # Print the results.
    print(f"Job name: {dlp_job.name}")
    if job.inspect_details.result.info_type_stats:
        for finding in job.inspect_details.result.info_type_stats:
            print(f"Info type: {finding.info_type.name}; Count: {finding.count}")
    else:
        print("No findings.")

일반적인 하이브리드 검사 시나리오

다음 섹션에서는 하이브리드 검사의 일반 용도와 해당 워크플로를 설명합니다.

일회성 스캔 수행

분기별 데이터베이스 확인의 일부로 Google Cloud 외부의 데이터베이스에 대한 일회성 스캔을 실행합니다.

  1. Google Cloud 콘솔 또는 DLP API를 사용하여 하이브리드 작업을 만듭니다.

  2. projects.locations.dlpJobs.hybridInspect를 호출하여 작업에 데이터를 전송합니다. 더 많은 데이터를 검사하려면 이 단계를 필요한 횟수만큼 반복합니다.

  3. 검사할 데이터를 전송한 후 projects.locations.dlpJobs.finish 메서드를 호출합니다.

    Sensitive Data Protection이 projects.locations.dlpJobs.create 요청에 지정된 작업을 수행합니다.

지속적인 모니터링 구성

Sensitive Data Protection에서 기본적으로 지원하지 않는 데이터베이스에 매일 추가되는 모든 새 콘텐츠를 모니터링합니다.

  1. Google Cloud 콘솔 또는 DLP API를 사용하여 하이브리드 작업 트리거를 만듭니다.

  2. projects.locations.jobTriggers.activate 메서드를 호출하여 작업 트리거를 활성화합니다.

  3. projects.locations.jobTriggers.hybridInspect를 호출하여 작업 트리거에 데이터를 전송합니다. 더 많은 데이터를 검사하려면 이 단계를 필요한 횟수만큼 반복합니다.

이 경우 projects.locations.dlpJobs.finish 메서드를 호출할 필요가 없습니다. Sensitive Data Protection는 전송 중인 데이터를 자동으로 파티션으로 나눕니다. 작업 트리거가 활성 상태이면 하이브리드 작업 트리거를 만들 때 지정한 작업이 하루가 끝날 때 Sensitive Data Protection에서 수행됩니다.

데이터베이스로 들어오는 데이터 스캔

데이터베이스로 들어오는 데이터를 스캔하고 데이터의 파티션 나누기 방법을 제어합니다. 작업 트리거의 각 작업은 단일 파티션입니다.

  1. Google Cloud 콘솔 또는 DLP API를 사용하여 하이브리드 작업 트리거를 만듭니다.

  2. projects.locations.jobTriggers.activate 메서드를 호출하여 작업 트리거를 활성화합니다.

    시스템이 단일 작업의 작업 ID를 반환합니다. 다음 단계에서 이 작업 ID가 필요합니다.

  3. projects.locations.dlpJobs.hybridInspect를 호출하여 작업에 데이터를 전송합니다.

    이 경우 작업 트리거 대신 작업에 데이터를 전송합니다. 이 접근 방식을 사용하면 검사를 위해 전송하는 데이터의 파티션 나누기 방법을 제어할 수 있습니다. 현재 파티션에서 검사할 데이터를 더 추가하려면 이 단계를 반복합니다.

  4. 작업에 데이터를 전송한 후 projects.locations.dlpJobs.finish 메서드를 호출합니다.

    Sensitive Data Protection이 projects.locations.jobTriggers.create 요청에 지정된 작업을 수행합니다.

  5. 다음 파티션에 대해 다른 작업을 만들려면 작업 트리거를 다시 활성화한 다음 데이터를 결과 작업으로 전송합니다.

프록시에서 트래픽 모니터링

두 커스텀 애플리케이션 사이에 설치된 프록시에서 트래픽을 모니터링합니다.

  1. Google Cloud 콘솔 또는 DLP API를 사용하여 하이브리드 작업 트리거를 만듭니다.

  2. projects.locations.jobTriggers.activate 메서드를 호출하여 작업 트리거를 활성화합니다.

  3. projects.locations.jobTriggers.hybridInspect를 호출하여 작업 트리거에 데이터를 전송합니다. 더 많은 데이터를 검사하려면 이 단계를 필요한 횟수만큼 반복합니다.

    모든 네트워크 트래픽에 대해 이 요청을 무제한으로 호출할 수 있습니다. 각 요청에 메타데이터를 포함해야 합니다.

이 경우 projects.locations.dlpJobs.finish 메서드를 호출할 필요가 없습니다. Sensitive Data Protection는 전송 중인 데이터를 자동으로 파티션으로 나눕니다. 작업 트리거가 활성 상태이면 하이브리드 작업 트리거를 만들 때 지정한 작업이 하루가 끝날 때 Sensitive Data Protection에서 수행됩니다.

다음 단계