The API is a configuration door too, and it asks the parser instead of the rule #1413

Closed
opened 2026-11-11 02:17:15 +00:00 by jaylouisw · 0 comments
Owner

The console has been taught, one rule at a time, what an address is (#1411) and what a mask is (#1249). The HTTP surface edits a port directly - POST /api/topologies/:name/interfaces/:device/:port with { ip, mask } - and it asked the parsers (ipToInt, maskToInt) instead of the rules. Measured against a running server:

POST {"ip":"10.5.5.1","mask":"255.0.255.0"}   -> 200, and the port held a mask that is not a netmask
  sw1#show running-config   ->  ip address 10.5.5.1 255.0.255.0     <- a line the console refuses to type
  sw1#show interfaces Gi0   ->    ip: 10.5.5.1/8                    <- and every surface read it as /8

POST {"ip":"10.5.5.1","mask":"24"}            -> 200, and the port held the *string* "24",
                                                 where the console stores "255.255.255.0" for the same command

The first is the one that matters: the board contained a configuration that cannot be replayed from its own configuration.

POST /load was the third door. Device.hydrate() copies the port document through - right, it is the lab that was saved - but the address is the one field the engine has rules about, so a hand-edited or older document put an impossible mask into state. And when the address itself was impossible the whole load answered 400 Invalid IPv4 address: 300.1.1.1 with the board never replaced, so one bad port cost the operator the rest of the lab.

What should be true

  1. a mask this build would refuse to type is refused by every door that writes one;
  2. one intent has one spelling in state (a prefix length is rewritten to a dotted mask);
  3. a request that is rejected changes nothing;
  4. a document that is loaded is either restored or explained - never adopted into a state no door would accept, and never dropped in silence.
The console has been taught, one rule at a time, what an address is (#1411) and what a mask is (#1249). The HTTP surface edits a port directly - `POST /api/topologies/:name/interfaces/:device/:port` with `{ ip, mask }` - and it asked the **parsers** (`ipToInt`, `maskToInt`) instead of the rules. Measured against a running server: ``` POST {"ip":"10.5.5.1","mask":"255.0.255.0"} -> 200, and the port held a mask that is not a netmask sw1#show running-config -> ip address 10.5.5.1 255.0.255.0 <- a line the console refuses to type sw1#show interfaces Gi0 -> ip: 10.5.5.1/8 <- and every surface read it as /8 POST {"ip":"10.5.5.1","mask":"24"} -> 200, and the port held the *string* "24", where the console stores "255.255.255.0" for the same command ``` The first is the one that matters: the board contained a configuration that cannot be replayed from its own configuration. `POST /load` was the third door. `Device.hydrate()` copies the port document through - right, it is the lab that was saved - but the address is the one field the engine has rules about, so a hand-edited or older document put an impossible mask into state. And when the address itself was impossible the *whole load* answered `400 Invalid IPv4 address: 300.1.1.1` with the board never replaced, so one bad port cost the operator the rest of the lab. ### What should be true 1. a mask this build would refuse to type is refused by every door that writes one; 2. one intent has one spelling in state (a prefix length is rewritten to a dotted mask); 3. a request that is rejected changes nothing; 4. a document that is loaded is either restored or explained - never adopted into a state no door would accept, and never dropped in silence.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jaylouisw/packetforge#1413
No description provided.