Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Analise automaticamente pacotes Go
Saiba como ativar a análise automática, enviar uma imagem de contentor para o Artifact Registry e ver uma lista de eventuais vulnerabilidades encontradas na imagem.
A Artifact Analysis procura vulnerabilidades sempre que uma imagem é
enviada para o Artifact Registry. Os administradores de plataformas e os programadores de aplicações podem usar esta funcionalidade de análise automática para ajudar a identificar riscos no respetivo pipeline de entrega de software.
Este início rápido usa um pacote simples disponível publicamente para demonstrar um tipo de análise de pacotes. Por predefinição, a análise de artefactos procura vulnerabilidades em vários tipos de pacotes assim que ativa a API de análise.
Os tipos de pacotes suportados incluem: SO, Go, Java (Maven), Python e Node.js (npm).
Antes de começar
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.
Na página Criar repositório, introduza as seguintes definições:
Nome: quickstart-docker-repo
Formato: Docker
Modo: padrão
Tipo de localização: região
Região: us-central1
Clique em Criar.
É apresentada a página Repositórios. O repositório quickstart-docker-repo é adicionado à lista de repositórios.
Configure a autenticação
Antes de poder enviar ou extrair imagens com o Artifact Registry, tem de configurar o Docker para usar a Google Cloud CLI para autenticar pedidos ao Artifact Registry.
No Cloud Shell ou na shell local, configure a autenticação para repositórios do Docker na região us-central1:
Na lista de imagens, clique no nome de uma imagem.
Os totais de vulnerabilidades para cada resumo de imagem são apresentados na coluna Vulnerabilidades.
Para ver a lista de vulnerabilidades de uma imagem, clique no link na coluna Vulnerabilidades.
A secção Resultados da análise apresenta um resumo dos tipos de pacotes analisados, do total de vulnerabilidades, das vulnerabilidades com correções disponíveis, das vulnerabilidades sem correções e da gravidade efetiva.
A tabela de vulnerabilidades apresenta o nome de Vulnerabilidades e exposições comuns (CVE) de cada vulnerabilidade encontrada, a gravidade efetiva, a pontuação do Common Vulnerability Scoring System (CVSS), as correções (quando disponíveis), o nome do pacote que contém a vulnerabilidade e o tipo de pacote.
Pode filtrar e ordenar estes ficheiros para verificar um ficheiro, um diretório ou um tipo de ficheiro específico por extensão do ficheiro.
Google Cloud A consola apresenta até 1200 vulnerabilidades nesta tabela. Se a sua imagem tiver mais de 1200 vulnerabilidades, tem de usar o gcloud ou a API para ver a lista completa.
Para ver detalhes sobre uma CVE específica, clique no nome da CVE.
Para ver detalhes da ocorrência de vulnerabilidades, como o número da versão e a localização afetada, clique em Ver ou Ver corrigido na linha com o nome da vulnerabilidade. O texto do link é Ver para vulnerabilidades sem uma correção e Ver corrigido para vulnerabilidades às quais foi aplicada uma correção.
Limpar
Para evitar incorrer em custos na sua Google Cloud conta pelos
recursos usados nesta página, elimine o Google Cloud projeto com os
recursos.
Se criou um novo projeto para este guia, pode eliminá-lo agora.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-21 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)."]]