סריקה ידנית של חבילות Java
במדריך למתחילים הזה מוסבר איך לשלוף קובץ אימג' של קונטיינר, לסרוק אותו באופן ידני באמצעות On-Demand Scanning ולאחזר נקודות חולשה שזוהו בחבילות של מערכת ו-Maven. כדי לבצע את השלבים במדריך הזה למתחילים, תשתמשו ב-Cloud Shell ובדוגמה של תמונת Alpine.
לפני שמתחילים
- נכנסים לחשבון 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.
-
Verify that billing is enabled for your Google Cloud project.
Enable the On-Demand Scanning API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
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.
-
Verify that billing is enabled for your Google Cloud project.
Enable the On-Demand Scanning API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.
הורדה וסריקה של תמונה
פותחים את Cloud Shell בפרויקט.
ייפתח חלון של Terminal עם כל הכלים שנדרשים כדי לפעול לפי המדריך הזה.
משתמשים ב-Docker כדי למשוך את קובץ האימג' של הקונטיינר:
docker pull jenkins:2.60.3-alpineמריצים את הסריקה:
gcloud artifacts docker images scan jenkins:2.60.3-alpine --additional-package-types=MAVENהפעולה הזו מפעילה את תהליך הסריקה ומחזירה את שם הסריקה כשהיא מסתיימת:
✓ 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: jenkins:2.60.3-alpine 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
משתמשים בשם הסריקה, בערך של
scanמהפלט, כדי לאחזר את תוצאות הסריקה:gcloud artifacts docker images list-vulnerabilities \ projects/my-project/locations/us/scans/893c91ce-7fe6-4f1a-a69a-d6ca1b465160הפלט מכיל רשימה של נקודות חולשה בחבילות Maven ו-Linux. אפשר לזהות פגיעויות בחבילות Maven לפי השדה
packageType:MAVEN.
הסרת המשאבים
כדי לא לצבור חיובים לחשבון Google Cloud על המשאבים שבהם השתמשתם בדף הזה, פועלים לפי השלבים הבאים:
אם יצרתם פרויקט חדש לצורך המדריך הזה, אתם יכולים למחוק אותו עכשיו.פותחים את דף ההגדרות (בקטע IAM & Admin) במסוף Google Cloud .
לוחצים על Select a project (בחירת פרויקט).
בוחרים את הפרויקט שרוצים למחוק ולוחצים על Open.
לוחצים על כיבוי.
מזינים את מזהה הפרויקט ולוחצים על Shut down.