Memeriksa teks sensitif menggunakan DLP API
Pelajari cara memindai string sampel untuk menemukan informasi sensitif menggunakan Cloud Data Loss Prevention API dari Sensitive Data Protection dan JSON.
Untuk mengikuti panduan langkah demi langkah tugas ini langsung di Google Cloud konsol, 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.
-
Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.
-
Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:
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.
-
-
Verify 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 the following:
PROJECT_ID
: your project ID.USER_IDENTIFIER
: the identifier for your user account—for example,myemail@example.com
.ROLE
: the IAM role that you grant to your user account.
-
Install the Google Cloud CLI.
-
Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.
-
Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:
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.
-
-
Verify 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 the following:
PROJECT_ID
: your project ID.USER_IDENTIFIER
: the identifier for your user account—for example,myemail@example.com
.ROLE
: the IAM role that you grant to your user account.
-
PROJECT_ID
: ID project Google Cloud Anda. Project ID adalah string alfanumerik, sepertimy-project
. -
Optional: Revoke credentials from the gcloud CLI.
gcloud auth revoke
Untuk mulai memeriksa teks dan gambar terkait data sensitif, lihat Panduan cara penggunaan.
Untuk lebih memahami inspeksi, penyensoran, infoType, dan kemungkinan, lihat Konsep.
Pelajari DLP API lebih lanjut.
Memeriksa string untuk menemukan informasi sensitif
Bagian ini menunjukkan cara mengonfigurasi DLP API untuk memindai
contoh teks menggunakan metode REST projects.content.inspect
.
Di bagian ini, Anda harus 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:
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 di 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