Betriebssystempakete manuell scannen

In dieser Kurzanleitung erfahren Sie, wie Sie ein Container-Image per Pull übertragen, es mit der On-Demand Scanning API manuell auf Sicherheitslücken im Betriebssystem scannen und erkannte Sicherheitslücken abrufen. Für diese Kurzanleitung verwenden Sie Cloud Shell und ein Ubuntu-Beispielbild.

Hinweise

  1. 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.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Verify that billing is enabled for your Google Cloud project.

  4. Enable the On-Demand Scanning API.

    Enable the API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. Verify that billing is enabled for your Google Cloud project.

  7. Enable the On-Demand Scanning API.

    Enable the API

  8. Bild herunterladen und scannen

    1. Öffnen Sie eine Cloud Shell in Ihrem Projekt.

      Cloud Shell öffnen

      Dadurch wird ein Terminal mit allen erforderlichen Tools für diese Anleitung geöffnet.

    2. Verwenden Sie Docker, um das neueste Ubuntu-Image abzurufen.

      docker pull ubuntu:latest
      
    3. Führen Sie den Scan aus.

      gcloud artifacts docker images scan ubuntu:latest
      

      Dadurch wird der Scanvorgang ausgelöst und der Scanname zurückgegeben, wenn er abgeschlossen ist:

      ✓ 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/1a6fd941-b997-4e5f-ba4f-6351f30e7dad]
      Done.
      
      done: true
      metadata:
        '@type': type.googleapis.com/google.cloud.ondemandscanning.v1.AnalyzePackagesMetadata
        createTime: '2021-01-26T13:43:53.112123Z'
        resourceUri: ubuntu:latest
      name: projects/my-project/locations/us/operations/1a6fd941-b99f-4eaf-ba4f-6e5af30e7dad
      response:
        '@type': type.googleapis.com/google.cloud.ondemandscanning.v1.AnalyzePackagesResponse
        scan: projects/my-project/locations/us/scans/893c91ce-7fe6-4f1a-a69a-d6ca1b465160
      
    4. Verwenden Sie den Scannamen, den Wert von scan aus der Ausgabe, um die Scanergebnisse abzurufen.

      gcloud artifacts docker images list-vulnerabilities \
      projects/my-project/locations/us/scans/893c91ce-7fe6-4f1a-a69a-d6ca1b465160
      

    Bereinigen

    Mit den folgenden Schritten vermeiden Sie, dass Ihrem Google Cloud -Konto die auf dieser Seite verwendeten Ressourcen in Rechnung gestellt werden:

    Wenn Sie für diese Anleitung ein neues Projekt erstellt haben, können Sie es jetzt löschen.

    Nächste Schritte