Properly managing sensitive data that is stored in a storage repository starts with storage classification: identifying where your sensitive data is in the repository, what type of sensitive data it is, and how it's being used. This knowledge can help you properly set access control and sharing permissions, and it can be part of an ongoing monitoring plan.
Sensitive Data Protection can detect and classify sensitive data stored in a Cloud Storage location, Datastore kind, or BigQuery table. When scanning files in Cloud Storage locations, Sensitive Data Protection supports scanning of binary, text, image, Microsoft Word, Microsoft Excel, Microsoft Powerpoint, PDF, and Apache Avro files. Files of types that are unrecognized are scanned as binary files. For more information about supported files types, see Supported file types.
To inspect storage and databases for sensitive data, you specify the location of the data and the type of sensitive data that Sensitive Data Protection should look for. Sensitive Data Protection initiates a job that inspects the data at the given location, and then it makes available details about infoTypes found in the content, likelihood values, and more.
You can set up inspection of storage and databases using Sensitive Data Protection in the Google Cloud console, via the RESTful DLP API, or programmatically using a Sensitive Data Protection client library in one of several languages.
This topic includes:
- Best practices for setting up scans of Google Cloud storage repositories and databases.
- Instructions for setting up an inspection scan using Sensitive Data Protection in the Google Cloud console, and (optionally) for scheduling periodic repeating inspection scans.
- JSON and code samples for each Google Cloud storage repository type: (Cloud Storage, Firestore in Datastore mode (Datastore), and BigQuery).
- A detailed overview of the configuration options for scan jobs.
- Instructions for how to retrieve scan results and how to manage the scan jobs that are created from each successful request.
Best practices
Identify and prioritize scanning
It's important to first evaluate your assets and specify which have the highest priority for scanning. When just getting started you may have a large backlog of data that needs classification, and it will be impossible to scan it all immediately. Choose data initially that poses the highest potential risk—for example, data that is frequently accessed, widely accessible, or unknown.
Ensure that Sensitive Data Protection can access your data
Sensitive Data Protection must be able to access data to be scanned. Be sure that the Sensitive Data Protection service account is permitted to read your resources.
Limit the scope of your first scans
For best results, limit the scope of your first jobs instead of scanning all of
your data. Start with one table, one bucket, or a few files and use
sampling. By limiting the scope of your
first scans, you can better
determine what detectors to enable and what exclusion
rules might be needed to
reduce false positives so that your findings will be more meaningful. Avoid
turning on all infoTypes if you don't need them all, as false positives or
unusable findings may make it harder to assess your risk. While useful in
certain scenarios, infoTypes such as DATE, TIME, DOMAIN_NAME, and URL
match on a broad range of findings and may not be useful to turn on for large
data scans.
When sampling a structured file—such as a CSV, TSV, or Avro file—make sure that the sample size is big enough to cover the file's full header and a row of data. For more information, see Scanning structured files in structured parsing mode.
Schedule your scans
Use Sensitive Data Protection job triggers to automatically run scans and generate findings daily, weekly, or quarterly. These scans can also be configured to only inspect data that has changed since the last scan, which can save time and reduce costs. Running scans on a regular basis can help you identify trends or anomalies in your scan results.
Job latency
There are no service level objectives (SLO) guaranteed for jobs and job triggers. Latency is affected by several factors, including the amount of data to scan, the storage repository being scanned, the type and number of infoTypes you are scanning for, the region where the job is processed, and the computing resources available in that region. Therefore, the latency of inspection jobs can't be determined in advance.
To help reduce job latency, you can try the following:
- If sampling is available for your job or job trigger, enable it.
Avoid enabling infoTypes that you don't need. Although the following are useful in certain scenarios, these infoTypes can make requests run much more slowly than requests that don't include them:
PERSON_NAMEFEMALE_NAMEMALE_NAMEFIRST_NAMELAST_NAMEDATE_OF_BIRTHLOCATIONSTREET_ADDRESSORGANIZATION_NAME
Always specify infoTypes explicitly. Do not use an empty infoTypes list.
If possible, use a different processing region.
If you're still having latency issues with jobs after trying these techniques,
consider using
content.inspect or
content.deidentify
requests instead of jobs. These methods are covered under the Service Level
Agreement. For more information, see Sensitive Data Protection Service Level
Agreement.
Before you begin
The instructions provided in this topic assume the following:
You have enabled billing.
You have enabled Sensitive Data Protection.
Storage classification requires the following OAuth scope:
https://www.googleapis.com/auth/cloud-platform. For more information, see
Authenticating to the DLP API.
Inspect a Cloud Storage location
You can set up a Sensitive Data Protection inspection of a Cloud Storage location using the Google Cloud console, the DLP API via REST or RPC requests, or programmatically in several languages using a client library. For information about the parameters included with the following JSON and code samples, see "Configure storage inspection," later in this topic.
Sensitive Data Protection relies on file extensions and media (MIME) types to identify the types
of the files to be scanned and the scanning modes to
apply. For example, Sensitive Data Protection scans a .txt file in
plain text mode, even if the file is structured as a CSV file, which is normally
scanned in structured parsing mode.
To set up a scan job of a Cloud Storage bucket using Sensitive Data Protection:
Console
This section describes how to inspect a Cloud Storage bucket or folder. If you also want Sensitive Data Protection to create a de-identified copy of your data, see De-identify sensitive data stored in Cloud Storage using the Google Cloud console.
In the Sensitive Data Protection section of the Google Cloud console, go to the Create job or job trigger page.
Enter the Sensitive Data Protection job information and click Continue to complete each step:
For Choose input data, name the job by entering a value in the Name field. In Location, choose Cloud Storage from the Storage type menu, and then enter the location of the data to scan. The Sampling section is pre-configured to run a sample scan against your data. You can adjust the Percentage of objects scanned within bucket field to save resources if you have a large amount of data. For more details, see Choose input data.
(Optional) For Configure detection, you can configure what types of data to look for, called "infoTypes." You can select from the list of pre-defined infoTypes, or you can select a template if one exists. For more details, see Configure detection.
For Add actions, select one or more actions for Sensitive Data Protection to take after the job completes. For more information, see Enable inspection or risk analysis actions.
After you select actions, click Continue.
(Optional) For Schedule, to run the scan one time only, leave the menu set to None. To schedule scans to run periodically, click Create a trigger to run the job on a periodic schedule. For more details, see Schedule.
Click Create.
After the Sensitive Data Protection job completes, you are redirected to the job details page and notified via email. You can view the results of the inspection on the job details page.
(Optional) If you chose to publish Sensitive Data Protection findings to BigQuery, on the Job details page, click View Findings in BigQuery to open the table in the BigQuery web UI. You can then query the table and analyze your findings. For more information on querying your results in BigQuery, see Querying Sensitive Data Protection findings in BigQuery.
Protocol
Following is sample JSON that can be sent in a POST request to the specified Sensitive Data Protection REST endpoint. This example JSON demonstrates how to use the DLP API to inspect Cloud Storage buckets. For information about the parameters included with the request, see "Configure storage inspection," later in this topic.
You can quickly try this out in the APIs Explorer on the reference page for
content.inspect:
Keep in mind that a successful request, even in APIs Explorer, will create a new scan job. For information about how to control scan jobs, see "Retrieve inspection results," later in this topic. For general information about using JSON to send requests to the DLP API, see the JSON quickstart.
JSON input:
POST https://dlp.googleapis.com/v2/projects/[PROJECT-ID]/dlpJobs?key={YOUR_API_KEY}
{
"inspectJob":{
"storageConfig":{
"cloudStorageOptions":{
"fileSet":{
"url":"gs://[BUCKET-NAME]/*"
},
"bytesLimitPerFile":"1073741824"
},
"timespanConfig":{
"startTime":"2017-11-13T12:34:29.965633345Z",
"endTime":"2018-01-05T04:45:04.240912125Z"
}
},
"inspectConfig":{
"infoTypes":[
{
"name":"PHONE_NUMBER"
}
],
"excludeInfoTypes":false,
"includeQuote":true,
"minLikelihood":"LIKELY"
},
"actions":[
{
"saveFindings":{
"outputConfig":{
"table":{
"projectId":"[PROJECT-ID]",
"datasetId":"[DATASET-ID]"
}
}
}
}
]
}
}
JSON output:
{
"name":"projects/[PROJECT-ID]/dlpJobs/[JOB-ID]",
"type":"INSPECT_JOB",
"state":"PENDING",
"inspectDetails":{
"requestedOptions":{
"snapshotInspectTemplate":{
},
"jobConfig":{
"storageConfig":{
"cloudStorageOptions":{
"fileSet":{
"url":"gs://[BUCKET-NAME]/*"
},
"bytesLimitPerFile":"1073741824"
},
"timespanConfig":{
"startTime":"2017-11-13T12:34:29.965633345Z",
"endTime":"2018-01-05T04:45:04.240912125Z"
}
},
"inspectConfig":{
"infoTypes":[
{
"name":"PHONE_NUMBER"
}
],
"minLikelihood":"LIKELY",
"limits":{
},
"includeQuote":true
},
"actions":[
{
"saveFindings":{
"outputConfig":{
"table":{
"projectId":"[PROJECT-ID]",
"datasetId":"[DATASET-ID]",
"tableId":"[NEW-TABLE-ID]"
}
}
}
}
]
}
}
},
"createTime":"2018-11-07T18:01:14.225Z"
}
Java
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
To learn how to install and use the client library for Sensitive Data Protection, see Sensitive Data Protection client libraries.
To authenticate to Sensitive Data Protection, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.