0
0
Fork 0
Commit graph

2 commits

Author SHA1 Message Date
steel
320646b8fe fixup
Some checks failed
CI / build-and-test (18.x) (push) Has been cancelled
CI / build-and-test (20.x) (push) Has been cancelled
CI / build-and-test (22.x) (push) Has been cancelled
2026-08-19 18:39:47 +08:00
Karstein Phobic Nyvold Kvistad
a4f8426369 version pin: refuse to save a project on a mismatched CODESYS install (v0.14.0)
The open_project pre-flight was supposed to prevent this, but it reads
the project's profile from projectinspectiondata.auxiliary inside the
.project ZIP -- and a plain .project is NOT a ZIP. Verified across
3.5.19.20 .. 3.5.22.10: magic 23 89 ED 33, unzip -l fails, no plaintext
profile string. So inspectProjectFile always throws, the pre-flight
catches and proceeds, and the guard is dead code on real projects.
It also only ever covered open_project -- not the release pipeline.

Consequence in the field: a server bound to SP21 Patch 5 opened and
re-saved a 3.5.19.20 vessel project during release_project_version.
4,639,776 -> 4,688,496 bytes, committed and tagged. The tagged binary
stopped being the software on the boat.

Since the version cannot be recovered from the file, pin it in the repo.
New src/version-pin.ts resolves, most specific first:
  1. .codesys-version next to the .project (one line, "3.5.19.20" or
     "CODESYS V3.5 SP19"; comments and blanks skipped) -- the only
     option when seeding a project with no release history
  2. library.md's "CODESYS Development System" row -- every project
     gets a pin for free after its first release

Policy is asymmetric so it guards the dangerous path without breaking
existing repos: bump_project_version and release_project_version refuse
on mismatch AND on no-pin; get_project_info, mirror_export and
list_project_libraries only warn on mismatch and proceed when unpinned.
Both saving tools accept allowVersionUpgrade: true to override.

Parsing note: library.md's row carries no dotted profile version, so it
is matched on the SP/Patch label only -- a naive version regex would
otherwise bind to the ScriptEngine's 4.2.0.0. Covered by a regression
test.

25 new unit tests; suite 180/180.

Also fixes an unrelated pre-existing test failure: the ASCII-only script
template check used readdirSync without filtering, so a local untracked
src/scripts/__pycache__/ made it fail with EISDIR.
2026-07-24 14:18:01 +02:00