Go 패키지 수동 스캔

이 빠른 시작에서는 컨테이너 이미지를 가져오고, On-Demand Scanning으로 수동으로 검사하고, 시스템 및 Go 패키지에 대해 식별된 취약점을 가져오는 방법을 보여줍니다. 이 빠른 시작을 따르려면 Cloud Shell과 Alpine 이미지 예시를 사용합니다.

시작하기 전에

  1. Google Cloud 계정에 로그인합니다. Google Cloud를 처음 사용하는 경우 계정을 만들고 Google 제품의 실제 성능을 평가해 보세요. 신규 고객에게는 워크로드를 실행, 테스트, 배포하는 데 사용할 수 있는 $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. Verify that billing is enabled for your Google Cloud project.

  4. 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 the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  5. 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

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

  7. 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 the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

이미지 다운로드 및 스캔

  1. 프로젝트에서 Cloud Shell을 엽니다.

    Cloud Shell 열기

    그러면 이 가이드를 따르는 데 필요한 모든 도구가 포함된 터미널이 열립니다.

  2. docker를 사용하여 컨테이너 이미지를 가져옵니다.

    docker pull golang:1.17.6-alpine
    
  3. 스캔을 실행합니다.

    gcloud artifacts docker images scan golang:1.17.6-alpine --additional-package-types=GO
    

    이렇게 하면 스캔 프로세스가 트리거되고 완료되면 스캔 이름이 반환됩니다.

    ✓ 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/849db1f8-2fb2-4559-9fe0-8720d8cd347c]
    Done.
    done: true
    metadata:
      '@type': type.googleapis.com/google.cloud.ondemandscanning.v1.AnalyzePackagesMetadata
      createTime: '2022-01-11T16:58:11.711487Z'
      resourceUri: golang:1.16.13-alpine
    name: projects/my-project/locations/us/operations/f4adb1f8-20b2-4579-9fe0-8720d8cd347c
    response:
      '@type': type.googleapis.com/google.cloud.ondemandscanning.v1.AnalyzePackagesResponse
      scan: projects/my-project/locations/us/scans/a54f12b0-ca2d-4d93-8da5-5cf48e9e20ef
    
  4. 출력의 scan 값인 스캔 이름을 사용하여 스캔 결과를 가져옵니다.

    gcloud artifacts docker images list-vulnerabilities \
    projects/my-project/locations/us/scans/a54f12b0-ca2d-4d93-8da5-5cf48e9e20ef
    

    출력에는 Go, Go 표준 라이브러리, Linux 패키지 취약점 목록이 포함됩니다. 다음 라벨은 Go 취약점의 유형을 나타냅니다.

    • packageType:GO_STDLIB. Go 표준 라이브러리 취약점 이는 바이너리를 빌드하는 데 사용된 Go 도구 모음이나 도구 모음과 번들로 제공되는 표준 라이브러리에서 취약점이 발견되었음을 나타냅니다. 빌드 도구 모음을 업그레이드하면 문제가 해결될 수 있습니다.

    • packageType:GO. Go 패키지 취약점 이는 취약점이 서드 파티 패키지에서 발견되었음을 나타냅니다. 종속 모듈을 업그레이드하면 문제가 해결될 수 있습니다.

삭제

이 페이지에서 사용한 리소스 비용이 Google Cloud 계정에 청구되지 않도록 하려면 다음 단계를 수행합니다.

  1. Google Cloud 콘솔에서 리소스 관리 페이지로 이동합니다.

    리소스 관리로 이동

  2. 프로젝트 목록에서 삭제할 프로젝트를 선택하고 삭제를 클릭합니다.
  3. 대화상자에서 프로젝트 ID를 입력한 후 종료를 클릭하여 프로젝트를 삭제합니다.

다음 단계