במאמר הזה מוסבר איך להגדיר התראות על עדכונים בהערות ובמופעים.
התכונה 'ניתוח ארטיפקטים' מספקת התראות באמצעות Pub/Sub לגבי פגיעויות שנמצאו על ידי סריקה אוטומטית ולגבי מטא-נתונים אחרים. כשיוצרים או מעדכנים הערה או אירוע, מתפרסמת הודעה בנושא המתאים לכל גרסת API. השתמשו בנושא שמתאים לגרסת ה-API שבה אתם משתמשים.
לפני שמתחילים
- נכנסים לחשבון Google Cloud . אנחנו ממליצים למשתמשים חדשים ב- Google Cloud ליצור חשבון כדי שיוכלו להעריך את הביצועים של המוצרים שלנו בתרחישים מהעולם האמיתי. לקוחות חדשים מקבלים בחינם גם קרדיט בשווי 300$ להרצה, לבדיקה ולפריסה של עומסי העבודה.
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
Enable the Container Analysis API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init -
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
Enable the Container Analysis API, if it is not already enabled.
Roles required to enable APIs
To enable APIs, you need the
serviceusage.services.enablepermission. 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.-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init - איך מגדירים בקרת גישה למטא-נתונים בפרויקט אפשר לדלג על השלב הזה אם אתם צורכים רק מטא-נתונים ממופעים שנוצרו על ידי סריקת מאגר Artifact Analysis.
יצירת נושאי Pub/Sub
אחרי שמפעילים את Artifact Analysis API, Artifact Analysis יוצר באופן אוטומטי נושאי Pub/Sub עם מזהי הנושאים הבאים:
container-analysis-notes-v1container-analysis-occurrences-v1
אם הנושאים נמחקו בטעות או חסרים, אתם יכולים להוסיף אותם בעצמכם. לדוגמה, יכול להיות שהנושאים לא יופיעו אם Google Cloud בארגון שלכם יש אילוץ של מדיניות הארגון שדורש הצפנה באמצעות מפתחות הצפנה בניהול הלקוח (CMEK). אם Pub/Sub API נמצא ברשימת הדחייה של האילוץ הזה, השירותים לא יכולים ליצור נושאים באופן אוטומטי עםGoogle-owned and Google-managed encryption keys.
כדי ליצור את הנושאים באמצעות Google-owned and Google-managed encryption keys:
המסוף
נכנסים לדף הנושאים של Pub/Sub במסוף Google Cloud .
לוחצים על יצירת נושא.
מזינים מזהה נושא:
container-analysis-notes-v1כדי שהשם יתאים ל-URI:
projects/PROJECT_ID/topics/container-analysis-notes-v1כאשר PROJECT_ID הוא Google Cloud מזהה הפרויקט.
לוחצים על יצירה.
מזינים מזהה נושא:
container-analysis-occurrences-v1כדי שהשם יתאים ל-URI:
projects/PROJECT_ID/topics/container-analysis-occurrences-v1
gcloud
מריצים את הפקודות הבאות בשורת הפקודה או בחלון הטרמינל:
gcloud pubsub topics create projects/PROJECT_ID/topics/container-analysis-notes-v1
gcloud pubsub topics create projects/PROJECT_ID/topics/container-analysis-occurrences-v1
מידע נוסף על הפקודה gcloud pubsub topics זמין במסמכי התיעוד של topics.
כדי ליצור את הנושאים עם הצפנת CMEK, אפשר לעיין בהוראות להצפנת נושאים ב-Pub/Sub.
בכל פעם שיוצרים או מעדכנים הערה או מופע, מתפרסמת הודעה בנושא המתאים. עם זאת, צריך גם ליצור מינוי ל-Pub/Sub כדי להאזין לאירועים ולקבל הודעות משירות Pub/Sub.
יצירת מינויים ל-Pub/Sub
כדי להאזין לאירועים, צריך ליצור מינוי Pub/Sub שמשויך לנושא:
המסוף
נכנסים לדף המינויים של Pub/Sub במסוףGoogle Cloud .
לוחצים על יצירת מינוי.
מקלידים שם למינוי. לדוגמה, notes.
מזינים את ה-URI של הנושא להערות:
projects/PROJECT_ID/topics/container-analysis-notes-v1כאשר PROJECT_ID הוא מזהה הפרויקט שלכם ב- Google Cloud.
לוחצים על יצירה.
יוצרים עוד מינוי להזדמנויות עם ה-URI:
projects/PROJECT_ID/topics/container-analysis-occurrences-v1
gcloud
כדי לקבל אירועי Pub/Sub, קודם צריך ליצור מינוי שמשויך לנושא container-analysis-occurrences-v1:
gcloud pubsub subscriptions create \
--topic container-analysis-occurrences-v1 occurrences
מעכשיו, תוכלו לשלוף הודעות שקשורות למופעים שלכם באמצעות המינוי החדש:
gcloud pubsub subscriptions pull \
--auto-ack occurrences
Java
מידע על התקנת ספריית הלקוח של Artifact Analysis ושימוש בה מופיע במאמר ספריות הלקוח של Artifact Analysis. מידע נוסף מופיע במאמרי העזרה של Artifact Analysis Java API.
כדי לבצע אימות ב-Artifact Analysis, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
Go
במאמר ספריות הלקוח של Artifact Analysis מוסבר איך להתקין את ספריית הלקוח ולהשתמש בה ב-Artifact Analysis. מידע נוסף מופיע במאמרי העזרה של Artifact Analysis Go API.
כדי לבצע אימות ב-Artifact Analysis, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
Node.js
במאמר ספריות הלקוח של Artifact Analysis מוסבר איך להתקין את ספריית הלקוח ולהשתמש בה ב-Artifact Analysis. למידע נוסף, קראו את מאמרי העזרה של Artifact Analysis Node.js API.
כדי לבצע אימות ב-Artifact Analysis, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
Ruby
במאמר ספריות הלקוח של Artifact Analysis מוסבר איך להתקין את ספריית הלקוח ולהשתמש בה ב-Artifact Analysis. מידע נוסף מופיע במאמרי העזרה של Artifact Analysis Ruby API.
כדי לבצע אימות ב-Artifact Analysis, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
Python
מידע על התקנת ספריית הלקוח של Artifact Analysis ושימוש בה מופיע במאמר ספריות הלקוח של Artifact Analysis. למידע נוסף, קראו את מאמרי העזרה של Artifact Analysis Python API.
כדי לבצע אימות ב-Artifact Analysis, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.
אפליקציות של מנויים מקבלות רק הודעות שמתפרסמות בנושא אחרי יצירת המינוי.
ה-payloads של Pub/Sub הם בפורמט JSON, והסכימה שלהם היא:
הערות:
{ "name": "projects/PROJECT_ID/notes/NOTE_ID", "kind": "NOTE_KIND", "notificationTime": "NOTIFICATION_TIME", }
מופעים:
{ "name": "projects/PROJECT_ID/occurrences/OCCURRENCE_ID", "kind": "NOTE_KIND", "notificationTime": "NOTIFICATION_TIME", }
where:
- NOTE_KIND הוא אחד מהערכים ב-
NoteKind - NOTIFICATION_TIME היא חותמת זמן בפורמט RFC 3339 UTC 'Zulu', עם דיוק של ננו-שניות.
לפרטים
כדי לקבל מידע נוסף על הערה או מופע, אתם יכולים לגשת למטא-נתונים שמאוחסנים ב-Artifact Analysis. לדוגמה, אפשר לבקש את כל הפרטים של אירוע ספציפי. הוראות מפורטות זמינות במאמר בדיקת נקודות חולשה.
המאמרים הבאים
- הוראות לשימוש ב-Artifact Analysis כדי לאחסן ולנהל את המטא-נתונים המותאמים אישית מפורטות במאמר יצירת הערות ומופעים בהתאמה אישית.