Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Scansione automatica dei pacchetti Go
Scopri come attivare la scansione automatica, eseguire il push di un'immagine container su Artifact Registry e visualizzare un elenco delle vulnerabilità rilevate nell'immagine.
Artifact Analysis esegue la scansione delle vulnerabilità ogni volta che viene eseguito il push di un'immagine su Artifact Registry. Gli amministratori della piattaforma e gli sviluppatori di applicazioni possono
utilizzare questa funzionalità di scansione automatica per identificare i rischi nella pipeline
di distribuzione del software.
Questa guida rapida utilizza un semplice pacchetto disponibile pubblicamente per mostrare un tipo
di scansione dei pacchetti. Per impostazione predefinita, Artifact Analysis esegue la scansione delle vulnerabilità in più tipi di pacchetti dopo che hai abilitato l'API di analisi.
I tipi di pacchetti supportati includono: OS, Go, Java (Maven), Python e Node.js (npm).
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.
Nella pagina Crea repository, inserisci le seguenti impostazioni:
Nome: quickstart-docker-repo
Formato: Docker
Modalità: standard
Tipo di località: Regione
Regione: us-central1
Fai clic su Crea.
Viene visualizzata la pagina Repository. Il repository quickstart-docker-repo viene aggiunto all'elenco dei repository.
Configura l'autenticazione
Prima di eseguire il push o il pull delle immagini con Artifact Registry, devi configurare Docker in modo che utilizzi Google Cloud CLI per autenticare le richieste ad Artifact Registry.
In Cloud Shell o nella shell locale, configura l'autenticazione per i repository Docker nella regione us-central1:
Passa a una directory in cui vuoi salvare l'immagine container.
Copia un'immagine nella directory locale. Ad esempio, puoi utilizzare Docker per eseguire il pull dell'ultima immagine Go da Docker Hub.
dockerpullgolang:1.17.6-alpine
Assegnare un tag al pacchetto con un nome di repository
Quando vuoi eseguire il push di un pacchetto in Artifact Registry, devi configurare il comando docker push in modo che esegua il push dell'immagine in una posizione specifica.
Esegui il comando seguente per taggare l'immagine come quickstart-image:tag1:
Nell'elenco dei repository, fai clic su un repository.
Nell'elenco delle immagini, fai clic sul nome di un'immagine.
I totali delle vulnerabilità per ogni digest dell'immagine vengono visualizzati nella
colonna Vulnerabilità.
Per visualizzare l'elenco delle vulnerabilità di un'immagine, fai clic sul link nella colonna
Vulnerabilità.
La sezione Risultati scansione mostra un riepilogo dei tipi di pacchetti
scansionati, delle vulnerabilità totali, delle vulnerabilità con correzioni disponibili,
delle vulnerabilità senza correzioni e della gravità effettiva.
La tabella delle vulnerabilità elenca il nome delle vulnerabilità ed esposizioni comuni (CVE) per ogni vulnerabilità trovata, la gravità effettiva, il punteggio del Common Vulnerability Scoring System (CVSS), le correzioni (se disponibili), il nome del pacchetto che contiene la vulnerabilità e il tipo di pacchetto.
Puoi filtrare e ordinare questi file per controllare un file, una directory o un tipo di file specifico in base all'estensione.
La consoleGoogle Cloud mostra fino a 1200 vulnerabilità in questa tabella. Se
la tua immagine ha più di 1200 vulnerabilità, devi utilizzare
gcloud o l'API per visualizzare l'elenco completo.
Per i dettagli di una CVE specifica, fai clic sul nome della CVE.
Per visualizzare i dettagli dell'occorrenza della vulnerabilità, come il numero di versione e la posizione interessata, fai clic su Visualizza o Visualizza correzione nella riga con il nome della vulnerabilità. Il testo del link è Visualizza per le vulnerabilità senza correzione e Visualizza correzione per le vulnerabilità a cui è stata applicata una correzione.
Esegui la pulizia
Per evitare che al tuo account Google Cloud vengano addebitati costi relativi alle risorse utilizzate in questa pagina, elimina il progetto Google Cloud
con le risorse.
Se hai creato un nuovo progetto per questa guida, ora puoi eliminarlo.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eArtifact Analysis automatically scans newly pushed images to Artifact Registry for vulnerabilities, which helps identify risks in the software delivery pipeline.\u003c/p\u003e\n"],["\u003cp\u003eThis process involves creating a Docker repository in Artifact Registry, configuring authentication, obtaining and tagging a package with a repository name, and then pushing the image to the registry.\u003c/p\u003e\n"],["\u003cp\u003eSupported package types for automatic vulnerability scanning include OS, Go, Java (Maven), Python, and Node.js (npm) packages.\u003c/p\u003e\n"],["\u003cp\u003eThe vulnerability scanning results, including CVE names, severity levels, and available fixes, can be viewed in the Google Cloud console by navigating through the repositories and images.\u003c/p\u003e\n"],["\u003cp\u003eEnabling the Container Scanning API starts billing immediately, and users can delete the entire project or selected resources within the project to avoid incurring charges.\u003c/p\u003e\n"]]],[],null,["Scan Go packages automatically Learn how to enable automatic scanning, push a container image on Artifact Registry,\nand see a list of any vulnerabilities found in the image.\n\nArtifact Analysis scans for vulnerabilities each time an image is\npushed to Artifact Registry. Platform administrators and application developers can\nuse this automatic scanning feature to help identify risks in their software\ndelivery pipeline.\n\nThis quickstart uses a simple publicly available package to demonstrate one type\nof package scanning. By default, Artifact Analysis scans for\nvulnerabilities in multiple package types once you enable the scanning API.\nSupported package types include: OS, Go, Java (Maven), Python and Node.js (npm).\n\nBefore you begin\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n- [Create or select a Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n - Create a Google Cloud project:\n\n ```\n gcloud projects create PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with a name for the Google Cloud project you are creating.\n - Select the Google Cloud project that you created:\n\n ```\n gcloud config set project PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your Google Cloud project name.\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Artifact Registry and Container Scanning APIs:\n\n\n ```bash\n gcloud services enable containerscanning.googleapis.com artifactregistry.googleapis.com\n ```\n\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n- [Create or select a Google Cloud project](https://cloud.google.com/resource-manager/docs/creating-managing-projects).\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n - Create a Google Cloud project:\n\n ```\n gcloud projects create PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with a name for the Google Cloud project you are creating.\n - Select the Google Cloud project that you created:\n\n ```\n gcloud config set project PROJECT_ID\n ```\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with your Google Cloud project name.\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n-\n\n\n Enable the Artifact Registry and Container Scanning APIs:\n\n\n ```bash\n gcloud services enable containerscanning.googleapis.com artifactregistry.googleapis.com\n ```\n\n| **Important:** When you enable the Container Scanning API, billing begins immediately. Once you enable the API for a project, Artifact Analysis automatically scans each newly pushed image to Artifact Registry in that project.\n\nCreate a Docker repository in Artifact Registry\n\nCreate a Docker repository to store the sample image for this quickstart.\n\n1. Open the **Repositories** page in the Google Cloud console.\n\n [Open the Repositories page](https://console.cloud.google.com/artifacts)\n2. Click **Create Repository**.\n\n3. On the **Create Repository** page, input the following settings:\n\n - **Name** : `quickstart-docker-repo`\n - **Format**: Docker\n - **Mode**: Standard\n - **Location type**: Region\n - **Region** : `us-central1`\n4. Click **Create**.\n\nYou see the **Repositories** page. Your `quickstart-docker-repo` repository is added to the repository list.\n\nConfigure authentication\n\nBefore you can push or pull images with Artifact Registry, you must configure Docker to use the Google Cloud CLI to authenticate requests to Artifact Registry.\n\nIn the Cloud Shell or your local shell, set up authentication for Docker repositories in the region `us-central1`: \n\n gcloud auth configure-docker us-central1-docker.pkg.dev\n\nObtain a package\n\n1. Change to a directory where you want to save your container image.\n\n2. Copy an image into your local directory. For example, you can use Docker to pull the latest Go image from [Docker Hub](https://hub.docker.com/_/golang).\n\n docker pull golang:1.17.6-alpine\n\nTag your package with a repository name\n\nWhen you want to push a package to Artifact Registry, you need to configure the `docker push` command to push the image to a specific location.\n\nRun the following command to tag the image as `quickstart-image:tag1`: \n\n```bash\ndocker tag golang:1.17.6-alpine \\\nus-central1-docker.pkg.dev/PROJECT/quickstart-docker-repo/quickstart-image:tag1\n```\n\nWhere:\n\n- \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e is your Google Cloud [project ID](/resource-manager/docs/creating-managing-projects#identifying_projects). If your project ID contains a colon (`:`), see [Domain-scoped projects](/artifact-registry/docs/docker/names#domain).\n- `us-central1` is the Artifact Registry repository region.\n- `docker.pkg.dev` is the hostname for Docker repositories.\n- `quickstart-image` is the image name you want to use in the repository. The image name can be different than the local image name.\n- `tag1` is a tag you're adding to the Docker image. If you didn't specify a tag, Docker will apply the default tag `latest`.\n\nPush the image to Artifact Registry\n\nArtifact Analysis automatically scans new Go packages when they're uploaded to\nArtifact Registry.\n\nTo push your image to your Docker repository in Artifact Registry, run the following command: \n\n```bash\ndocker push us-central1-docker.pkg.dev/PROJECT/quickstart-docker-repo/quickstart-image:tag1\n```\n\nReplace \u003cvar translate=\"no\"\u003ePROJECT\u003c/var\u003e with your Google Cloud\n[project ID](/resource-manager/docs/creating-managing-projects#identifying_projects).\nIf your project ID contains a colon (`:`), see\n[Domain-scoped projects](/artifact-registry/docs/docker/names#domain).\n\nView vulnerability scanning results\n\nTo see the vulnerabilities in an image:\n\n1. Get the list of repositories.\n\n [Open the Repositories page](https://console.cloud.google.com/artifacts)\n2. In the repositories list, click a repository.\n\n3. In the images list, click an image name.\n\n Vulnerability totals for each image digest are displayed in the\n **Vulnerabilities** column.\n\n4. To view the list of vulnerabilities for an image, click the link in the\n **Vulnerabilities** column.\n\n The **Scan results** section displays a summary of the package types\n scanned, total vulnerabilities, vulnerabilities with fixes available,\n vulnerabilities without fixes, and effective severity.\n\n The table of vulnerabilities lists the Common Vulnerabilities and Exposures\n (CVE) name for each vulnerability found, the\n [effective severity](/artifact-analysis/docs/severity-levels),\n Common Vulnerability Scoring System (CVSS) score, fixes (when available),\n the name of the package that contains the vulnerability, and the package\n type. You can filter and sort these files to check a specific file, directory,\n or type of file by file extension. Google Cloud console displays up to\n 1200 vulnerabilities per page in this table.\n5. For details about a specific CVE, click the CVE name.\n\n6. To view vulnerability occurrence details such as version number and affected\n location, click **View** or **View Fixed** in the row with the name of the vulnerability. The link text is **View** for vulnerabilities without a fix, and **View Fixed** for vulnerabilities where a fix has been applied.\n\nClean up\n\n\nTo avoid incurring charges to your Google Cloud account for\nthe resources used on this page, delete the Google Cloud project with the\nresources.\nIf you created a new project for this guide, you can now delete the project.\n\n\u003cbr /\u003e\n\n| **Caution** : Deleting a project has the following effects:\n|\n| - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.\n| - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.\n|\n|\n| If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects\n| can help you avoid exceeding project quota limits.\n1. Delete a Google Cloud project: \n\n```\ngcloud projects delete PROJECT_ID\n```\n\nWhat's next\n\n- [Explore on-demand scanning options](/artifact-analysis/docs/on-demand-scanning-howto).\n- [Understand container scanning concepts](/artifact-analysis/docs/artifact-analysis)."]]