Repository navigation
Commit 8ebbc93
Per-rule disable/enable with a persisted spec (#17)
* Per-rule disable/enable with a persisted spec
nftables has no disabled state: a rule is in the ruleset or it is not. So
disabling can only mean deleting the rule while remembering enough to put it
back exactly where it was, and that memory has to survive a reboot or the
feature is a delete with a friendly name.
The memory goes in the file the Save action already writes, as comment lines
`nft -f` ignores and this tool parses. The live half stays nft's own listing,
byte for byte, so the boot path is untouched and a machine that loses this
tool still boots the rules it had; a file written before this existed still
loads, and a ruleset with nothing disabled still writes that same v1 file, so
nobody who does not press D sees the format at all.
D disables the selected rule and D again puts it back at the recorded index.
The statement replayed on the way back is captured from the live match when
the rule was disabled, by the same rebuild a move uses, so the refusals are
the ones E already makes: a rule this tool does not hold in full is refused
before anything is deleted. The disabled rule stays on screen as a greyed-out
row drawn from the spec rather than from the kernel.
Disabling does not join a staged batch. The ruleset change and the record of
it have to agree, and a batch defers the one past the other; so it applies on
its own and then offers the save, with the header saying `1 disabled, unsaved`
until that save happens.
Everything read off disk is guarded before it becomes an nft statement or a
table cell, with two fuzz targets on the invariants.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MCypLQF5AD8JD831Ea9S9q
* Bound the LCS table the save diff allocates
The Save preview diffs the capture against the file at the save path, and only
one of those two is this tool's own output. The other is whatever is on disk,
and the diff is a quadratic longest-common-subsequence over lines: a file that
is not a table listing — a log somebody redirected there, a ruleset a hundred
times this tool's own — asks for a table quadratic in its size before a
character is drawn. CodeQL flags the allocation, and it is right to.
Past the bound the diff degrades to "the whole file is replaced", which is
what installing over it does anyway.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MCypLQF5AD8JD831Ea9S9q
* Bound each side of the save diff, not the product
CodeQL follows the line count of a file this tool did not write into the
allocation and does not read the product of two int64s as a bound on either.
A plain per-side limit says the same thing and is the same fix.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MCypLQF5AD8JD831Ea9S9q
---------
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>1 parent 1afcf1e commit 8ebbc93
22 files changed
Lines changed: 2096 additions & 73 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
| 135 | + | |
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| |||
309 | 309 | | |
310 | 310 | | |
311 | 311 | | |
| 312 | + | |
312 | 313 | | |
313 | 314 | | |
314 | 315 | | |
| |||
467 | 468 | | |
468 | 469 | | |
469 | 470 | | |
470 | | - | |
| 471 | + | |
471 | 472 | | |
472 | 473 | | |
473 | 474 | | |
| |||
502 | 503 | | |
503 | 504 | | |
504 | 505 | | |
505 | | - | |
506 | | - | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
507 | 536 | | |
508 | 537 | | |
509 | 538 | | |
| |||
583 | 612 | | |
584 | 613 | | |
585 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
586 | 618 | | |
587 | 619 | | |
588 | 620 | | |
589 | | - | |
| 621 | + | |
| 622 | + | |
590 | 623 | | |
591 | 624 | | |
592 | 625 | | |
| |||
612 | 645 | | |
613 | 646 | | |
614 | 647 | | |
615 | | - | |
616 | | - | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
617 | 653 | | |
618 | 654 | | |
619 | 655 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
102 | 114 | | |
103 | 115 | | |
104 | 116 | | |
| |||
230 | 242 | | |
231 | 243 | | |
232 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
233 | 252 | | |
234 | 253 | | |
235 | 254 | | |
| |||
243 | 262 | | |
244 | 263 | | |
245 | 264 | | |
| 265 | + | |
| 266 | + | |
246 | 267 | | |
| 268 | + | |
| 269 | + | |
247 | 270 | | |
248 | 271 | | |
249 | 272 | | |
| |||
265 | 288 | | |
266 | 289 | | |
267 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
268 | 303 | | |
269 | 304 | | |
270 | 305 | | |
| |||
347 | 382 | | |
348 | 383 | | |
349 | 384 | | |
350 | | - | |
| 385 | + | |
351 | 386 | | |
| 387 | + | |
| 388 | + | |
352 | 389 | | |
353 | 390 | | |
354 | 391 | | |
| |||
562 | 599 | | |
563 | 600 | | |
564 | 601 | | |
| 602 | + | |
| 603 | + | |
565 | 604 | | |
566 | 605 | | |
567 | 606 | | |
| |||
0 commit comments