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.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the On-Demand Scanning API.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the On-Demand Scanning API.
Scaricare e scansionare un'immagine
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à dei pacchetti Go, della libreria standard Go e di Linux. Le seguenti etichette indicano il tipo di vulnerabilità Gov:
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.
Esegui la pulizia
Per evitare che al tuo account Google Cloud vengano addebitati costi relativi alle risorse utilizzate in questa pagina, segui questi passaggi.
- 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.