יצירת הערות ומופעים בהתאמה אישית

אתם יכולים לספק מטא-נתונים משלכם ל-Artifact Analysis כדי לענות על צורך עסקי ספציפי. לדוגמה, ארגון שמספק ניהול אבטחה עבור קובצי Docker של הלקוחות שלו יכול להשתמש ב-Artifact Analysis כדי לאחסן ולאחזר מטא-נתונים שקשורים לאבטחה של התמונות האלה.

בשלבים הבאים מוסבר איך לספק מטא-נתונים של אימות לתמונות באמצעות Artifact Analysis API. אפשר להשתמש באותן הוראות כדי לאחסן ולשלוף כל סוג של מטא-נתונים שנתמך על ידי Artifact Analysis.

לפני שמתחילים

  1. נכנסים לחשבון Google Cloud . אם אתם משתמשים חדשים ב- Google Cloud, צרו חשבון כדי שתוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Enable the Container Analysis API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  4. התקינו את ה-CLI של Google Cloud.

  5. אם אתם משתמשים בספק זהויות חיצוני (IdP), קודם אתם צריכים להיכנס ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.

  6. כדי לאתחל את ה-CLI של gcloud, הריצו את הפקודה הבאה:

    gcloud init
  7. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  8. Enable the Container Analysis API.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the API

  9. התקינו את ה-CLI של Google Cloud.

  10. אם אתם משתמשים בספק זהויות חיצוני (IdP), קודם אתם צריכים להיכנס ל-CLI של gcloud באמצעות המאגר המאוחד לניהול זהויות.

  11. כדי לאתחל את ה-CLI של gcloud, הריצו את הפקודה הבאה:

    gcloud init
  12. איך מגדירים בקרת גישה למטא-נתונים בפרויקט אפשר לדלג על השלב הזה אם אתם צורכים רק מטא נתונים ממופעים שנוצרו על ידי סריקת קונטיינר של Artifact Analysis.

יצירת הערות ומופעים לפרויקטים

בקטע הזה מוסבר איך ליצור הערות ומופעים. בדוגמה הזו נשתמש בסוג ATTESTATION.

בתור ספק, אתם יוצרים הערה בפרויקט שלכם לכל אישור, ויוצרים מופע בפרויקט של הלקוח למופע של האישור הזה.

יצירת הערות

כדי ליצור הערה ולהקצות לה מזהה הערה:

API

  1. יוצרים קובץ בשם note.json עם תיאור ופרטים של האישור. הקוד הבא מציג קובץ note.json לדוגמה:

    {
      "shortDescription": "A brief Description of the note",
      "longDescription": "A longer description of the note",
      "kind": "ATTESTATION",
      "attestation": {
        "hint": {
          "humanReadableName": "my-attestation-authority"
        }
      }
    }
    

    מידע נוסף על ייצוג JSON של ההערות מופיע במאמרי העזרה של Notes API.

  2. מריצים את פקודת ה-Curl הבאה כדי ליצור הערה:

    curl -v -H "Content-Type: application/json" -H \
      "Authorization: Bearer $(gcloud auth print-access-token)" \
      https://containeranalysis.googleapis.com/v1/projects/PROVIDER_PROJECT_ID/notes?note_id=NOTE_ID -d @note.json
    

    כאשר:

    • PROVIDER_PROJECT_ID הוא מזהה הפרויקט.
    • NOTE_ID מציין מזהה לפתק. מחרוזת באורך של עד 100 תווים.

Java

מידע על התקנת ספריית הלקוח של Artifact Analysis ושימוש בה מופיע במאמר ספריות הלקוח של Artifact Analysis. מידע נוסף מופיע במאמרי העזרה של Artifact Analysis Java API.

כדי לבצע אימות ב-Artifact Analysis, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

import com.google.cloud.devtools.containeranalysis.v1.ContainerAnalysisClient;
import io.grafeas.v1.GrafeasClient;
import io.grafeas.v1.Note;
import io.grafeas.v1.ProjectName;
import io.grafeas.v1.Version;
import io.grafeas.v1.AttestationNote;
import java.io.IOException;
import