Scansionare manualmente i pacchetti Go
Questa guida rapida mostra come eseguire il pull di un'immagine container, analizzarla manualmente con On-Demand Scanning e recuperare le vulnerabilità identificate per i pacchetti di sistema e Go. Per seguire questa guida rapida, utilizzerai Cloud Shell e un'immagine Alpine di esempio.
Prima di iniziare
- 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.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the On-Demand Scanning API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the On-Demand Scanning API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. Apri Cloud Shell nel tuo progetto.
Si apre un terminale con tutti gli strumenti necessari per seguire questa guida.
Utilizza Docker per eseguire il pull dell'immagine container:
docker pull golang:1.17.6-alpine
Esegui la scansione:
gcloud artifacts docker images scan golang:1.17.6-alpine --additional-package-types=GO
Questo attiva il processo di scansione e restituisce il nome della scansione al termine:
✓ Scanning container image ✓ Locally extracting packages and versions from local container image ✓ Remotely initiating analysis of packages and versions ✓ Waiting for analysis operation to complete [projects/my-project/locations/us/operations/849db1f8-2fb2-4559-9fe0-8720d8cd347c] Done. done: true metadata: '@type': type.googleapis.com/google.cloud.ondemandscanning.v1.AnalyzePackagesMetadata createTime: '2022-01-11T16:58:11.711487Z' resourceUri: golang:1.16.13-alpine name: projects/my-project/locations/us/operations/f4adb1f8-20b2-4579-9fe0-8720d8cd347c response: '@type': type.googleapis.com/google.cloud.ondemandscanning.v1.AnalyzePackagesResponse scan: projects/my-project/locations/us/scans/a54f12b0-ca2d-4d93-8da5-5cf48e9e20ef
Utilizza il nome della scansione, il valore di
scan
dall'output, per recuperare i risultati della scansione:gcloud artifacts docker images list-vulnerabilities \ projects/my-project/locations/us/scans/a54f12b0-ca2d-4d93-8da5-5cf48e9e20ef
L'output contiene un elenco di vulnerabilità di Go, della libreria standard Go e del pacchetto Linux. Le seguenti etichette indicano il tipo di vulnerabilità di Go:
packageType:GO_STDLIB
. Vai alle vulnerabilità della libreria standard. Ciò indica che la vulnerabilità è stata rilevata nella toolchain Go utilizzata per creare il file binario o nella libreria standard inclusa nella toolchain. Una possibile soluzione è aggiornare la toolchain di build.packageType:GO
. Vulnerabilità dei pacchetti Go. Ciò indica che la vulnerabilità è stata trovata in un pacchetto di terze parti. Una possibile soluzione è aggiornare i moduli dipendenti.
- In the Google Cloud console, go to the Manage resources page.
- In the project list, select the project that you want to delete, and then click Delete.
- In the dialog, type the project ID, and then click Shut down to delete the project.
Scaricare e scansionare un'immagine
Esegui la pulizia
Per evitare che al tuo account Google Cloud vengano addebitati costi relativi alle risorse utilizzate in questa pagina, segui questi passaggi.