Commit 245ea8d
committed
fix(tooling): stop inventory.sh from answering wrongly on bad input
Six ways the selector could hand a caller the wrong host list, all of them
silent, which is the failure mode the script exists to prevent:
- `--tag ""` matched nothing, so the filter was dropped and the ENTIRE fleet
came back at exit 0. An unset `$DEVNET` in `--tag "$DEVNET"` would act on
hosts on other chains, the mirror image of the typo case already guarded.
- The unknown-argument path printed help to stdout, and the documented idiom
captures stdout: a mistyped flag fed 1.4 KB of usage text into a host loop.
- `--not-tag T` hard-failed when no host carried T, contradicting the script's
own `--tag validator` == `--tag <devnet> --not-tag aggregator` equivalence.
An exclusion matching nothing is well-defined; only `--tag` is checked now.
- Nothing validated nodes/subnets, so one space in the tags column shifted every
later field: a role landed in `nodes`, `--tag validator` returned the
aggregator, and a word reached a caller expecting a count. The file is now
refused with the row named, rather than answered from.
- Tag arguments were glob-expanded against the cwd, so `--tag 'devnet-*'` could
silently resolve to a different group than typed.
- `usage()` sliced help from a hardcoded line range; it now ends at the first
non-comment line, so editing the header cannot truncate `--help`.
The documented recipes were also unrunnable as written: `inventory.sh` is not on
PATH, and the `| tr` pipeline discarded the exit code the script sets so
carefully, turning any error into an empty-but-successful host list.1 parent 79b2aeb commit 245ea8d
3 files changed
Lines changed: 68 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | 71 | | |
71 | | - | |
72 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
Lines changed: 7 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
27 | 34 | | |
28 | 35 | | |
29 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
30 | 59 | | |
31 | 60 | | |
32 | 61 | | |
| |||
35 | 64 | | |
36 | 65 | | |
37 | 66 | | |
38 | | - | |
| 67 | + | |
39 | 68 | | |
40 | | - | |
| 69 | + | |
41 | 70 | | |
42 | 71 | | |
43 | 72 | | |
| |||
95 | 124 | | |
96 | 125 | | |
97 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
98 | 138 | | |
99 | 139 | | |
100 | 140 | | |
| |||
113 | 153 | | |
114 | 154 | | |
115 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
116 | 163 | | |
117 | 164 | | |
118 | 165 | | |
119 | 166 | | |
120 | 167 | | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | 168 | | |
126 | 169 | | |
127 | 170 | | |
| |||
0 commit comments