La regola del progetto è «codice e commenti in inglese; interfaccia, documenti e messaggi in italiano», e gli script di .gitea/ (script e flussi), di installer/ e docker/entrypoint.sh avevano ancora i commenti in italiano (decisione di Alberto del 29 novembre 2026). Cambiano solo i commenti: i messaggi che una persona legge (echo, ::warning::, ::error::, nomi dei passi, note della release) restano in italiano e nessun comando cambia. I programmi awk e gli script finti delle prove erano già in inglese. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
2.5 KiB
Bash
Executable File
61 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Installs one of the two external tools of the CI, the only ones Alberto approved and only for the CI (20 October
|
|
# 2026): gitleaks (secrets in the history) and Trivy (image vulnerabilities). Fixed version, archive downloaded from
|
|
# the project's release and installed only if its SHA-256 hash matches the one written here. The hashes are those of
|
|
# the releases' *_checksums.txt files, checked again on 20 October 2026 against the downloaded archive and the hash
|
|
# GitHub shows for the attachment.
|
|
#
|
|
# .gitea/scripts/strumento.sh gitleaks|trivy <cartella>
|
|
#
|
|
# To update a tool, version and hash change together, in a single commit, with a line in docs/decisioni.md. Never
|
|
# «latest», never third-party actions (trivy-action was compromised in March 2026, CVE-2026-33634), never an install
|
|
# script downloaded on the fly.
|
|
set -euo pipefail
|
|
|
|
nome="${1:?Indica lo strumento: gitleaks o trivy.}"
|
|
cartella="${2:?Indica la cartella in cui installarlo.}"
|
|
|
|
case "$nome" in
|
|
gitleaks)
|
|
versione="8.30.1"
|
|
archivio="gitleaks_${versione}_linux_x64.tar.gz"
|
|
indirizzo="https://github.com/gitleaks/gitleaks/releases/download/v${versione}/${archivio}"
|
|
sha256="551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb"
|
|
;;
|
|
trivy)
|
|
versione="0.75.0"
|
|
archivio="trivy_${versione}_Linux-64bit.tar.gz"
|
|
indirizzo="https://github.com/aquasecurity/trivy/releases/download/v${versione}/${archivio}"
|
|
sha256="c6e65abddb348e25f10549df887045629cf28cc72453cd1c63acb717316b3f3f"
|
|
;;
|
|
*)
|
|
echo "Strumento sconosciuto: «$nome» (gitleaks o trivy)." >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
piattaforma="$(uname -s)-$(uname -m)"
|
|
if [[ "$piattaforma" != "Linux-x86_64" ]]; then
|
|
echo "Gli archivi fissati qui sono per Linux x86_64, non per $piattaforma." >&2
|
|
exit 2
|
|
fi
|
|
|
|
if [[ -x "$cartella/$nome" ]] && [[ -f "$cartella/$nome.sha256" ]] && [[ "$(cat "$cartella/$nome.sha256")" == "$sha256" ]]; then
|
|
echo "== $nome $versione già installato in $cartella"
|
|
exit 0
|
|
fi
|
|
|
|
temporanea="$(mktemp -d)"
|
|
trap 'rm -rf "$temporanea"' EXIT
|
|
echo "== $nome $versione"
|
|
curl -fsSL --retry 3 --retry-delay 5 --max-time 600 -o "$temporanea/$archivio" "$indirizzo"
|
|
if ! echo "$sha256 $temporanea/$archivio" | sha256sum -c --quiet -; then
|
|
echo "L'impronta SHA-256 di $archivio non è quella attesa: $nome non si installa." >&2
|
|
exit 1
|
|
fi
|
|
mkdir -p "$cartella"
|
|
tar -xzf "$temporanea/$archivio" -C "$cartella" "$nome"
|
|
chmod 0755 "$cartella/$nome"
|
|
echo "$sha256" > "$cartella/$nome.sha256"
|
|
"$cartella/$nome" --version | head -n 1 || true
|