将 Assured OSS 与 Security Command Center 集成后,有保障的开源软件包会托管在您控制的项目中创建的 Artifact Registry 代码库中。
本文档介绍了如何连接到 Assured OSS 的 Artifact Registry 代码库,以直接访问和下载 Go 软件包。
本文档仅适用于 Assured OSS 高级层级。 对于免费层级,请参阅使用直接代码库访问权限下载 Go 软件包(免费层级)。
准备工作
-
如需获得获取服务账号密钥的 base64 编码字符串所需的权限,请让管理员为您授予组织的 Service Account Key Admin (
roles/iam.serviceAccountKeyAdmin
) IAM 角色。 如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。 - 将 Assured OSS 与 Security Command Center 集成。
- 验证所请求的服务账号与 Security Command Center 的连接。
- 安装最新版本的 Google Cloud CLI。
如果您之前安装了 Google Cloud CLI,请运行以下命令,检查您是否拥有最新版本:
gcloud components update
设置身份验证
如需设置身份验证,请参阅为 Go 设置身份验证。
下载 Go 软件包
在 gcloud CLI 中,安装 Go 1.15 或更高版本。
安装适用于 Go 的 gcloud CLI 插件:
gcloud components install package-go-module
指示 Go 从 Assured OSS 代码库下载模块:
export GOPROXY=https://us-go.pkg.dev/PROJECT_ID/assuredoss-go
将 PROJECT_ID 替换为您在设置 Assured OSS 时选择的项目 ID。
从使用公共校验和数据库进行检查的模块中排除您正在开发的模块:
export GONOSUMDB=MODULE_PATH_REGEX
使用 Go 凭据帮助程序将 Artifact Registry 凭据添加到
netrc
文件中:GOPROXY=proxy.golang.org \ go run github.com/GoogleCloudPlatform/artifact-registry-go-tools/cmd/auth@v0.1.0 \ add-locations --locations=us \ --json_key=KEY_FILENAME.json