Skip to content

Commit ac18bed

Browse files
committed
smiles
Signed-off-by: Smyslov Maxim <[email protected]>
1 parent c5c5c07 commit ac18bed

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

templates/CVE_Scan.gitlab-ci.yml

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
script:
2828
# Creating workdir
2929
- |
30-
echo "Creating workdir"
30+
echo "🏗️ Creating workdir"
3131
workdir="trivy_scan"
3232
# remove workdir in case it was not removed on previous run
3333
rm -rf "${workdir}"
@@ -37,26 +37,26 @@
3737
echo
3838
# Preparing DOCKER_CONFIG and login to registries
3939
- |
40-
echo "Preparing DOCKER_CONFIG and login to registries"
40+
echo "🔐 Preparing DOCKER_CONFIG and login to registries"
4141
mkdir -p "${workdir}/docker"
4242
export DOCKER_CONFIG="${workdir}/docker"
43-
echo "Logging as ${PROD_REGISTRY_USER} to ${PROD_REGISTRY}"
43+
echo "🔑 Logging as ${PROD_REGISTRY_USER} to ${PROD_REGISTRY}"
4444
echo ${PROD_REGISTRY_PASSWORD} | docker login --username="${PROD_REGISTRY_USER}" --password-stdin ${PROD_REGISTRY}
45-
echo "Logging as ${DEV_REGISTRY_USER} to ${DEV_REGISTRY}"
45+
echo "🔑 Logging as ${DEV_REGISTRY_USER} to ${DEV_REGISTRY}"
4646
echo ${DEV_REGISTRY_PASSWORD} | docker login --username="${DEV_REGISTRY_USER}" --password-stdin ${DEV_REGISTRY}
4747
echo
4848
echo "======================================================="
4949
echo
5050
# Get Trivy
5151
- |
52-
echo "Get Trivy"
53-
echo "Trivy version: ${TRIVY_BIN_VERSION}"
52+
echo "📥 Get Trivy"
53+
echo "🔖 Trivy version: ${TRIVY_BIN_VERSION}"
5454
mkdir -p "${workdir}/bin/trivy-${TRIVY_BIN_VERSION}"
5555
curl -L -s --fail-with-body ${CI_API_V4_URL}/projects/${TRIVY_REPO_ID}/packages/generic/trivy-${TRIVY_BIN_VERSION}/${TRIVY_BIN_VERSION}/trivy -o ${workdir}/bin/trivy-${TRIVY_BIN_VERSION}/trivy
5656
chmod u+x ${workdir}/bin/trivy-${TRIVY_BIN_VERSION}/trivy
5757
ln -s ${PWD}/${workdir}/bin/trivy-${TRIVY_BIN_VERSION}/trivy ${workdir}/bin/trivy
5858
59-
echo "Updating Trivy Data Bases"
59+
echo "🔄 Updating Trivy Data Bases"
6060
mkdir -p "${workdir}/bin/trivy_cache"
6161
${workdir}/bin/trivy image --username "${PROD_REGISTRY_USER}" --password "${PROD_REGISTRY_PASSWORD}" --download-db-only --db-repository "${TRIVY_DB_URL}" --cache-dir "${workdir}/bin/trivy_cache"
6262
${workdir}/bin/trivy image --username "${PROD_REGISTRY_USER}" --password "${PROD_REGISTRY_PASSWORD}" --download-java-db-only --java-db-repository "${TRIVY_JAVA_DB_URL}" --cache-dir "${workdir}/bin/trivy_cache"
@@ -66,54 +66,54 @@
6666
6767
# Run Trivy scan
6868
- |
69-
echo "Setting up registry path for module"
69+
echo "⚙️ Setting up registry path for module"
7070
PROD_REGISTRY_MODULE_BASEDIR="${PROD_REGISTRY}/${MODULE_PROD_REGISTRY_CUSTOM_PATH:-deckhouse/fe/modules}"
7171
DEV_REGISTRY_MODULE_BASEDIR="${DEV_REGISTRY}/${MODULE_DEV_REGISTRY_CUSTOM_PATH:-sys/deckhouse-oss/modules}"
7272
severity="${SEVERITY:-UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL}"
7373
latest_releases_amount="${LATEST_RELEASES_AMOUNT:-3}"
7474
75-
echo "Using prod registry module base dir: ${PROD_REGISTRY_MODULE_BASEDIR}"
76-
echo "Using dev registry module base dir: ${DEV_REGISTRY_MODULE_BASEDIR}"
75+
echo "📦 Using prod registry module base dir: ${PROD_REGISTRY_MODULE_BASEDIR}"
76+
echo "🧪 Using dev registry module base dir: ${DEV_REGISTRY_MODULE_BASEDIR}"
7777
7878
# If input var TAG is empty - set to default branch
7979
if [ -z "${TAG}" ]; then
80-
echo "TAG is empty, setting to default branch: ${CI_DEFAULT_BRANCH}"
80+
echo "🏷️ TAG is empty, setting to default branch: ${CI_DEFAULT_BRANCH}"
8181
TAG="${CI_DEFAULT_BRANCH}"
8282
fi
8383
# prepare TAG if it was triggered with CI_COMMIT_TAG
8484
if [ -n "${CI_COMMIT_TAG}" ]; then
8585
TAG=$(echo "${TAG}"| sed 's/^v//' | cut -d '.' -f -2)
86-
echo "Minor tag to scan: ${TAG}"
86+
echo "🏷️ Minor tag to scan: ${TAG}"
8787
fi
8888
module_tags=("${TAG}")
8989
9090
if [ "${CI_PIPELINE_SOURCE}" == "schedule" ]; then
91-
echo "Pipeline is scheduled, several latest releases will be scanned"
91+
echo "Pipeline is scheduled, several latest releases will be scanned"
9292
SCAN_SEVERAL_LASTEST_RELEASES="true"
9393
fi
9494
95-
echo "Getting tags to scan"
95+
echo "🔍 Getting tags to scan"
9696
# Check if provided tag is a semver minor, and if so - get image from prod registry
9797
if echo "${TAG}" | grep -qE "[0-9]+\.[0-9]+"; then
98-
echo "TAG is a semver minor, image from prod registry will be used"
99-
echo "Total images for module found: $(crane ls "${PROD_REGISTRY_MODULE_BASEDIR}/${MODULE_NAME}" | wc -l)"
98+
echo "📊 TAG is a semver minor, image from prod registry will be used"
99+
echo "📈 Total images for module found: $(crane ls "${PROD_REGISTRY_MODULE_BASEDIR}/${MODULE_NAME}" | wc -l)"
100100
101101
module_tags=($(crane ls "${PROD_REGISTRY_MODULE_BASEDIR}/${MODULE_NAME}" | grep "^v${TAG}\.[0-9]*" | sort -V -r | head -n 1))
102-
echo "Selected images: ${module_tags[@]}"
102+
echo "Selected images: ${module_tags[@]}"
103103
fi
104104
if [ "${SCAN_SEVERAL_LASTEST_RELEASES}" == "true" ]; then
105-
echo "Several latest releases will be scanned: ${latest_releases_amount}"
105+
echo "📚 Several latest releases will be scanned: ${latest_releases_amount}"
106106
107107
# Get release tags by regexp, sort by sevmer desc, cut to get minor version, uniq and get several latest
108108
releases=($(crane ls "${PROD_REGISTRY_MODULE_BASEDIR}/${MODULE_NAME}" | grep "^v[0-9]*\.[0-9]*\.[0-9]*" | sort -V -r))
109109
latest_minor_releases=($(printf '%s\n' "${releases[@]}"| cut -d "." -f -2 | uniq | head -n ${latest_releases_amount}))
110110
111111
for r in "${latest_minor_releases[@]}"; do
112-
echo "Adding image for minor release: ${r} to scan"
112+
echo "Adding image for minor release: ${r} to scan"
113113
module_tags+=($(printf '%s\n' "${releases[@]}" | grep "${r}" | sort -V -r|head -n 1))
114114
done
115115
fi
116-
echo "CVE Scan will be applied to the following tags of ${MODULE_NAME} module:"
116+
echo "🎯 CVE Scan will be applied to the following tags of ${MODULE_NAME} module:"
117117
echo "${module_tags[@]}"
118118
119119
# Functions
@@ -133,7 +133,7 @@
133133
tags_string+=",\"${dd_short_release_tag}\",\"${dd_full_release_tag}\""
134134
fi
135135
echo ""
136-
echo " Uploading trivy ${dd_branch} report for image \"${dd_image_name}\" of \"${dd_module_name}\" module"
136+
echo "📤 Uploading trivy ${dd_branch} report for image \"${dd_image_name}\" of \"${dd_module_name}\" module"
137137
echo ""
138138
dd_upload_response=$(curl -sw "%{http_code}" -X POST \
139139
--retry 10 \
@@ -187,7 +187,7 @@
187187
\"branch_tag\": \"${dd_branch}\"
188188
}")
189189
if [ ${dd_eng_patch_response: -3} -eq 200 ]; then
190-
echo "Engagemet \"${dd_engagement_name}\" updated successfully"
190+
echo "Engagemet \"${dd_engagement_name}\" updated successfully"
191191
else
192192
echo "!!!WARNING!!!"
193193
echo "Engagemet \"${dd_engagement_name}\" WAS NOT UPDATED"
@@ -232,14 +232,14 @@
232232
module_reports="${module_workdir}/reports"
233233
mkdir -p "${module_reports}"
234234
touch ${module_workdir}/.trivyignore
235-
echo "Image to check: ${module_image}:${module_tag}"
236-
echo "Severity: ${severity}"
235+
echo "🔍 Image to check: ${module_image}:${module_tag}"
236+
echo "⚠️ Severity: ${severity}"
237237
echo "----------------------------------------------"
238238
echo ""
239-
echo "Getting module image"
239+
echo "📥 Getting module image"
240240
crane export "${module_image}:${module_tag}" "${MODULE_NAME}.tar"
241241
tar xf "${MODULE_NAME}.tar" -C "${module_workdir}/"
242-
echo "Preparing images list to scan"
242+
echo "📋 Preparing images list to scan"
243243
digests=$(cat "${module_workdir}${IMAGES_DIGESTS_PATH}")
244244
# Main module images to scan
245245
digests=$(echo "${digests}"|jq --arg i "${MODULE_NAME}" --arg s "${module_tag}" '. += { ($i): ($s) }')
@@ -285,7 +285,7 @@
285285
# License scan
286286
trivy_scan "json" "--scanners license --license-full" "--output ${module_reports}/ext_${MODULE_NAME}_${IMAGE_NAME}_report_license.json" "${module_image}@${IMAGE_HASH}"
287287
fi
288-
echo " Done"
288+
echo " Done"
289289
290290
send_report "CVE" "${module_reports}/ext_${MODULE_NAME}_${IMAGE_NAME}_report.json" "${MODULE_NAME}" "${IMAGE_NAME}"
291291
send_report "License" "${module_reports}/ext_${MODULE_NAME}_${IMAGE_NAME}_report_license.json" "${MODULE_NAME}" "${IMAGE_NAME}"

0 commit comments

Comments
 (0)