ציון מיקומי עיבוד

האפשרות לציין אזור שבו יתבצעו הפעולות של 'הגנה על מידע רגיש' מאפשרת לכם לשלוט במיקום שבו יעובדו הנתונים הרגישים הפוטנציאליים שלכם. במאמר הזה מוסבר המושג 'מיקום העיבוד של Sensitive Data Protection' ומוסבר איך לציין אזור.

רשימה של אזורים נתמכים ואזורים מרובים זמינה במאמר מיקומים של Sensitive Data Protection.

מידע על אזורים ועל אזורים מרובים

אזור – מקום גיאוגרפי ספציפי, כמו מערב ארצות הברית או צפון-מזרח אסיה. מיקום במספר אזורים (או פשוט מספר אזורים) הוא אזור גיאוגרפי נרחב, כמו האיחוד האירופי, שכולל שני אזורים גיאוגרפיים או יותר.

שיקולים בקשר למיקום

מיקום טוב מאזן בין זמן האחזור, הזמינות ועלויות רוחב הפס.

  • כדאי להשתמש באזור כדי לבצע אופטימיזציה של זמן האחזור ורוחב הפס של הרשת.

  • משתמשים במרחב רב-אזורי כשרוצים לעבד נתונים שמגיעים מחוץ לרשת של Google ומתפלגים על פני אזורים גיאוגרפיים גדולים, או כשרוצים את הזמינות הגבוהה יותר שמתקבלת מיתירות באזורים שונים.

  • בדרך כלל, כדאי לעבד את הנתונים במיקום שנוח לכם או שרוב המשתמשים של הנתונים נמצאים בו.

  • אם הארגון שלכם נדרש לשמור נתונים במעבר במיקום מסוים, אתם צריכים להשתמש רק באזורים או במספר אזורים שתומכים בנקודות קצה אזוריות. במקרה כזה, צריך להשתמש ב-Cloud Data Loss Prevention API, כי נקודות הקצה האזוריות של Sensitive Data Protection לא זמינות לשימוש עם מסוףGoogle Cloud .

ציון אזור

אופן ציון אזור העיבוד תלוי בסוג נקודת הקצה שאליה נשלחת הבקשה – נקודת קצה גלובלית או נקודת קצה אזורית. סוג נקודת הקצה שבוחרים תלוי בדרישה לשמירת נתונים במעבר באזור מסוים. מידע נוסף זמין במאמר בנושא נקודות קצה (endpoint) גלובליות ואזוריות של Sensitive Data Protection.

ציון אזור בבקשה לנקודת הקצה הגלובלית

המסוף

כשמגדירים את הפעולה של Sensitive Data Protection, צריך לבחור אזור.

לדוגמה, כשיוצרים טריגר להפעלת משימה, בוחרים מיקום מהתפריט מיקום המשאב, כמו שמוצג כאן:

אם מיקום העיבוד לא חשוב לכם, תוכלו להשתמש באזור Global ו-Google תבחר את המיקום שבו העיבוד יתבצע. Global היא ברירת המחדל של האזור.

REST

מוסיפים את פרטי האזור לכתובת ה-URL של נקודת הקצה של הבקשה. אם מיקום העיבוד לא חשוב לכם, תוכלו להשתמש באזור global ו-Google תבחר את המיקום שבו יתבצע העיבוד. שימו לב שכל משאב שנוצר על ידי בקשה שמצוין בה אזור global מאוחסן באזור global.

הנה כמה דוגמאות לבקשות לנקודת הקצה הגלובלית.

שימוש באזור הגלובלי

לשתי הבקשות הבאות יש את אותה השפעה. אם לא מציינים אזור, זה כמו לציין locations/global/.

POST https://www.googleapis.com/dlp/v2/projects/PROJECT_ID/locations/global/content:inspect
POST https://www.googleapis.com/dlp/v2/projects/PROJECT_ID/content:inspect

שימוש באזור ספציפי

כדי לציין אזור לעיבוד, מוסיפים לכתובת ה-URL של המשאב את המחרוזת locations/ ואחריה את שם האזור.

POST https://www.googleapis.com/dlp/v2/projects/PROJECT_ID/locations/us-west2/content:inspect

ציון אזור בבקשה לנקודת קצה אזורית

המסוף

