fix(installer): correct a false security claim, and clear the should-fix list
Some checks failed
CI / backend (push) Failing after 8s
CI / naming (push) Successful in 2s
CI / frontend (push) Successful in 9s
CI / migrations-mysql (push) Failing after 7s

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.
This commit is contained in:
cproudlock
2026-08-03 14:57:38 -04:00
parent aea2905de0
commit 2c415a1712
24 changed files with 582 additions and 119 deletions

View File

@@ -18,11 +18,16 @@
#endif
#define AppName "ShopDB-Flask"
; Pre-release. This has not shipped, so it is 0.x by definition. It becomes
; 1.0.0 when a real site installs from it successfully - not before.
; Do NOT bump this to work around a locked output file: the BUILD STAMP below
; makes every compile a unique filename, which is what that problem needed.
#define AppVersion "0.9.0"
; The PRODUCT version, generated into version.iss by the builder from
; shopdb/__init__.py. It was hardcoded, and had drifted to 0.9.0 while the
; product, the frontend and the newest tag all said 0.7.0 - so the delivered exe,
; its Add/Remove Programs entry and the version stamp written onto the server all
; disagreed with the code inside it, and 0.9.0 collided with a retired contract
; version. Never hardcode it here again.
;
; Do NOT bump a version to work around a locked output file: the BUILD STAMP
; below makes every compile a unique filename, which is what that problem needed.
#include "version.iss"
#define AppPublisher "GE Aerospace"
#define BundleDir "bundle"
; Single source for the install directory - used by DefaultDirName and by the
@@ -239,9 +244,18 @@ end;
// True when a fresh install should tick this by default. The five omitted here
// are specialised; a site that wants them can tick them.
// Pre-tick to match each plugin's own manifest. These five ship
// "default_enabled": false, so a site gets them only by asking. The list used to
// omit measuringtools and printedparts, which meant the wizard installed and
// enabled them against their manifests on every site that took the defaults -
// creating tables nobody asked for.
//
// Keep this in step with the manifests. tests/test_installer_defaults.py fails
// if they drift.
function PluginDefault(const Name: String): Boolean;
begin
Result := (Name <> 'usb') and (Name <> 'employees') and (Name <> 'geenforce');
Result := (Name <> 'usb') and (Name <> 'employees') and (Name <> 'geenforce')
and (Name <> 'measuringtools') and (Name <> 'printedparts');
end;
// Comma-separated list of what the operator ticked.
@@ -372,8 +386,10 @@ begin
// have and ticking a new box adds it.
PluginPage := CreateInputOptionPage(PreflightPage.ID,
'Features', 'Which parts of ShopDB-Flask does this site use?',
'Everything is included in this installer. Unticked features are simply not ' +
'set up, and their database tables are not created.',
'Unticked features are simply not set up, and their database tables are not ' +
'created. On an upgrade this shows what the site already has - ticking a new ' +
'box adds it, but UNTICKING one does NOT remove a feature that is already ' +
'installed. Removing is a deliberate step, not a side effect of an upgrade.',
False, True);
PluginNames := StringSplit('{#AvailablePlugins}', [','], stAll);
for I := 0 to GetArrayLength(PluginNames) - 1 do
@@ -394,7 +410,11 @@ begin
'Existing database', 'Connection details',
'The database and application user must already exist. Your DBA creates ' +
'them; the installer does not, so that it never needs administrative ' +
'rights on your database server.');
'rights on your database server. If they need the exact statements:' + #13#10 +
' CREATE DATABASE shopdb_flask CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' + #13#10 +
' CREATE USER ''shopdb''@''%'' IDENTIFIED BY ''<password>'';' + #13#10 +
' GRANT ALL PRIVILEGES ON shopdb_flask.* TO ''shopdb''@''%'';' + #13#10 +
'The utf8mb4 charset matters - the default on older servers is latin1.');
DbDetailsPage.Add('Host:', False);
DbDetailsPage.Add('Port:', False);
DbDetailsPage.Add('Database:', False);
@@ -445,12 +465,17 @@ begin
// wrong behind a proxy (REMOTE_ADDR is the proxy, so the real client IP is
// discarded). Hence a question rather than a default.
ClientIpPage := CreateInputOptionPage(SitePage.ID,
'Client addresses', 'How does this server see who is connecting?',
'Client addresses', 'Does anything sit between your users and this server?',
'ShopDB records the address of every request, and some features decide what '
+ 'to show based on it. Choose whichever describes this server.',
+ 'to show based on it. If you are not sure, choose the first option - it is '
+ 'correct for a server users reach directly.',
True, False);
ClientIpPage.Add('Clients connect to this server directly (installs URL Rewrite)');
ClientIpPage.Add('A proxy or load balancer sits in front of this server');
ClientIpPage.Add('No - users reach this server directly (installs URL Rewrite)');
// Phrased as "already adds the visitor's address" rather than "is a proxy":
// the operator can check that with their network team, whereas "is there a
// proxy" invites a guess, and guessing wrong here silently discards the real
// client address on every request.
ClientIpPage.Add('Yes - a load balancer or gateway that already adds the visitor''s address');
ClientIpPage.SelectedValueIndex := 0;
end;