Memeriksa teks sensitif menggunakan DLP API
Pelajari cara memindai string contoh untuk menemukan informasi sensitif menggunakan Cloud Data Loss Prevention API dari Sensitive Data Protection dan JSON.
Jika ingin mengikuti panduan langkah demi langkah untuk tugas ini langsung di Konsol Google Cloud, klik Pandu saya:
Sebelum memulai
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
Create or select a Google Cloud project.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_ID
with a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_ID
with your Google Cloud project name.
-
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the DLP API:
gcloud services enable dlp.googleapis.com
-
Grant roles to your user account. Run the following command once for each of the following IAM roles:
roles/dlp.user
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE
- Replace
PROJECT_ID
with your project ID. -
Replace
USER_IDENTIFIER
with the identifier for your user account. For example,user:myemail@example.com
. - Replace
ROLE
with each individual role.
- Replace
- Install the Google Cloud CLI.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
Create or select a Google Cloud project.
-
Create a Google Cloud project:
gcloud projects create PROJECT_ID
Replace
PROJECT_ID
with a name for the Google Cloud project you are creating. -
Select the Google Cloud project that you created:
gcloud config set project PROJECT_ID
Replace
PROJECT_ID
with your Google Cloud project name.
-
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the DLP API:
gcloud services enable dlp.googleapis.com
-
Grant roles to your user account. Run the following command once for each of the following IAM roles:
roles/dlp.user
gcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE
- Replace
PROJECT_ID
with your project ID. -
Replace
USER_IDENTIFIER
with the identifier for your user account. For example,user:myemail@example.com
. - Replace
ROLE
with each individual role.
- Replace
Memeriksa string untuk informasi sensitif
Bagian ini menunjukkan cara mengonfigurasi DLP API untuk memindai
contoh teks menggunakan metode REST
projects.content.inspect
.
Bagian ini mengharuskan Anda menyimpan contoh permintaan dalam file JSON. Jika menggunakan Cloud Shell, Anda dapat menggunakan Editor Cloud Shell untuk membuat file. Untuk meluncurkan editor, klik
Open Editor di toolbar jendela Cloud Shell.Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:
-
PROJECT_ID
: ID project Google Cloud Anda. Project ID adalah string alfanumerik, sepertimy-project
.
Metode HTTP dan URL:
POST https://dlp.googleapis.com/v2/projects/PROJECT_ID/content:inspect
Meminta isi JSON:
{ "item": { "value": "My phone number is (800) 555-0123." }, "inspectConfig": { "infoTypes": [ { "name": "PHONE_NUMBER" }, { "name": "US_TOLLFREE_PHONE_NUMBER" } ], "minLikelihood": "POSSIBLE", "limits": { "maxFindingsPerItem": 0 }, "includeQuote": true } }
Untuk mengirim permintaan Anda, perluas salah satu opsi berikut:
Anda akan melihat respons JSON seperti berikut:
{ "result": { "findings": [ { "quote": "(800) 555-0123", "infoType": { "name": "US_TOLLFREE_PHONE_NUMBER" }, "likelihood": "LIKELY", "location": { "byteRange": { "start": "19", "end": "33" }, "codepointRange": { "start": "19", "end": "33" } }, "createTime": "2022-09-23T01:53:05.303Z", "findingId": "2022-09-23T01:53:05.306348Z5328915744504121862" } ] } }
Pembersihan
Agar tidak menimbulkan biaya pada akun Google Cloud Anda untuk resource yang digunakan pada halaman ini, hapus project Google Cloud yang berisi resource tersebut.
Menghapus project
Jika Anda membuat project baru untuk panduan memulai ini, cara termudah untuk mencegah biaya tambahan adalah dengan menghapus project tersebut.
Delete a Google Cloud project:
gcloud projects delete PROJECT_ID
Mencabut kredensial Anda
Optional: Revoke credentials from the gcloud CLI.
gcloud auth revoke
Langkah selanjutnya
Untuk mulai memeriksa teks dan gambar guna menemukan data sensitif, lihat Panduan cara.
Untuk lebih memahami inspeksi, penyamaran, infoTypes, dan kemungkinan, lihat Konsep.
Pelajari DLP API lebih lanjut.