Commit 33030ac
authored
chore: backport the 2.2.0 release-branch fixes to develop (#1006)
* fix(net): three plaintext-guard fixes for 2.2.0, and CI on release PRs (#1004)
Carries the plaintext-guard fixes onto the release branch. The first two
were raised in review of #988 and were never fixed there, because the work
landed on a branch targeting `develop` (#1002, since merged) while
`release/2.2.0` is cut from `main`.
- **A redirect bypassed the guard entirely.** `send` validated the initial
URI and then handed the request to a client that follows redirects by
default, below `BaseClient.send` where the guard never sees the hop. An
approved private endpoint answering 30x with a public `http://` target
would have had that connection made. Automatic redirects are now off, so a
30x returns to the caller as the response it is — for `https://` too.
- **The Host header dropped the port.** Rebinding `http://ollama.lan:11434`
to its resolved address wrote `Host: ollama.lan`, a different authority
from the one typed, and a local model server is essentially never on 80.
- **A zoned link-local address was refused.** `Uri` escapes the zone id, so
`fe80::1%wlan0` reaches the guard as `fe80::1%25wlan0`, which
`InternetAddress.tryParse` rejects; the address fell through to a DNS
lookup that cannot succeed and the caller was told the server is
unreachable. `dart:io` performs the same unescaping itself before it
connects, which is why an unguarded client worked. Fail-closed, and it
predates 2.2.0. Found by audit, not by review.
The review also objected that the guard's tests used a recording fake, which
cannot follow a redirect, so they pinned that `followRedirects` was set
false rather than that it stops the second hop. There is now a group running
against a real `HttpServer` on loopback and a real `dart:io` client, over
both branches through the guard, with a control test proving an unguarded
client really does follow the 302.
All three fixes are mutation-tested: reverting the redirect guard fails four
tests, the port two, the zone two.
Also adds `release/**` to the workflow's `pull_request` trigger. This PR
opened with exactly one check — the Copilot reviewer — while reporting
`CLEAN`, which is the silent failure the trigger list's own comment warns
about, now hit on a release branch.
Cherry-picked from #1002 and from #1005, which is closed in favour of this.
`plaintext_destination_guard.dart` and its test file are byte-identical
across both branches.
(cherry picked from commit ae8ad7c)
* fix(bulk-add): round a converted quantity to the precision the field takes
The amount field accepts at most two decimals: `_quantityPattern` in
bulk_add_screen.dart is both the submit check and the field's input
formatter. A converted imperial quantity carries far more — `1 lb` is
453.59237 g — and the prefill passed it through untouched.
So an ordinary imperial line was unloggable. `1 lb mince` prefilled
"453.59237", the submit check refused it with a message naming only the
field, and because that check validates the whole batch before writing
anything, one such row blocked every correct row beside it. Recovery was
worse: the pattern is anchored, so the formatter matched nothing on the
non-conforming string and the field blanked entirely on the first
keystroke.
Rounding at the prefill is what keeps the two in step. The floor is the
same concern from the other end — a positive quantity below 0.005 would
round to "0.00", which the check rejects for being non-positive, and a
backend serving weight can be that small.
`lb` is a deliberate unit, not a stray one: it is in the model tool
schema enum because the model was otherwise mapping "1 pound of mince"
onto `oz`, so the model path reached this too.
(cherry picked from commit fcb2323)1 parent e44c9b8 commit 33030ac
5 files changed
Lines changed: 209 additions & 6 deletions
File tree
- .github/workflows
- lib
- core/utils
- features/add_meal/presentation/bloc
- test/unit_test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 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 | + | |
91 | 117 | | |
92 | 118 | | |
93 | 119 | | |
| |||
103 | 129 | | |
104 | 130 | | |
105 | 131 | | |
106 | | - | |
| 132 | + | |
107 | 133 | | |
108 | 134 | | |
109 | 135 | | |
| |||
Lines changed: 22 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
| 438 | + | |
439 | 439 | | |
440 | 440 | | |
441 | 441 | | |
442 | | - | |
| 442 | + | |
443 | 443 | | |
444 | 444 | | |
445 | 445 | | |
| |||
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
500 | | - | |
501 | | - | |
502 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
503 | 520 | | |
504 | 521 | | |
505 | 522 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
224 | 296 | | |
225 | 297 | | |
226 | 298 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
171 | 252 | | |
172 | 253 | | |
173 | 254 | | |
| |||
0 commit comments