CLIENT IP / SPOOFABILITY. docs/geenforce-api-cutover.md claimed that removing the IIS rewrite rule made the allowlist fail closed and that it does NOT become spoofable. The opposite is true. IIS never sets X-Forwarded-For on its own; the rule is the only thing that does. Remove it and IIS still forwards whatever X-Forwarded-For the CALLER sent, waitress trusts it because it arrives from 127.0.0.1, and remote_addr becomes attacker-controlled - so a token-less caller can fetch manifests from anywhere on the network. The document and the _trusted_client_ip docstring now say so, waitress runs with --trusted-proxy-count=1, and stage 5 checks the rule is actually live rather than assuming it. The wizard question is rephrased to something an operator can verify with their network team instead of guessing at. NON-ASCII. The style gate only ever checked .py/.vue/.js/.ts, so documentation accumulated em-dashes, arrows and box-drawing characters against this repo's own convention - including in files added this week. Cleaned, and the gate now uses INCLUDES_ALL so Markdown, JSON and YAML are covered. PLUGIN DEFAULTS. The wizard pre-ticked measuringtools and printedparts, both of which ship default_enabled=false, so every site taking the defaults installed and enabled them against their manifests. Inno has no JSON parser so the list must be hardcoded, but tests/test_installer_defaults.py now fails when it drifts. UPGRADES. The payload copy merges, so a plugin dropped from a site's profile kept its code forever - which defeats a lean build and leaves core's optional-import guards succeeding for a plugin the site no longer has. Stale plugin directories are now deregistered and removed before the copy. add-plugin used 'plugin install', which for the five default_enabled=false plugins left them installed but DISABLED - and printed a green success line anyway. It now goes through apply-profile, and the success line is gated on the exit code. Invoke-Flask records its own exit status, because $LASTEXITCODE keeps a stale value when flask.exe is missing and no native command runs. CHARSET. The utf8mb4 compiler hook lived inline in migrations/env.py, so it covered the CORE chain only: plugin baselines inherited the server default, which on a latin1 server means two charsets in one database. It is now shopdb/utils/mysql_charset.py, imported by both, and preflight reports the database's default charset. BACKUP HONESTY. The dump was described as 'all of your asset data'. Uploaded branding and floor-map images live in instance\ on disk, not in the database, so a restore from the .sql alone comes back with no map. backup now archives instance\ alongside it and says both are needed. VERSIONING. AppVersion was hardcoded at 0.9.0 while the product, the frontend and the newest tag said 0.7.0 - and 0.9.0 collides with a retired contract version. Both builders now generate version.iss from shopdb/__init__.py. Smaller: rollback overwrites .env before deleting it, as uninstall already did; appcmd unlocks are scoped to this site's location rather than server-wide, with the wide unlock as a fallback; DEVELOPMENT-SETUP says Python 3.14; the README plugin list gains printedparts; prune-schema --force is documented as first-provisioning-only; HTTPS is documented as not-the-default with the steps to add it; the DBA SQL is on the wizard's database page; the features page says unticking does not remove an installed feature; and the installer README states that bundle-lock cannot vouch for the exe itself - that needs signing or an out-of-band hash, neither of which is wired up.
141 lines
6.4 KiB
Bash
Executable File
141 lines
6.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Stage a lean per-site bundle next to ShopDBFlask.iss, ready for Inno Setup.
|
|
#
|
|
# The bundle is built FOR ONE SITE from its plugin profile (ADR-013): plugins the
|
|
# site did not choose are absent from the payload entirely. Build one installer
|
|
# per site, not one universal installer.
|
|
#
|
|
# Usage: build-installer.sh <site-profile.json> [repo-path]
|
|
#
|
|
# The wheelhouse cannot be built here. Wheels are cp314 win_amd64 and must be
|
|
# produced ON Windows with the matching Python:
|
|
# pip download -r requirements.txt -d wheels --only-binary=:all:
|
|
# Copy that wheels\ directory in before compiling.
|
|
set -euo pipefail
|
|
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROFILE="${1:?usage: build-installer.sh <site-profile.json> [repo-path]}"
|
|
REPO="${2:-$HOME/projects/shopdb-flask}"
|
|
BUNDLE="$HERE/bundle"
|
|
|
|
[ -f "$PROFILE" ] || { echo "profile not found: $PROFILE"; exit 1; }
|
|
[ -d "$REPO" ] || { echo "repo not found: $REPO"; exit 1; }
|
|
|
|
echo "==> Staging lean app tree from $PROFILE"
|
|
rm -rf "$BUNDLE/app"
|
|
bash "$REPO/scripts/build-site.sh" "$PROFILE" "$BUNDLE/app"
|
|
|
|
# build-site.sh emits the SPA as frontend-dist; the installer's web.config and
|
|
# static route expect frontend\dist.
|
|
if [ -d "$BUNDLE/app/frontend-dist" ]; then
|
|
mkdir -p "$BUNDLE/app/frontend"
|
|
rm -rf "$BUNDLE/app/frontend/dist"
|
|
mv "$BUNDLE/app/frontend-dist" "$BUNDLE/app/frontend/dist"
|
|
fi
|
|
# The /shopdb-based build, used when the operator picks the subpath deployment.
|
|
if [ -d "$BUNDLE/app/frontend-dist-subpath" ]; then
|
|
rm -rf "$BUNDLE/app/frontend/dist-subpath"
|
|
mv "$BUNDLE/app/frontend-dist-subpath" "$BUNDLE/app/frontend/dist-subpath"
|
|
fi
|
|
|
|
# Tell the .iss which plugins this bundle actually carries, so the wizard's
|
|
# plugin page always matches the payload instead of a hand-maintained list.
|
|
echo "==> Writing plugins.iss"
|
|
PLUGINS=$(ls "$BUNDLE/app/plugins" 2>/dev/null | tr '\n' ',' | sed 's/,$//')
|
|
# The subpath SPA is built with its base path compiled in, so whether the wizard
|
|
# can OFFER a subpath install is a property of the bundle, not a runtime choice.
|
|
SUBPATH_ALIAS_BUILT=""
|
|
if [ -f "$BUNDLE/app/frontend/dist-subpath/.alias" ]; then
|
|
SUBPATH_ALIAS_BUILT="$(cat "$BUNDLE/app/frontend/dist-subpath/.alias")"
|
|
fi
|
|
|
|
cat > "$HERE/plugins.iss" <<EOF
|
|
; GENERATED by build-installer.sh - do not edit.
|
|
; The plugins present in bundle\\app\\plugins at build time.
|
|
#define AvailablePlugins "$PLUGINS"
|
|
; The alias the subpath SPA was built for, or empty if this bundle has no
|
|
; subpath build - in which case the wizard must not offer that option.
|
|
#define SubpathAlias "$SUBPATH_ALIAS_BUILT"
|
|
EOF
|
|
echo " $PLUGINS"
|
|
|
|
# The product version, read from the code rather than restated here. A hardcoded
|
|
# AppVersion in the .iss had drifted two minor versions from shopdb/__init__.py.
|
|
echo "==> Writing version.iss"
|
|
APPVERSION=$(sed -n "s/^__version__ = '\\(.*\\)'/\\1/p" "$REPO/shopdb/__init__.py" | head -1)
|
|
[ -n "$APPVERSION" ] || { echo "could not read __version__ from shopdb/__init__.py"; exit 1; }
|
|
cat > "$HERE/version.iss" <<EOF
|
|
; GENERATED by build-installer.sh from shopdb/__init__.py - do not edit.
|
|
#define AppVersion "$APPVERSION"
|
|
EOF
|
|
echo " $APPVERSION"
|
|
|
|
# From THIS directory, which is the reviewed copy under version control. These
|
|
# used to be copied from $HOME/Downloads, so the installer logic that shipped was
|
|
# not the logic that was committed, and the build only worked on one machine.
|
|
echo "==> Copying installer scripts"
|
|
mkdir -p "$BUNDLE"
|
|
for f in shopdb-install.ps1 shopdb-preflight.ps1 bundle-lock.ps1; do
|
|
[ -f "$HERE/$f" ] || { echo "installer script missing from the repo: $f"; exit 1; }
|
|
cp "$HERE/$f" "$BUNDLE/"
|
|
done
|
|
|
|
echo ""
|
|
echo "Bundle staged at: $BUNDLE"
|
|
for d in app wheels python httpplatformhandler urlrewrite mysql; do
|
|
if [ -d "$BUNDLE/$d" ]; then
|
|
printf ' %-20s %s\n' "$d" "$(du -sh "$BUNDLE/$d" | cut -f1)"
|
|
else
|
|
printf ' %-20s absent\n' "$d"
|
|
fi
|
|
done
|
|
echo ""
|
|
echo " plugins shipped: $(ls "$BUNDLE/app/plugins" 2>/dev/null | tr '\n' ' ')"
|
|
|
|
# --- payload verification ---------------------------------------------------
|
|
# The third-party payload is the part git does not record: the wheels, the Python
|
|
# installer and the MSIs that run as SYSTEM on the target server. It must be
|
|
# EXACTLY what bundle-lock.json describes - no missing file, no stale extra wheel
|
|
# left over from a previous build, no changed content - or this is not a bundle
|
|
# anyone reviewed. Previously a missing wheelhouse printed MISSING and the script
|
|
# still exited 0, so an empty bundle compiled into a shippable installer and the
|
|
# failure surfaced on an air-gapped server with no way to fix it.
|
|
#
|
|
# ALLOW_UNLOCKED=1 downgrades this to a warning, for assembling a bundle before
|
|
# its lock exists. A bundle built that way must not be shipped.
|
|
echo ""
|
|
echo "==> Verifying the third-party payload against bundle-lock.json"
|
|
if python3 "$HERE/verify_bundle_lock.py" "$BUNDLE" "$HERE/bundle-lock.json"; then
|
|
echo " payload matches the lock"
|
|
# Ships WITH the bundle: the installer re-checks the payload on the target
|
|
# server before running any of it, so tampering between build and install is
|
|
# caught too.
|
|
cp "$HERE/bundle-lock.json" "$BUNDLE/"
|
|
elif [ "${ALLOW_UNLOCKED:-0}" = "1" ]; then
|
|
echo ""
|
|
echo " ALLOW_UNLOCKED=1: continuing anyway. DO NOT SHIP this bundle."
|
|
else
|
|
echo ""
|
|
echo " The bundle is not what the lock describes."
|
|
echo ""
|
|
echo " Add the missing pieces by hand:"
|
|
echo " wheels/ pip download -r requirements.txt --only-binary=:all: \\"
|
|
echo " --platform win_amd64 --python-version 314 \\"
|
|
echo " --implementation cp --abi cp314 -d wheels"
|
|
echo " python/ python-3.14.x-amd64.exe"
|
|
echo " httpplatformhandler/ httpPlatformHandler_amd64.msi"
|
|
echo " urlrewrite/ rewrite_amd64.msi (client-IP rule; see README)"
|
|
echo " mysql/ mysql-8.0.x-winx64.msi (bundled-database option only)"
|
|
echo ""
|
|
echo " If the payload changed ON PURPOSE, regenerate and COMMIT the lock:"
|
|
echo " pwsh ./refresh-bundle-lock.ps1 # review the diff"
|
|
echo " pwsh ./refresh-bundle-lock.ps1 -Yes # write it"
|
|
echo ""
|
|
echo " To stage a bundle before its lock exists: ALLOW_UNLOCKED=1 $0 ..."
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "Then compile on Windows: iscc ShopDBFlask.iss"
|
|
echo "(Inno Setup 6.6.0 or newer - the wizard uses the windows11 custom style.)"
|