Inspecionar texto confidencial usando o Node.js

Saiba como verificar se há informações sensíveis em uma string de amostra usando a API Cloud Data Loss Prevention da Proteção de dados sensíveis, a Google Cloud CLI e o Node.js.


Para seguir as instruções passo a passo desta tarefa diretamente no console do Google Cloud, clique em Orientação:

Orientações


Antes de começar

  1. 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.
  2. Install the Google Cloud CLI.
  3. To initialize the gcloud CLI, run the following command:

    gcloud init
  4. 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.

  5. Make sure that billing is enabled for your Google Cloud project.

  6. Enable the DLP API:

    gcloud services enable dlp.googleapis.com
  7. Create local authentication credentials for your user account:

    gcloud auth application-default login
  8. 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_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.
  9. Install the Google Cloud CLI.
  10. To initialize the gcloud CLI, run the following command:

    gcloud init
  11. 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.

  12. Make sure that billing is enabled for your Google Cloud project.

  13. Enable the DLP API:

    gcloud services enable dlp.googleapis.com
  14. Create local authentication credentials for your user account:

    gcloud auth application-default login
  15. 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_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.
  16. Instale o Node.js e o npm.

Configurar um app CLI de proteção de dados confidenciais

Para configurar um app CLI de proteção de dados sensíveis usando o Node.js, faça o seguinte:

  1. Clone a biblioteca de cliente do DLP do Node.js:

     git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples
    
  2. Navegue até o diretório dlp.

     cd nodejs-docs-samples/dlp
    
  3. Instale as dependências do aplicativo:

     npm install
    

Verificar se há informações confidenciais em uma string

Para verificar um texto de amostra usando a API DLP e o script inspectString Node.js, execute este comando:

  node inspectString.js PROJECT_ID "My email address is joe@example.com."

O resultado será assim:

  Findings:
      Info type: EMAIL_ADDRESS
      Likelihood: LIKELY

Limpar

Para evitar cobranças na sua conta do Google Cloud pelos recursos usados nesta página, exclua o projeto do Google Cloud com esses recursos.

Exclua o projeto

Se você criou um novo projeto para este guia de início rápido, a maneira mais fácil de evitar cobranças adicionais é excluir o projeto.

    Delete a Google Cloud project:

    gcloud projects delete PROJECT_ID

Revogar suas credenciais

  1. Optional: Revoke the authentication credentials that you created, and delete the local credential file.

    gcloud auth application-default revoke
  2. Optional: Revoke credentials from the gcloud CLI.

    gcloud auth revoke

A seguir