Commit a01ac02
committed
Address codex review on PinSecureMode
Two findings:
1. The persist failure was logged at debug, which silently weakens the
stated pin-on-success guarantee: login succeeds, the keyring write
succeeds, but auth_storage = secure is never persisted. A later
default-secure read with a transient keyring probe failure would
then fall back to plaintext, undoing the protection the pin was
supposed to provide. Promote to log.Warnf so the user sees the
failure during login and can investigate (file permissions, etc.).
Login is still not blocked: pinning is best-effort.
2. PinSecureMode re-resolved the storage mode with StorageModeUnknown,
so a caller-supplied override was invisible to the source check.
The function's doc said "No-op when the user already chose a mode
explicitly", but only env and config were detected; an override
secure mode would still pin auth_storage = secure to config,
silently turning an ephemeral per-invocation choice into a
persistent one. No caller passes a non-empty override today, so the
bug was dormant, but fix it before someone wires up a flag and
notices the behavior.
PinSecureMode now takes an override StorageMode parameter, and the
three call sites (main login, discoveryLogin, runInlineLogin) pass
storage.StorageModeUnknown explicitly. New table-driven case covers
the override path.
Co-authored-by: Isaac1 parent a15feae commit a01ac02
4 files changed
Lines changed: 31 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
298 | 298 | | |
299 | 299 | | |
300 | 300 | | |
301 | | - | |
| 301 | + | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| |||
639 | 639 | | |
640 | 640 | | |
641 | 641 | | |
642 | | - | |
| 642 | + | |
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
433 | 433 | | |
434 | 434 | | |
435 | 435 | | |
436 | | - | |
| 436 | + | |
437 | 437 | | |
438 | 438 | | |
439 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
255 | 261 | | |
256 | 262 | | |
257 | 263 | | |
258 | | - | |
| 264 | + | |
259 | 265 | | |
260 | 266 | | |
261 | 267 | | |
| |||
265 | 271 | | |
266 | 272 | | |
267 | 273 | | |
268 | | - | |
| 274 | + | |
269 | 275 | | |
270 | 276 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
| 389 | + | |
389 | 390 | | |
390 | 391 | | |
391 | 392 | | |
| |||
412 | 413 | | |
413 | 414 | | |
414 | 415 | | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
415 | 426 | | |
416 | 427 | | |
417 | 428 | | |
| |||
426 | 437 | | |
427 | 438 | | |
428 | 439 | | |
429 | | - | |
| 440 | + | |
430 | 441 | | |
431 | 442 | | |
432 | 443 | | |
| |||
440 | 451 | | |
441 | 452 | | |
442 | 453 | | |
443 | | - | |
| 454 | + | |
444 | 455 | | |
445 | 456 | | |
446 | 457 | | |
447 | 458 | | |
448 | 459 | | |
449 | | - | |
| 460 | + | |
450 | 461 | | |
451 | 462 | | |
452 | 463 | | |
| |||
461 | 472 | | |
462 | 473 | | |
463 | 474 | | |
464 | | - | |
465 | | - | |
| 475 | + | |
| 476 | + | |
466 | 477 | | |
467 | 478 | | |
468 | 479 | | |
| |||
0 commit comments