[v9.4.x] Security: Authenticate to GCR for trivy scans (#73926)
Security: Authenticate to GCR for trivy scans (#72658)
* Authenticate to GCR for trivy scans
# Conflicts:
# .drone.yml
* verify-starlark
* Change secret
# Conflicts:
# .drone.yml
(cherry picked from commit e100fc927e)
# Conflicts:
# .drone.yml
# scripts/drone/vault.star
This commit is contained in:
+131
-7
@@ -3679,14 +3679,34 @@ platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
steps:
|
||||
- commands:
|
||||
- echo $${GCR_CREDENTIALS} | docker login -u _json_key --password-stdin https://us.gcr.io
|
||||
environment:
|
||||
GCR_CREDENTIALS:
|
||||
from_secret: gcr_credentials
|
||||
image: docker:dind
|
||||
name: authenticate-gcr
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM grafana/grafana:latest
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-unknown-low-medium-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 1 --severity HIGH,CRITICAL grafana/grafana:latest
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-high-critical-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- image: plugins/slack
|
||||
name: slack-notify-failure
|
||||
settings:
|
||||
@@ -3700,6 +3720,10 @@ trigger:
|
||||
cron: nightly
|
||||
event: cron
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
clone:
|
||||
retries: 3
|
||||
@@ -3709,14 +3733,34 @@ platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
steps:
|
||||
- commands:
|
||||
- echo $${GCR_CREDENTIALS} | docker login -u _json_key --password-stdin https://us.gcr.io
|
||||
environment:
|
||||
GCR_CREDENTIALS:
|
||||
from_secret: gcr_credentials
|
||||
image: docker:dind
|
||||
name: authenticate-gcr
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM grafana/grafana:main
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-unknown-low-medium-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 1 --severity HIGH,CRITICAL grafana/grafana:main
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-high-critical-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- image: plugins/slack
|
||||
name: slack-notify-failure
|
||||
settings:
|
||||
@@ -3730,6 +3774,10 @@ trigger:
|
||||
cron: nightly
|
||||
event: cron
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
clone:
|
||||
retries: 3
|
||||
@@ -3739,14 +3787,34 @@ platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
steps:
|
||||
- commands:
|
||||
- echo $${GCR_CREDENTIALS} | docker login -u _json_key --password-stdin https://us.gcr.io
|
||||
environment:
|
||||
GCR_CREDENTIALS:
|
||||
from_secret: gcr_credentials
|
||||
image: docker:dind
|
||||
name: authenticate-gcr
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM grafana/grafana:latest-ubuntu
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-unknown-low-medium-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 1 --severity HIGH,CRITICAL grafana/grafana:latest-ubuntu
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-high-critical-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- image: plugins/slack
|
||||
name: slack-notify-failure
|
||||
settings:
|
||||
@@ -3761,6 +3829,10 @@ trigger:
|
||||
cron: nightly
|
||||
event: cron
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
clone:
|
||||
retries: 3
|
||||
@@ -3770,14 +3842,34 @@ platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
steps:
|
||||
- commands:
|
||||
- echo $${GCR_CREDENTIALS} | docker login -u _json_key --password-stdin https://us.gcr.io
|
||||
environment:
|
||||
GCR_CREDENTIALS:
|
||||
from_secret: gcr_credentials
|
||||
image: docker:dind
|
||||
name: authenticate-gcr
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM grafana/grafana:main-ubuntu
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-unknown-low-medium-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 1 --severity HIGH,CRITICAL grafana/grafana:main-ubuntu
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-high-critical-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- image: plugins/slack
|
||||
name: slack-notify-failure
|
||||
settings:
|
||||
@@ -3792,6 +3884,10 @@ trigger:
|
||||
cron: nightly
|
||||
event: cron
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
clone:
|
||||
retries: 3
|
||||
@@ -3801,6 +3897,16 @@ platform:
|
||||
arch: amd64
|
||||
os: linux
|
||||
steps:
|
||||
- commands:
|
||||
- echo $${GCR_CREDENTIALS} | docker login -u _json_key --password-stdin https://us.gcr.io
|
||||
environment:
|
||||
GCR_CREDENTIALS:
|
||||
from_secret: gcr_credentials
|
||||
image: docker:dind
|
||||
name: authenticate-gcr
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM google/cloud-sdk:431.0.0
|
||||
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM grafana/build-container:1.7.4
|
||||
@@ -3821,8 +3927,13 @@ steps:
|
||||
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM grafana/docs-base:dbd975af06
|
||||
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM cypress/included:9.5.1-node16.14.0-slim-chrome99-ff97
|
||||
- trivy --exit-code 0 --severity UNKNOWN,LOW,MEDIUM us-docker.pkg.dev/grafanalabs-dev/cloud-data-sources/e2e:latest
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-unknown-low-medium-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- commands:
|
||||
- trivy --exit-code 1 --severity HIGH,CRITICAL google/cloud-sdk:431.0.0
|
||||
- trivy --exit-code 1 --severity HIGH,CRITICAL grafana/build-container:1.7.4
|
||||
@@ -3843,8 +3954,13 @@ steps:
|
||||
- trivy --exit-code 1 --severity HIGH,CRITICAL grafana/docs-base:dbd975af06
|
||||
- trivy --exit-code 1 --severity HIGH,CRITICAL cypress/included:9.5.1-node16.14.0-slim-chrome99-ff97
|
||||
- trivy --exit-code 1 --severity HIGH,CRITICAL us-docker.pkg.dev/grafanalabs-dev/cloud-data-sources/e2e:latest
|
||||
depends_on:
|
||||
- authenticate-gcr
|
||||
image: aquasec/trivy:0.21.0
|
||||
name: scan-high-critical-vulnerabilities
|
||||
volumes:
|
||||
- name: docker
|
||||
path: /var/run/docker.sock
|
||||
- image: plugins/slack
|
||||
name: slack-notify-failure
|
||||
settings:
|
||||
@@ -3858,6 +3974,10 @@ trigger:
|
||||
cron: nightly
|
||||
event: cron
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
clone:
|
||||
retries: 3
|
||||
@@ -3889,6 +4009,10 @@ trigger:
|
||||
cron: grafana-com-nightly
|
||||
event: cron
|
||||
type: docker
|
||||
volumes:
|
||||
- host:
|
||||
path: /var/run/docker.sock
|
||||
name: docker
|
||||
---
|
||||
get:
|
||||
name: credentials.json
|
||||
@@ -4016,12 +4140,6 @@ get:
|
||||
kind: secret
|
||||
name: enterprise2-cdn-path
|
||||
---
|
||||
get:
|
||||
name: security_prefix
|
||||
path: infra/data/ci/grafana-release-eng/enterprise2
|
||||
kind: secret
|
||||
name: enterprise2_security_prefix
|
||||
---
|
||||
get:
|
||||
name: gcp_service_account_prod_base64
|
||||
path: infra/data/ci/grafana-release-eng/rgm
|
||||
@@ -4082,7 +4200,13 @@ get:
|
||||
kind: secret
|
||||
name: github_token
|
||||
---
|
||||
get:
|
||||
name: service-account
|
||||
path: secret/data/common/gcr
|
||||
kind: secret
|
||||
name: gcr_credentials
|
||||
---
|
||||
kind: signature
|
||||
hmac: fc290ffe72cdad8e3d81f5e763aaeb2d370b6a58ae25886edb15837fc1503c79
|
||||
hmac: 8b1c797ceda46adc56f3c8545d1a185d98c2ebda15985ef2c67bf7f8a3cc7e73
|
||||
|
||||
...
|
||||
|
||||
@@ -24,6 +24,17 @@ def cronjobs():
|
||||
grafana_com_nightly_pipeline(),
|
||||
]
|
||||
|
||||
def authenticate_gcr_step():
|
||||
return {
|
||||
"name": "authenticate-gcr",
|
||||
"image": "docker:dind",
|
||||
"commands": ["echo $${GCR_CREDENTIALS} | docker login -u _json_key --password-stdin https://us.gcr.io"],
|
||||
"environment": {
|
||||
"GCR_CREDENTIALS": from_secret("gcr_credentials"),
|
||||
},
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}],
|
||||
}
|
||||
|
||||
def cron_job_pipeline(cronName, name, steps):
|
||||
return {
|
||||
"kind": "pipeline",
|
||||
@@ -41,6 +52,14 @@ def cron_job_pipeline(cronName, name, steps):
|
||||
"retries": 3,
|
||||
},
|
||||
"steps": steps,
|
||||
"volumes": [
|
||||
{
|
||||
"name": "docker",
|
||||
"host": {
|
||||
"path": "/var/run/docker.sock",
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
def scan_docker_image_pipeline(tag):
|
||||
@@ -58,6 +77,7 @@ def scan_docker_image_pipeline(tag):
|
||||
cronName = "nightly",
|
||||
name = "scan-" + docker_image + "-image",
|
||||
steps = [
|
||||
authenticate_gcr_step(),
|
||||
scan_docker_image_unknown_low_medium_vulnerabilities_step(docker_image),
|
||||
scan_docker_image_high_critical_vulnerabilities_step(docker_image),
|
||||
slack_job_failed_step("grafana-backend-ops", docker_image),
|
||||
@@ -75,6 +95,7 @@ def scan_build_test_publish_docker_image_pipeline():
|
||||
cronName = "nightly",
|
||||
name = "scan-build-test-and-publish-docker-images",
|
||||
steps = [
|
||||
authenticate_gcr_step(),
|
||||
scan_docker_image_unknown_low_medium_vulnerabilities_step("all"),
|
||||
scan_docker_image_high_critical_vulnerabilities_step("all"),
|
||||
slack_job_failed_step("grafana-backend-ops", "build-images"),
|
||||
@@ -101,6 +122,8 @@ def scan_docker_image_unknown_low_medium_vulnerabilities_step(docker_image):
|
||||
"name": "scan-unknown-low-medium-vulnerabilities",
|
||||
"image": aquasec_trivy_image,
|
||||
"commands": cmds,
|
||||
"depends_on": ["authenticate-gcr"],
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}],
|
||||
}
|
||||
|
||||
def scan_docker_image_high_critical_vulnerabilities_step(docker_image):
|
||||
@@ -123,6 +146,8 @@ def scan_docker_image_high_critical_vulnerabilities_step(docker_image):
|
||||
"name": "scan-high-critical-vulnerabilities",
|
||||
"image": aquasec_trivy_image,
|
||||
"commands": cmds,
|
||||
"depends_on": ["authenticate-gcr"],
|
||||
"volumes": [{"name": "docker", "path": "/var/run/docker.sock"}],
|
||||
}
|
||||
|
||||
def slack_job_failed_step(channel, image):
|
||||
|
||||
@@ -112,11 +112,6 @@ def secrets():
|
||||
"infra/data/ci/grafana-release-eng/enterprise2",
|
||||
"cdn_path",
|
||||
),
|
||||
vault_secret(
|
||||
"enterprise2_security_prefix",
|
||||
"infra/data/ci/grafana-release-eng/enterprise2",
|
||||
"security_prefix",
|
||||
),
|
||||
vault_secret(
|
||||
rgm_gcp_key_base64,
|
||||
"infra/data/ci/grafana-release-eng/rgm",
|
||||
@@ -168,4 +163,9 @@ def secrets():
|
||||
"infra/data/ci/github/grafanabot",
|
||||
"pat",
|
||||
),
|
||||
vault_secret(
|
||||
"gcr_credentials",
|
||||
"secret/data/common/gcr",
|
||||
"service-account",
|
||||
),
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user