Commit 92bffc1
committed
fix(fail2ban, needs-restarting, rpm-updates): pad args.TEST defensively
All three plugins store their test fixtures in a multi-file layout
(one file per subprocess call, e.g. fail2ban has -ping, -status,
-status-<jail>; rpm-updates has -upgrades, -installed, -updateinfo;
needs-restarting has -reboothint, -services, -needrestart) and
splice the stderr path and the expected return code into the
lib.lftest.test() call by hand:
lib.lftest.test([args.TEST[0] + '-ping',
args.TEST[1], args.TEST[2]])
That direct index access crashes with IndexError when the user
passes --test=path without trailing commas, because lib.args.csv
splits on commas and leaves a 1-element list. lib.lftest.test()
itself already pads to (stdout, stderr, retc) defensively, but
these three plugins bypass that by consuming args.TEST[1] and
args.TEST[2] before the call.
Minimal fix: pad args.TEST to 3 elements once at main() entry so
the hardcoded indices can't go out of range, and the splice into
the per-command fixture name still works unchanged.
Multi-file fixture convention stays, unlike in
strongswan-connections where it was redundant and collapsed into
a single JSON file. The three plugins here legitimately need
separate fixtures per subprocess call.
Smoke-test: running each plugin with --test=<base> (no trailing
commas) no longer crashes.1 parent 0369070 commit 92bffc1
File tree
3 files changed
+25
-0
lines changed- check-plugins
- fail2ban
- needs-restarting
- rpm-updates
3 files changed
+25
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
93 | 101 | | |
94 | 102 | | |
95 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
586 | 586 | | |
587 | 587 | | |
588 | 588 | | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
589 | 598 | | |
590 | 599 | | |
591 | 600 | | |
| |||
0 commit comments