Reject consecutive hyphen GitHub logins#480
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThe PR tightens GitHub login validation by adding a negative lookahead to reject logins containing consecutive hyphens. The regex pattern is updated identically across three modules (accounts, config, ledger), and test coverage verifies the constraint is enforced across account validation, deploy readiness, and wallet registration flows. ChangesGitHub login validation: consecutive hyphen constraint
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
er1c-cartman
left a comment
There was a problem hiding this comment.
Reviewed PR #480 at current head 0f89e7c8dc43bd5520980a5a25793135afb8df21. No blocker found in this focused pass.
Evidence checked:
- Diff is scoped to six files:
app/accounts.py,app/config.py,app/ledger/service.py,tests/test_account_validation.py,tests/test_deploy_readiness.py, andtests/test_wallets.py. - The new
^(?!.*--)...login regex consistently applies to public account normalization, deploy admin/labeler validation, and wallet registration, sogithub:bad--loginis rejected across the surfaces that previously accepted it. - Existing valid-login behavior is preserved by the original character/length/start/end constraints; the change only adds the consecutive-hyphen exclusion.
- Regression coverage exercises API account lookup, public account page lookup, MCP
get_balance, wallet registration, and deploy readiness validation. - GitHub CI run #635 completed successfully on this head.
Validation run locally:
PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ~/.local/bin/uv run --extra dev python -m pytest tests/test_account_validation.py::test_account_views_reject_consecutive_hyphen_github_login tests/test_wallets.py::test_wallet_registration_rejects_consecutive_hyphen_github_login tests/test_deploy_readiness.py::test_deploy_readiness_rejects_invalid_admin_or_labeler_logins -q->3 passedPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ~/.local/bin/uv run --extra dev python -m pytest tests/test_account_validation.py tests/test_account_routes.py tests/test_wallets.py tests/test_deploy_readiness.py -q->67 passed~/.local/bin/uv run --extra dev ruff check app/accounts.py app/config.py app/ledger/service.py tests/test_account_validation.py tests/test_wallets.py tests/test_deploy_readiness.py-> passed~/.local/bin/uv run --extra dev ruff format --check app/accounts.py app/config.py app/ledger/service.py tests/test_account_validation.py tests/test_wallets.py tests/test_deploy_readiness.py->6 files already formatted~/.local/bin/uv run --extra dev mypy app-> successPYTEST_DISABLE_PLUGIN_AUTOLOAD=1 ~/.local/bin/uv run --extra dev python scripts/docs_smoke.py-> docs smoke okgit diff --check origin/main...HEAD-> clean- changed-diff secret scan -> no matches
Assessment: this is a good focused hardening move for MergeWork because it keeps account identities closer to GitHub-createable login rules before those values enter public pages, MCP responses, deploy settings, or wallet-link records.
akmhatey-ai
left a comment
There was a problem hiding this comment.
Reviewed PR #480 at current head 0f89e7c8dc43bd5520980a5a25793135afb8df21.
I would make one small test-coverage change before merge. The runtime behavior looks fixed, but the deploy-readiness regression does not isolate the new consecutive-hyphen case.
tests/test_deploy_readiness.py::test_deploy_readiness_rejects_invalid_admin_or_labeler_logins now checks both bad_login and bad--login in the same admin_logins / github_accepted_labelers tuples. Since bad_login was already invalid before this PR, that test would still pass if app/config.py regressed to the old regex that accepted consecutive hyphens.
Local proof on this head, without changing files, by monkeypatching app.config.GITHUB_LOGIN_RE to the old regex:
bad--login only -> []
current test shape -> ['MERGEWORK_ADMIN_LOGINS must contain valid GitHub logins', 'MERGEWORK_GITHUB_ACCEPTED_LABELERS must contain valid GitHub logins']
So the account/API/MCP and wallet coverage prove the new rule, but the deploy-readiness surface is only incidentally covered by an older invalid underscore login. Please split or parameterize the deploy-readiness test so bad--login is tested alone for admin_logins and github_accepted_labelers.
Validation I ran:
uv run --extra dev python -m pytest tests/test_account_validation.py::test_account_views_reject_consecutive_hyphen_github_login tests/test_wallets.py::test_wallet_registration_rejects_consecutive_hyphen_github_login tests/test_deploy_readiness.py::test_deploy_readiness_rejects_invalid_admin_or_labeler_logins -q->3 passeduv run --extra dev python -m pytest tests/test_account_validation.py tests/test_account_routes.py tests/test_wallets.py tests/test_deploy_readiness.py -q->67 passeduv run --extra dev python -m pytest -q->416 passeduv run --extra dev ruff check app/accounts.py app/config.py app/ledger/service.py tests/test_account_validation.py tests/test_wallets.py tests/test_deploy_readiness.py-> passeduv run --extra dev ruff format --check app/accounts.py app/config.py app/ledger/service.py tests/test_account_validation.py tests/test_wallets.py tests/test_deploy_readiness.py->6 files already formatteduv run --extra dev python -m mypy app-> successuv run --extra dev python scripts/docs_smoke.py-> docs smoke okgit diff --check origin/main...HEAD-> cleangit diff origin/main...HEAD | gitleaks stdin --no-banner --redact --exit-code 1-> no leaks found
This is a coverage gap, not a claim that the current production behavior is still accepting bad--login.
0f89e7c to
a7620dd
Compare
|
Updated in What changed:
Fresh validation:
|
akmhatey-ai
left a comment
There was a problem hiding this comment.
Follow-up on my earlier changes-requested review for head 0f89e7c8dc43bd5520980a5a25793135afb8df21: current head a7620dde2b9fa73aa889b6990197bf94113da26d resolves the deploy-readiness coverage gap I flagged.
The new test_deploy_readiness_rejects_consecutive_hyphen_admin_or_labeler_logins() checks bad--login as the only admin/labeler value, so the deploy-readiness path now directly proves the consecutive-hyphen rule instead of relying on the already-invalid bad_login case.
I revalidated the current head:
- focused consecutive-hyphen/deploy/account/wallet tests: 4 passed
- related deploy/account/wallet suites: 65 passed
- full pytest: 417 passed
- Ruff check and format check: passed
- mypy app: success
- docs smoke: ok
git diff --check origin/main...HEAD: clean- diff-scoped Gitleaks: no leaks
Approved for the current head. This is a follow-up to the existing review thread, not a new bounty claim.
rebel117
left a comment
There was a problem hiding this comment.
Reviewed PR #480 at current head for Bounty #447.
Checked files: app/accounts.py, app/config.py, app/ledger/service.py, tests/test_account_validation.py, tests/test_deploy_readiness.py, tests/test_wallets.py.
Evidence:
- Inspected the regex change in all 3 locations:
r"^(?!.*--)[a-z0-9](?:[a-z0-9-]{0,37}[a-z0-9])?$". The negative lookahead(?!.*--)rejects any login containing consecutive hyphens. - Confirmed GitHub actually forbids consecutive hyphens in usernames (per their signup rules), so this aligns the validation with the real constraint.
- Verified the test covers all three entry points: API (
/api/v1/accounts/github:bad--login), HTML page (/accounts/github:bad--login), and MCP (get_balancewithgithub:bad--login). All three return error responses. - Checked
test_deploy_readiness.pychanges: the existingtest_deploy_readiness_rejects_invalid_admin_or_labeler_loginsnow includesbad--loginalongsidebad_login, and a new dedicated test covers consecutive-hyphen-only case. - Confirmed
test_wallets.pyverifies wallet registration also rejectsbad--loginthroughregister_wallet. - Cross-referenced: the same
GITHUB_LOGIN_REpattern is defined in 3 separate modules (accounts.py,config.py,ledger/service.py). This PR updates all 3 consistently.
Verdict: Correct and well-tested. One minor observation: having the same regex in 3 files is a DRY concern, but that is pre-existing and out of scope for this PR. No blockers.
Summary
Bounty #406.
Evidence
The existing GitHub login regex allowed
bad--loginanywhere login validation was used. GitHub username guidance for managed usernames treats names with two consecutive dashes as not creatable, so accepting them locally lets invalidgithub:*accounts pass public account, wallet-link, and admin config validation.Before the fix,
/api/v1/accounts/github:bad--loginand MCPget_balanceaccepted the account shape instead of rejecting it as an invalid GitHub login.Validation
uv run --extra dev python -m pytest tests/test_account_validation.py::test_account_views_reject_consecutive_hyphen_github_login tests/test_wallets.py::test_wallet_registration_rejects_consecutive_hyphen_github_login tests/test_deploy_readiness.py::test_deploy_readiness_rejects_invalid_admin_or_labeler_logins -q-> 3 passeduv run --extra dev python -m pytest tests/test_account_validation.py tests/test_account_routes.py tests/test_wallets.py tests/test_deploy_readiness.py -q-> 67 passeduv run --extra dev ruff check app/accounts.py app/config.py app/ledger/service.py tests/test_account_validation.py tests/test_wallets.py tests/test_deploy_readiness.py-> passeduv run --extra dev ruff format --check app/accounts.py app/config.py app/ledger/service.py tests/test_account_validation.py tests/test_wallets.py tests/test_deploy_readiness.py-> 6 files already formatteduv run --extra dev python -m mypy app-> successuv run --extra dev python scripts/docs_smoke.py-> docs smoke okgit diff --check-> cleanOut of scope
No auth, payout, wallet signature, ledger balance, or database migration behavior changed.
Summary by CodeRabbit