Выполнить лабораторную 7 по безопасности мессенджера
Application HTTPS smoke / smoke (pull_request) Blocked by required conditions
Skeleton contracts / contracts (pull_request) Blocked by required conditions

This commit is contained in:
2026-12-04 23:51:24 +03:00
parent 20afc2c790
commit 65bbf3224a
86 changed files with 6376 additions and 144 deletions
+36
View File
@@ -0,0 +1,36 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
cache=mtusi2026lab7_grype_cache
grype=anchore/grype:v0.110.0
docker run --rm -e GRYPE_DB_CACHE_DIR=/cache -v "$cache:/cache" "$grype" db update >&2
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
if [ "$#" -gt 0 ]; then
images=$(printf '%s\n' "$@")
else
images=$(docker compose --profile operator config --images | sort -u)
fi
printf '%s\n' "$images" | while IFS= read -r image; do
[ -n "$image" ] || continue
docker image save "$image" -o "$work/image.tar"
docker run --rm -e GRYPE_DB_CACHE_DIR=/cache -e GRYPE_DB_AUTO_UPDATE=false \
-v "$cache:/cache" -v "$work/image.tar:/image.tar:ro" "$grype" docker-archive:/image.tar -o json \
> "$work/result.json"
python3 - "$image" "$work/result.json" <<'PY'
import collections
import json
import sys
doc = json.load(open(sys.argv[2]))
assert doc["descriptor"]["db"]["status"]["valid"]
counts = collections.Counter(entry["vulnerability"]["severity"] for entry in doc["matches"])
examples = []
for entry in doc["matches"]:
vuln, pkg = entry["vulnerability"], entry["artifact"]
if vuln["severity"] == "Critical" or (pkg["type"] == "python" and vuln["severity"] == "High"):
examples.append({"id": vuln["id"], "package": pkg["name"], "version": pkg["version"],
"fix": vuln["fix"]["versions"]})
print(json.dumps({"image": sys.argv[1], "db_built": doc["descriptor"]["db"]["status"]["built"],
"counts": dict(counts), "critical_or_python_high": examples[:10]}))
PY
done