forked from risingwavelabs/risingwave
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add docker scout to check vulnerabilities in docker pipeline (
- Loading branch information
Showing
4 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exits as soon as any line fails. | ||
set -euo pipefail | ||
|
||
buildkite-agent meta-data get SCOUT_REPORT > scout.report | ||
cat >> step.yaml << EOF | ||
steps: | ||
- label: "docker scout slack notification" | ||
command: "echo '--- notify the scout report'" | ||
notify: | ||
- slack: | ||
channels: | ||
- "#notification-buildkite" | ||
message: | | ||
${report} | ||
EOF | ||
|
||
buildkite-agent pipeline upload step.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exits as soon as any line fails. | ||
set -euo pipefail | ||
|
||
ghcraddr="ghcr.io/risingwavelabs/risingwave" | ||
arch="$(uname -m)" | ||
image="${ghcraddr}:${BUILDKITE_COMMIT}-${arch}" | ||
|
||
echo "--- ghcr login" | ||
echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GHCR_USERNAME" --password-stdin | ||
|
||
echo "--- dockerhub login" | ||
echo "$DOCKER_TOKEN" | docker login -u "risingwavelabs" --password-stdin | ||
|
||
echo "--- pull docker image" | ||
echo "pulling ${image}" | ||
docker pull "${image}" | ||
|
||
echo "--- check vulnerabilities" | ||
mkdir -p scout | ||
function docker-scout { | ||
docker run -it -e DOCKER_SCOUT_HUB_USER=risingwavelabs -e DOCKER_SCOUT_HUB_PASSWORD=$DOCKER_TOKEN -u root -v /var/run/docker.sock:/var/run/docker.sock -v $PWD/scout:/scout docker/scout-cli "$@" | ||
} | ||
|
||
echo "--- scout quickview" | ||
docker-scout quickview ${image} -o /scout/quickview.output | ||
cat scout/quickview.output | ||
read C H M L <<< $(grep 'Target' scout/quickview.output | awk -F'[ │ ]+' '{print $4, $5, $6, $7}' | sed 's/[CHML]//g') | ||
cat >> scout/report.output << EOF | ||
Docker Scout Report: | ||
- Critical: $C | ||
- High: $H | ||
- Medium: $M | ||
- Low: $L | ||
EOF | ||
|
||
buildkite-agent meta-data set "SCOUT_REPORT" "$(cat scout/report.output)" | ||
|
||
echo "--- scout recommendations" | ||
docker-scout recommendations "${image}" | ||
|
||
echo "--- scout cves" | ||
docker-scout cves "${image}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters