Commit 5c5f1f0
authored
feat: Add pdsh-style hostlist expression support (#107)
* feat: Add pdsh-style hostlist expression support (#98)
Implement range expansion syntax for specifying multiple hosts:
- Simple ranges: node[1-5] -> node1, node2, node3, node4, node5
- Zero-padded: node[01-05] -> node01, node02, node03, node04, node05
- Comma-separated: node[1,3,5] -> node1, node3, node5
- Mixed: node[1-3,7] -> node1, node2, node3, node7
- Cartesian product: rack[1-2]-node[1-3] -> 6 hosts
- File input: ^/path/to/file reads hosts from file
Integrate with -H option, --filter, and --exclude options.
Add 52 unit tests for hostlist module.
* fix: Address PR review findings - resource limits and code cleanup (#108)
* fix: Address PR review findings - resource limits and code cleanup
HIGH Priority Fixes:
- Add resource exhaustion protection in parse_hostfile():
* Maximum file size limit of 1 MB
* Maximum line count limit of 100,000 lines
* Check file size before reading to prevent DoS attacks
MEDIUM Priority Fixes:
- Remove code duplication:
* Move is_hostlist_expression() and looks_like_hostlist_range()
from src/main.rs and src/app/nodes.rs to src/hostlist/mod.rs
* Export functions as public API from hostlist module
* Update all call sites to use the exported functions
- Remove unused variable:
* Remove unused 'sign' variable from parse_number() in parser.rs
- Add overflow protection:
* Use checked_mul() for cartesian product allocations in expander.rs
* Return RangeTooLarge error if overflow would occur
* Prevent integer overflow in intermediate calculations
All changes compile successfully and pass tests (cargo test, cargo clippy).
* docs: Add HOSTLIST EXPRESSIONS section and update option docs in manpage1 parent 66b4e36 commit 5c5f1f0
11 files changed
+2068
-80
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
287 | 363 | | |
288 | 364 | | |
289 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
179 | 180 | | |
180 | 181 | | |
181 | 182 | | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
182 | 192 | | |
183 | 193 | | |
184 | 194 | | |
| 195 | + | |
185 | 196 | | |
186 | 197 | | |
187 | 198 | | |
188 | 199 | | |
189 | | - | |
| 200 | + | |
190 | 201 | | |
191 | 202 | | |
192 | 203 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
117 | 139 | | |
118 | 140 | | |
119 | 141 | | |
| |||
166 | 188 | | |
167 | 189 | | |
168 | 190 | | |
169 | | - | |
| 191 | + | |
170 | 192 | | |
171 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
172 | 203 | | |
173 | 204 | | |
174 | 205 | | |
175 | 206 | | |
176 | | - | |
177 | | - | |
| 207 | + | |
178 | 208 | | |
179 | 209 | | |
180 | 210 | | |
181 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
182 | 214 | | |
183 | | - | |
| 215 | + | |
184 | 216 | | |
185 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
186 | 222 | | |
187 | | - | |
| 223 | + | |
188 | 224 | | |
189 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
190 | 228 | | |
191 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
192 | 232 | | |
193 | 233 | | |
194 | 234 | | |
| |||
1094 | 1134 | | |
1095 | 1135 | | |
1096 | 1136 | | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
| 1143 | + | |
| 1144 | + | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
| 1151 | + | |
| 1152 | + | |
| 1153 | + | |
| 1154 | + | |
| 1155 | + | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
| 1200 | + | |
| 1201 | + | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
1097 | 1210 | | |
1098 | 1211 | | |
1099 | 1212 | | |
| |||
0 commit comments