refactor(config): check admin password strength at startup - #1193
refactor(config): check admin password strength at startup#1193madhavilosetty-intel wants to merge 1 commit into
Conversation
8e481a9 to
c946bd7
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1193 +/- ##
==========================================
+ Coverage 50.09% 50.19% +0.10%
==========================================
Files 146 146
Lines 13552 13596 +44
==========================================
+ Hits 6789 6825 +36
- Misses 6171 6175 +4
- Partials 592 596 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds an admin-password strength policy check during startup (warn-only) and updates the admin password generator to reliably produce passwords that satisfy the same policy, keeping existing installations unblocked.
Changes:
- Add a startup warning for weak configured admin passwords (length and per-class complexity).
- Update generated admin passwords to include at least one character from each required class and then shuffle using
crypto/rand. - Add unit tests to lock generator output to the policy checker and validate warning behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| cmd/app/main.go | Adds password policy constants/checker, warn-only startup logging, and updates password generation to be policy-aware. |
| cmd/app/main_test.go | Adds tests for policy compliance, shell-safe generation constraints, length errors, and startup warning logging. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
4aa5a0e to
2e6a6ab
Compare
|
Hi Madhavi, thanks for this! The new generator logic looks good — crypto/rand, shuffle, one char per class all check out. A few things to look at before merge:
Small nits: Thanks again — happy to help with any of these! |
97495d0 to
6161b6f
Compare
|
Thanks for the review @rsdmike, all four are fixed in the latest push. |
Warn when the configured admin password is shorter than 8 characters or misses a lowercase letter, uppercase letter, digit, or symbol. Startup continues either way. Generated passwords now draw one character from each required class and shuffle with crypto/rand, so a fresh install satisfies the same rule the warning describes. The generator draws its symbols from @ and * only, because the value gets pasted verbatim into files that mangle punctuation: $ and ! expand in sh, # truncates the value in make (the Makefile does -include .env, where quoting does not help), and % ^ & break cmd.exe's set. Operators may still use any of those themselves. There is no upper length bound, and any non-alphanumeric counts as a symbol: this password is only compared against the login request, so a long passphrase or one using - or _ must not be called weak. Existing passwords are untouched: the generator only runs when no password is configured, and a weak value only warns.
6161b6f to
452bc8d
Compare
Warn when the configured admin password falls short of a length (8-32) and complexity rule. Startup continues.
Generated passwords now draw one character from each required class and shuffle with crypto/rand, so a fresh install satisfies the same rule the warning describes. The generated special set omits $ and ! because the printed password is pasted into AUTH_ADMIN_PASSWORD in .env and compose files, where they expand; both stay accepted when an operator sets them.
Existing passwords are untouched: the generator only runs when no password is configured, and a weak value only warns.