Commit 0ce9343
committed
fix(plugins): harden fragile version regexes and slicing (#1070)
Three plugins parsed version strings in ways that either had a real
bug or only worked by accident:
- axenita-stats: the slice `axenita_ver[8 : 8 + axenita_ver.find('-') - 1]`
was designed for the fixed `release-14.0.8-...` format and happened to
extract "14.0.8" when the patch was a single digit. For any longer
patch (e.g. `14.0.12`) the slice silently truncated the trailing
digit, and for 2-digit majors it would slide out of bounds. Replace
with a simple `split('-')[1]` and document why the dots are stripped
(perfdata wants a numeric value).
- keycloak-version: the regex `r'n (.*)'` happened to match the "n " in
the word "Version" of `/opt/keycloak/version.txt` (contents:
`Keycloak - Version 25.0.4`) and capture the version tail. Replace
with an explicit `r'[Vv]ersion\s+(\d+(?:\.\d+)*)'`. Also fall through
to the API fallback when the file is present but does not match,
instead of aborting with "Keycloak not found".
- openvpn-version: the regex `r'N (\d+\.\d+\.\d+)'` matched the "N" at
the end of "OpenVPN" plus the following space. Anchor the match on
"OpenVPN" explicitly.1 parent 7ef6a8e commit 0ce9343
File tree
4 files changed
+30
-11
lines changed- check-plugins
- axenita-stats
- keycloak-version
- openvpn-version
4 files changed
+30
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
272 | 281 | | |
273 | 282 | | |
274 | 283 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
174 | 180 | | |
175 | 181 | | |
176 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
132 | 132 | | |
133 | 133 | | |
134 | 134 | | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
140 | 140 | | |
| 141 | + | |
141 | 142 | | |
142 | 143 | | |
143 | 144 | | |
| |||
0 commit comments