在使用Google Cloud Run时,有两个主要的安全选项:Binary Authorization和gcloud漏洞过滤器。Binary Authorization是一项高级安全功能,主要用于限制代码在Google Cloud上运行时的来源和版本。gcloud漏洞过滤器是一种便捷的工具,主要用于识别和过滤二进制文件中的漏洞。
下面是一个简单的示例,演示如何使用这两个功能:
使用Binary Authorization:
1.设置Binary Authorization策略:
gcloud beta container binauthz policy export > policy.yaml
# edit the policy.yaml file to allow only trusted images and/or clusters
gcloud beta container binauthz policy import policy.yaml
gcloud builds submit --tag gcr.io/my-project/my-image
gcloud beta run deploy --image gcr.io/my-project/my-image
使用gcloud漏洞过滤器:
gcloud config set builds/scan 'enable'
gcloud builds submit --tag gcr.io/my-project/my-image
gcloud beta container images describe gcr.io/my-project/my-image --show-package-vulnerability
无论是Binary Authorization还是gcloud漏洞过滤器,都提供了一种有用的方法来确保在Google Cloud Run中运行的代码是安全的。选择哪种方法将取决于您的具体需求。