.gitea/workflows/delpoy.yml aktualisiert
This commit is contained in:
@@ -29,6 +29,8 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GIT_USER: ${{ vars.GIT_USER }}
|
GIT_USER: ${{ vars.GIT_USER }}
|
||||||
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
|
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
|
||||||
|
TRIVY_REGISTRY_USER: ${{ vars.TRIVY_REGISTRY_USER }}
|
||||||
|
TRIVY_REGISTRY_PASSWORD: ${{ secrets.TRIVY_REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Scan Docker images for vulnerabilities
|
- name: Scan Docker images for vulnerabilities
|
||||||
@@ -108,6 +110,12 @@ jobs:
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -n "${TRIVY_REGISTRY_USER:-}" ] || [ -n "${TRIVY_REGISTRY_PASSWORD:-}" ]; then
|
||||||
|
: "${TRIVY_REGISTRY_USER:?TRIVY_REGISTRY_USER is required when TRIVY_REGISTRY_PASSWORD is set}"
|
||||||
|
: "${TRIVY_REGISTRY_PASSWORD:?TRIVY_REGISTRY_PASSWORD is required when TRIVY_REGISTRY_USER is set}"
|
||||||
|
echo "Using registry credentials from TRIVY_REGISTRY_USER/TRIVY_REGISTRY_PASSWORD"
|
||||||
|
fi
|
||||||
|
|
||||||
TRIVY_IGNORE_ARGS=""
|
TRIVY_IGNORE_ARGS=""
|
||||||
|
|
||||||
if [ -f cve_blacklist.txt ]; then
|
if [ -f cve_blacklist.txt ]; then
|
||||||
@@ -137,7 +145,22 @@ jobs:
|
|||||||
echo ""
|
echo ""
|
||||||
echo "Scanning ${image}"
|
echo "Scanning ${image}"
|
||||||
|
|
||||||
if ! trivy \
|
if [ -n "${TRIVY_REGISTRY_USER:-}" ]; then
|
||||||
|
if ! trivy \
|
||||||
|
image \
|
||||||
|
--username "${TRIVY_REGISTRY_USER}" \
|
||||||
|
--password "${TRIVY_REGISTRY_PASSWORD}" \
|
||||||
|
--scanners "${TRIVY_IMAGE_SCANNERS}" \
|
||||||
|
--vex "${TRIVY_VEX}" \
|
||||||
|
--exit-code 1 \
|
||||||
|
--severity "${TRIVY_SEVERITY}" \
|
||||||
|
--ignore-unfixed \
|
||||||
|
${TRIVY_IGNORE_ARGS} \
|
||||||
|
--no-progress \
|
||||||
|
"${image}"; then
|
||||||
|
failed=1
|
||||||
|
fi
|
||||||
|
elif ! trivy \
|
||||||
image \
|
image \
|
||||||
--scanners "${TRIVY_IMAGE_SCANNERS}" \
|
--scanners "${TRIVY_IMAGE_SCANNERS}" \
|
||||||
--vex "${TRIVY_VEX}" \
|
--vex "${TRIVY_VEX}" \
|
||||||
@@ -147,12 +170,12 @@ jobs:
|
|||||||
${TRIVY_IGNORE_ARGS} \
|
${TRIVY_IGNORE_ARGS} \
|
||||||
--no-progress \
|
--no-progress \
|
||||||
"${image}"; then
|
"${image}"; then
|
||||||
failed=1
|
failed=1
|
||||||
fi
|
fi
|
||||||
done < images.txt
|
done < images.txt
|
||||||
|
|
||||||
if [ "$failed" -ne 0 ]; then
|
if [ "$failed" -ne 0 ]; then
|
||||||
echo "WARNING: High or critical vulnerabilities were found in one or more Docker images. Deployment stopped."
|
echo "WARNING: One or more Docker image scans failed or found ${TRIVY_SEVERITY} vulnerabilities. Deployment stopped."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user