Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Go-Pakete automatisch scannen
Hier erfahren Sie, wie Sie das automatische Scannen aktivieren, ein Container-Image in Artifact Registry übertragen und eine Liste der im Image gefundenen Sicherheitslücken aufrufen.
Die Artefaktanalyse scannt jedes Mal, wenn ein Image in Artifact Registry übertragen wird, nach Sicherheitslücken. Plattformadministratoren und Anwendungsentwickler können diese automatische Scanfunktion nutzen, um Risiken in ihrer Softwarebereitstellungspipeline zu erkennen.
In dieser Kurzanleitung wird ein einfaches, öffentlich verfügbares Paket verwendet, um eine Art von Paketscanning zu demonstrieren. Standardmäßig scannt die Artefaktanalyse mehrere Pakettypen auf Sicherheitslücken, sobald Sie die Scanning API aktivieren.
Zu den unterstützten Pakettypen gehören: Betriebssystem, Go, Java (Maven), Python und Node.js (npm).
Hinweise
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.
Geben Sie auf der Seite Repository erstellen die folgenden Einstellungen ein:
Name:quickstart-docker-repo
Format: Docker
Modus: Standard
Standorttyp: Region
Region:us-central1
Klicken Sie auf Erstellen.
Die Seite Repositories wird angezeigt. Ihr quickstart-docker-repo-Repository wird der Repository-Liste hinzugefügt.
Authentifizierung konfigurieren
Bevor Sie Images mit Artifact Registry hoch- oder herunterladen können, müssen Sie Docker so konfigurieren, dass die Google Cloud CLI zum Authentifizieren von Anfragen an Artifact Registry verwendet wird.
Richten Sie in Cloud Shell oder in Ihrer lokalen Shell die Authentifizierung für Docker-Repositories in der Region us-central1 ein:
Wechseln Sie in ein Verzeichnis, in dem Sie das Container-Image speichern möchten.
Kopieren Sie ein Bild in Ihr lokales Verzeichnis. Sie können beispielsweise Docker verwenden, um das neueste Go-Image von Docker Hub abzurufen.
dockerpullgolang:1.17.6-alpine
Paket mit einem Repository-Namen taggen
Wenn Sie ein Paket in Artifact Registry hochladen möchten, müssen Sie den Befehl docker push so konfigurieren, dass das Image an einen bestimmten Speicherort hochgeladen wird.
Führen Sie den folgenden Befehl aus, um das Image als quickstart-image:tag1 zu taggen:
us-central1 ist die Region des Artifact Registry-Repositorys.
docker.pkg.dev ist der Hostname für Docker-Repositories.
quickstart-image ist der Image-Name, der im Repository verwendet werden soll.
Der Image-Name kann sich vom Image-Namen des lokalen Images unterscheiden.
tag1 ist ein Tag, das Sie dem Docker-Image hinzufügen. Wenn Sie kein Tag angegeben haben, wendet Docker das Standard-Tag latest an.
Image in Artifact Registry hochladen
Die Artefaktanalyse scannt automatisch neue Go-Pakete, wenn sie in Artifact Registry hochgeladen werden.
Führen Sie den folgenden Befehl aus, um Ihr Image per Push in Ihr Docker-Repository in Artifact Registry zu übertragen:
Ersetzen Sie PROJECT durch Ihre Google Cloud
Projekt-ID.
Wenn die Projekt-ID einen Doppelpunkt (:) enthält, finden Sie weitere Informationen unter Auf Domains beschränkte Projekte.
Ergebnisse des Scannens auf Sicherheitslücken ansehen
So sehen Sie die Sicherheitslücken in einem Image:
Klicken Sie in der Liste der Repositories auf ein Repository.
Klicken Sie in der Liste der Bilder auf einen Bildnamen.
Alle Sicherheitslücken für jeden Image-Digest werden in der Spalte Sicherheitslücken angezeigt.
Wenn Sie die Liste der Sicherheitslücken für ein Image aufrufen möchten, klicken Sie auf den Link in der Spalte Vulnerabilities (Sicherheitslücken).
Im Bereich Scanergebnisse wird eine Zusammenfassung der gescannten Pakettypen, der Gesamtzahl der Sicherheitslücken, der Sicherheitslücken mit verfügbaren Korrekturen, der Sicherheitslücken ohne Korrekturen und des effektiven Schweregrads angezeigt.
In der Tabelle mit den Sicherheitslücken sind für jede gefundene Sicherheitslücke der CVE-Name (Common Vulnerabilities and Exposures), der effektive Schweregrad, die CVSS-Punktzahl (Common Vulnerability Scoring System), Korrekturen (sofern verfügbar), der Name des Pakets, das die Sicherheitslücke enthält, und der Pakettyp aufgeführt.
Sie können diese Dateien filtern und sortieren, um eine bestimmte Datei, ein bestimmtes Verzeichnis oder einen bestimmten Dateityp nach Dateiendung zu prüfen.
In derGoogle Cloud -Konsole werden in dieser Tabelle bis zu 1.200 Sicherheitslücken angezeigt. Wenn Ihr Image mehr als 1.200 Sicherheitslücken aufweist, müssen Sie die vollständige Liste mit gcloud oder der API aufrufen.
Klicken Sie auf den Namen der CVE, um Details zu einer bestimmten CVE aufzurufen.
Wenn Sie Details zum Auftreten von Sicherheitslücken wie Versionsnummer und betroffene Stelle aufrufen möchten, klicken Sie in der Zeile mit dem Namen der Sicherheitslücke auf Anzeigen oder Behoben anzeigen. Der Linktext lautet Ansehen für Sicherheitslücken ohne Korrektur und Behobene ansehen für Sicherheitslücken, bei denen eine Korrektur angewendet wurde.
Bereinigen
Löschen Sie das Google Cloud -Projekt zusammen mit den Ressourcen, damit Ihrem Google Cloud -Konto die auf dieser Seite verwendeten Ressourcen nicht in Rechnung gestellt werden.
Wenn Sie für diese Anleitung ein neues Projekt erstellt haben, können Sie es jetzt löschen.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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)."]]