A port count has an upper bound, and there is one expansion rule rather than two (#1319) #1320
No reviewers
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1320
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/port-count-bound"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A port count has an upper bound, and there is one expansion rule rather than two.
Fixes #1319.
Two findings in the same corner. The second is a boot-time denial of service.
1. Two copies of the expansion rule, and a test that could not see the difference
devices/registry.jsandengine/topology.jseach had anexpandInterfaces. The test meant to keep them in stepcompared port names over the catalogue — so a divergence in any other field, on any spec outside the catalogue,
or in any edge case was invisible by construction.
Measured: over all 2,015 specs the copies agree on every field of every port today, so the drift had not
happened — but they had already diverged where it counts:
engine/topology.jscarried the comment "the cleanest end state is for engine/topology.js to call this functioninstead of keeping its own copy … so for now the two are kept in step by that test." The test does not keep them in
step; nothing can.
2.
counthas a documented ceiling that nothing enforceddocs/DEVICE_SCHEMA.mdsayscountis 1..512. The gate was "a positive whole number", so:count: 1000000passed → a million ports at boot;count: Infinitypassed too (Math.floor(Infinity) === Infinity,Infinity > 0) → expanding it never returns.With the two files reverted, the new test dies with exit 134 after 2 of 15 checks — an allocation failure
building the list, before the server serves anything. One spec file, or one hand-edited saved board (
/loadneverpasses through the loader).
Fixes
engine/topology.jsdelegates todevices/registry.effectiveInterfaces— one implementation, the end state thatfile has described since #71.
portCountProblem()is the one rule for a template's count, used by the loader (whichnames the file) and by the expander (which covers the doors the loader does not guard). The message names the range
and prints
InfinityasInfinity, notnull.Evidence
test/port-count.test.js— 15 checks: the engine no longer loops over a count of its own and agrees with theregistry on every field of every port of 2,015 specs; nine impossible counts (
0, -1, 1.5, "8", Infinity, -Infinity, NaN, 513, 1000000) all refused with the range named; 512 still expands to 512 and an absent count to one port; twoimpossible spec files reported by the loader while the sane one beside them loads; and a device built straight from a
spec — the door the loader does not guard — refused the same way, leaving no half-built device behind.
test/fuzz-importer.test.js: its two count expectations pinned the old wording ("must be a positive whole number")— precisely the wording that was not enough. Updated to the range, with the reason stated in the test.
docs/DEVICE_SCHEMA.md: "One expansion rule", and the ceiling paragraph now says where the rule lives.Suite: 175 suites, 6,985 assertions, 0 failed.