ב-Sensitive Data Protection, אי אפשר להשתמש בנקודות קצה אזוריות עם מסוף Google Cloud .

C#

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


using System;
using System.Collections.Generic;
using System.Linq;
using Google.Api.Gax.ResourceNames;
using Google.Cloud.Dlp.V2;
using static Google.Cloud.Dlp.V2.InspectConfig.Types;

public class InspectStringRep
{
    public static InspectContentResponse Inspect(
        string projectId,
        string repLocation,
        string dataValue,
        string minLikelihood,
        int maxFindings,
        bool includeQuote,
        IEnumerable<InfoType> infoTypes,
        IEnumerable<CustomInfoType> customInfoTypes)
    {
        var inspectConfig = new InspectConfig
        {
            MinLikelihood = (Likelihood)Enum.Parse(typeof(Likelihood), minLikelihood, true),
            Limits = new FindingLimits
            {
                MaxFindingsPerRequest = maxFindings
            },
            IncludeQuote = includeQuote,
            InfoTypes = { infoTypes },
            CustomInfoTypes = { customInfoTypes }
        };
        var request = new InspectContentRequest
        {
            Parent = new LocationName(projectId, repLocation).ToString(),
            Item = new ContentItem
            {
                Value = dataValue
            },
            InspectConfig = inspectConfig
        };

        var dlp = new DlpServiceClientBuilder
        {
            Endpoint = $"dlp.{repLocation}.rep.googleapis.com"
        }.Build();

        var response = dlp.InspectContent(request);

        PrintResponse(includeQuote, response);

        return response;
    }

    private static void PrintResponse(bool includeQuote, InspectContentResponse response)
    {
        var findings = response.Result.Findings;
        if (findings.Any())
        {
            Console.WriteLine("Findings:");
            foreach (var finding in findings)
            {
                if (includeQuote)
                {
                    Console.WriteLine($"  Quote: {finding.Quote}");
                }
                Console.WriteLine($"  InfoType: {finding.InfoType}");
                Console.WriteLine($"  Likelihood: {finding.Likelihood}");
            }
        }
        else
        {
            Console.WriteLine("No findings.");
        }
    }
}

Go

מידע על התקנת ספריית הלקוח של Sensitive Data Protection והשימוש בה מופיע במאמר ספריות הלקוח של Sensitive Data Protection.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

import (
	"context"
	"fmt"
	"io"

	dlp "cloud.google.com/go/dlp/apiv2"
	"cloud.google.com/go/dlp/apiv2/dlppb"
	"google.golang.org/api/option"
)

// inspectString inspects the a given string, and prints results.
func inspectStringRep(w io.Writer, projectID, repLocation, textToInspect string) error {
	// projectID := "my-project-id"
	// textToInspect := "My name is Gary and my email is gary@example.com"
	ctx := context.Background()

	// Assemble the regional endpoint url using provided rep location
	repEndpoint := fmt.Sprintf("dlp.%s.rep.googleapis.com:443", repLocation)

	// Initialize client.
	client, err := dlp.NewClient(ctx, option.WithEndpoint(repEndpoint))
	if err != nil {
		return err
	}
	defer client.Close() // Closing the client safely cleans up background resources.

	// Create and send the request.
	req := &dlppb.InspectContentRequest{
		Parent: fmt.Sprintf("projects/%s/locations/%s", projectID, repLocation),
		Item: &dlppb.ContentItem{
			DataItem: &dlppb.ContentItem_Value{
				Value: textToInspect,
			},
		},
		InspectConfig: &dlppb.InspectConfig{
			InfoTypes: []*dlppb.InfoType{
				{Name: "PHONE_NUMBER"},
				{Name: "EMAIL_ADDRESS"},
				{Name: "CREDIT_CARD_NUMBER"},
			},
			IncludeQuote: true,
		},
	}
	resp, err := client.InspectContent(ctx, req)
	if err != nil {
		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.

כדי לבצע אימות ב-Sensitive Data Protection, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


import com.google.cloud.dlp.v2.DlpServiceClient;
import com.google.cloud.dlp.v2.DlpServiceSettings;
import com.google.privacy.dlp.v2.ByteContentItem;
import com.google.privacy.dlp.v2.ByteContentItem.BytesType;
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.LocationName;
import com.google.protobuf.ByteString;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class InspectStringRep {

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

  // Inspects the provided text.
  public static void inspectString(String projectId, String repLocation, String textToInspect)
      throws IOException {
    // Assemble the regional endpoint url using provided rep location
    String repEndpoint = String.format("dlp.%s.rep.googleapis.com:443", repLocation);
    DlpServiceSettings settings = DlpServiceSettings.newBuilder()
        .setEndpoint(repEndpoint)
        .build();
    // 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(settings)) {
      // Specify the type and content to be inspected.
      ByteContentItem byteItem =
          ByteContentItem.newBuilder()
              .setType(BytesType.TEXT_UTF8)
              .setData(ByteString.copyFromUtf8(textToInspect))
              .build();
      ContentItem item = ContentItem.newBuilder().setByteItem(byteItem).build();

      // Specify the type of info the inspection will look for.
      List<InfoType> infoTypes = new ArrayList<>();
      // See https://cloud.google.com/dlp/docs/infotypes-reference for complete list of info types
      for (String typeName : new String[] {"PHONE_NUMBER", "EMAIL_ADDRESS", "CREDIT_CARD_NUMBER"}) {
        infoTypes.add(InfoType.newBuilder().setName(typeName).build());
      }

      // Construct the configuration for the Inspect request.
      InspectConfig config =
          InspectConfig.newBuilder().addAllInfoTypes(infoTypes).setIncludeQuote(true).build();

      // Construct the Inspect request to be sent by the client.
      InspectContentRequest request =
          InspectContentRequest.newBuilder()
              .setParent(LocationName.of(projectId, repLocation).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());
      }
    }
  }
}

