Private
Public Access
Pin dependencies by hash and refuse to follow a rewritten release tag (S7)
pyproject.toml used broad version ranges with no lock file, so two deployments of the same release could end up with different dependency versions, and there was no check that a package actually matches what was reviewed/tested — a compromised or substituted package on the index could install silently. requirements.txt and requirements-dev.txt (generated via `pip-compile --generate-hashes`, see the new README section on regenerating them) pin every dependency to an exact version with its hash. install.sh and upgrade.sh now install from requirements.txt with --require-hashes, then the app itself with --no-deps — a tampered or substituted package fails the hash check instead of installing. Both scripts also no longer `git fetch --tags --force`: a plain fetch refuses to move a tag ref they already have onto a different commit, so a rewritten/tampered release tag is reported and stops the deploy/install instead of being silently followed into production. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
03dd37e69d
commit
cb5617edb8
6 files changed
+1257
-4
No files matched your search
+27
-2
@@ -122,7 +122,22 @@ fi
|
||||
# fast instead of hanging the install on a silent username/password
|
||||
# prompt.
|
||||
if [ -d "$APP_DIR/.git" ]; then
|
||||
GIT_TERMINAL_PROMPT=0 git -C "$APP_DIR" fetch --tags --force || true
|
||||
# Deliberately NOT --force (S7, matches scripts/upgrade.sh): a plain
|
||||
# `git fetch --tags` refuses to move a tag ref this checkout already
|
||||
# has onto a different commit, so a rewritten/tampered release tag
|
||||
# gets reported here instead of silently followed. A fresh checkout
|
||||
# with no tags at all, or an unreachable remote, both legitimately
|
||||
# fail this fetch too — this is a first install, not an upgrade, so
|
||||
# either case still falls through to "stay on whatever's checked out"
|
||||
# below rather than blocking the install.
|
||||
FETCH_OUTPUT="$(GIT_TERMINAL_PROMPT=0 git -C "$APP_DIR" fetch --tags 2>&1)" || {
|
||||
echo "$FETCH_OUTPUT" >&2
|
||||
if echo "$FETCH_OUTPUT" | grep -q "would clobber existing tag"; then
|
||||
echo "==> A release tag points at a different commit than expected —" \
|
||||
"leaving it alone rather than force-following it. Investigate" \
|
||||
"with 'git fetch --tags --dry-run -v' before deploying." >&2
|
||||
fi
|
||||
}
|
||||
LATEST_TAG="$(git -C "$APP_DIR" tag --sort=-creatordate | head -n1)"
|
||||
if [ -n "$LATEST_TAG" ]; then
|
||||
echo "==> Checking out latest release: $LATEST_TAG"
|
||||
@@ -153,7 +168,17 @@ if [ ! -d "$VENV_DIR" ]; then
|
||||
fi
|
||||
echo "==> Installing Evection and its dependencies"
|
||||
sudo -u "$EVECTION_USER" -H "$VENV_DIR/bin/pip" install --upgrade pip
|
||||
sudo -u "$EVECTION_USER" -H "$VENV_DIR/bin/pip" install "$APP_DIR"
|
||||
# requirements.txt (generated by `pip-compile --generate-hashes`, committed
|
||||
# alongside pyproject.toml) pins every dependency to an exact, hash-
|
||||
# verified version (S7) — two installs of the same release get identical
|
||||
# dependency code, and a tampered or substituted package on the index
|
||||
# fails the hash check instead of installing silently. --require-hashes
|
||||
# also means every entry in the file must carry a hash, so an
|
||||
# unreviewed/unpinned addition fails closed rather than installing
|
||||
# unverified. The app itself is installed separately with --no-deps: its
|
||||
# own version is pinned by which git tag is checked out, not by this file.
|
||||
sudo -u "$EVECTION_USER" -H "$VENV_DIR/bin/pip" install --require-hashes -r "$APP_DIR/requirements.txt"
|
||||
sudo -u "$EVECTION_USER" -H "$VENV_DIR/bin/pip" install --no-deps "$APP_DIR"
|
||||
|
||||
# --- 4. .env --------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in new issue
Block a user