Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

INSIGHTS-118 - insights plugins pipeline is not being able to scan the latest changes before release #936

Merged
merged 30 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
73016e4
INSIGHTS-118: insights plugins pipeline is not being able to scan the…
jdesouza Jun 11, 2024
45c8957
INSIGHTS-118: insights plugins pipeline is not being able to scan the…
jdesouza Jun 11, 2024
69e6346
INSIGHTS-118: insights plugins pipeline is not being able to scan the…
jdesouza Jun 11, 2024
ac3e689
INSIGHTS-118: insights plugins pipeline is not being able to scan the…
jdesouza Jun 11, 2024
f489658
INSIGHTS-118: insights plugins pipeline is not being able to scan the…
jdesouza Jun 11, 2024
3e421aa
debugging
jdesouza Jun 11, 2024
f4d04f2
debugging
jdesouza Jun 11, 2024
e6ed077
debugging
jdesouza Jun 11, 2024
f8cac65
debugging
jdesouza Jun 11, 2024
0708ef0
debugging
jdesouza Jun 11, 2024
74bc16f
debugging
jdesouza Jun 11, 2024
7d7c6db
debugging
jdesouza Jun 11, 2024
c1dbe4b
debugging
jdesouza Jun 11, 2024
6d85c99
debugging
jdesouza Jun 11, 2024
abbab2a
debugging
jdesouza Jun 11, 2024
0be066d
debugging
jdesouza Jun 11, 2024
4131e6d
debugging
jdesouza Jun 11, 2024
171db5b
debugging
jdesouza Jun 11, 2024
92f280b
debugging
jdesouza Jun 11, 2024
010c942
debugging
jdesouza Jun 11, 2024
4615a76
debugging
jdesouza Jun 11, 2024
ef54302
debugging
jdesouza Jun 11, 2024
e94462b
debugging
jdesouza Jun 11, 2024
ba59eda
debugging
jdesouza Jun 11, 2024
413876f
debugging
jdesouza Jun 11, 2024
ee64d19
debugging
jdesouza Jun 11, 2024
64ee91a
debugging
jdesouza Jun 11, 2024
586c979
debugging
jdesouza Jun 11, 2024
f22246e
debugging
jdesouza Jun 11, 2024
2564c1b
Revert
jdesouza Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,16 @@ jobs:
- set_environment_variables
- setup_remote_docker
- run: ./.circleci/scripts/install-trivy.sh
- run: ./scripts/scan-all.sh
- set_tags
- run:
name: Scan for vulnerabilities
command: |
if [ "$CIRCLE_BRANCH" != "main" ]
then
./scripts/scan-all.sh $CIRCLE_BRANCH "${CHANGED[*]}"
else
./scripts/scan-all.sh
fi
- run: |
if ! git diff --exit-code fairwinds-insights.yaml; then
echo "Please run `SKIP_TRIVY=true ./scripts/scan-all.sh` to regenerate fairwinds-insights.yaml"
Expand Down Expand Up @@ -337,3 +346,4 @@ workflows:
- main
jobs:
- build_and_push_plugins
- scan_for_vulnerabilities
40 changes: 40 additions & 0 deletions scripts/scan-all.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#! /bin/bash
set -eo pipefail

declare branch_name=$1
declare -a changed_plugins=($2)

branch_name=$(echo $branch_name | sed 's/\//-/g')

# Hard-coding four external images we own. Versions taken from insights-agent. Need to find a better solution here.
images=(quay.io/fairwinds/polaris:9.0 quay.io/fairwinds/nova:v3.9 us-docker.pkg.dev/fairwinds-ops/oss/pluto:v5.19 us-docker.pkg.dev/fairwinds-ops/oss/goldilocks:v4.11)
have_vulns=()
Expand All @@ -27,11 +32,46 @@ for name in "${images[@]}"; do
echo -e " - $name" >> ./fairwinds-insights.yaml
done

declare -A changed_plugins_map
for plugin in "${changed_plugins[@]}"; do
changed_plugins_map[$plugin]=1
done

# create a map to match images in images array to the plugin name
declare -A plugin_map
plugin_map["quay.io/fairwinds/insights-admission-controller"]="admission"
plugin_map["quay.io/fairwinds/aws-costs"]="aws-costs"
plugin_map["quay.io/fairwinds/insights-ci"]="ci"
plugin_map["quay.io/fairwinds/cloud-costs"]="cloud-costs"
plugin_map["quay.io/fairwinds/falco-agent"]="falco"
plugin_map["quay.io/fairwinds/fw-kube-bench-aggregator"]="kube-bench-aggregator"
plugin_map["quay.io/fairwinds/fw-kube-bench"]="kube-bench"
plugin_map["quay.io/fairwinds/kubectl"]="kubectl"
plugin_map["quay.io/fairwinds/fw-kubesec"]="kubesec"
plugin_map["quay.io/fairwinds/kyverno"]="kyverno"
plugin_map["quay.io/fairwinds/fw-opa"]="opa"
plugin_map["quay.io/fairwinds/postgres-partman"]="postgres"
plugin_map["quay.io/fairwinds/prometheus-collector"]="postgres-partman"
plugin_map["quay.io/fairwinds/rbac-reporter"]="rbac-reporter"
plugin_map["quay.io/fairwinds/right-sizer"]="right-sizer"
plugin_map["quay.io/fairwinds/fw-trivy"]="trivy"
plugin_map["quay.io/fairwinds/insights-uploader"]="uploader"
plugin_map["quay.io/fairwinds/insights-utils"]="utils"
plugin_map["quay.io/fairwinds/workloads"]="workloads"

echo "scanning all images"
for name in "${images[@]}"; do
if [[ $SKIP_TRIVY == "true" ]]; then
break
fi

name_without_tag=$(echo $name | sed "s/:.*//")
if [[ -n ${plugin_map[$name_without_tag]} ]]; then
if [[ -n ${changed_plugins_map[${plugin_map[$name_without_tag]}]} ]]; then
name=$(echo $name_without_tag:$branch_name)
fi
fi

echo "scanning $name"
docker pull $name

Expand Down