REST

בדוגמה הבאה נשלחת בקשת content.inspect לנקודת קצה אזורית. כל הנתונים שמצורפים לבקשה הזו נשארים באזור שצוין בזמן ההעברה, השימוש ובמצב מנוחה.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • REGION: אזור שבו זמין endpoint אזורי ל-Sensitive Data Protection, לדוגמה: us-west2. רשימה מלאה של האזורים זמינה במאמר מיקומים של Sensitive Data Protection.
  • PROJECT_ID: מזהה הפרויקט ב- Google Cloud . מזהי פרויקטים הם מחרוזות אלפאנומריות, כמו example-project.

ה-method של ה-HTTP וכתובת ה-URL:

POST https://dlp.REGION.rep.googleapis.com/v2/projects/PROJECT_ID/locations/REGION/content:inspect

תוכן בקשת JSON:

{
  "inspectConfig": {
    "infoTypes": [
      {
        "name": "CREDIT_CARD_NUMBER"
      }
    ]
  },
  "item": {
    "value": "hi, my ccn is 4111111111111111"
  }
}

כדי לשלוח את הבקשה צריך להרחיב אחת מהאפשרויות הבאות:

אתם אמורים לקבל תגובת JSON שדומה לזו:

{
  "result": {
    "findings": [
      {
        "infoType": {
          "name": "CREDIT_CARD_NUMBER",
          "sensitivityScore": {
            "score": "SENSITIVITY_HIGH"
          }
        },
        "likelihood": "LIKELY",
        "location": {
          "byteRange": {
            "start": "14",
            "end": "30"
          },
          "codepointRange": {
            "start": "14",
            "end": "30"
          }
        },
        "createTime": "2024-08-09T19:54:13.348Z",
        "findingId": "2024-08-09T19:54:13.352163Z4747901452516738787"
      }
    ]
  }
}

שיקולים לגבי מיקום משותף

כשסורקים מאגר אחסון כמו Cloud Storage או BigQuery, צריך לציין בבקשת Sensitive Data Protection את אותו מיקום שבו נמצא המאגר שסורקים. לדוגמה, אם מערך הנתונים ב-BigQuery נמצא במיקום במספר אזורים באיחוד האירופי, צריך לציין את המיקום במספר אזורים באיחוד האירופי (europe) כשמגדירים את העבודה של Sensitive Data Protection.

אם לא תמקמו את הבקשה ל-Sensitive Data Protection באותו מיקום עם מאגר האחסון שאתם סורקים, יכול להיות שהעיבוד של הבקשה יפוצל בין מיקום הנתונים לבין המיקום שצוין בבקשה.

המאמרים הבאים