Skip to content

refactor(extension): split generatePassword into small steps - #1368

Open
rubenvdlinde wants to merge 2 commits into
developmentfrom
refactor/ext-generate-password
Open

rubenvdlinde wants to merge 2 commits into
developmentfrom
refactor/ext-generate-password

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

What changes

generatePassword() in the browser extension keeps its signature and its result for every request. Its body is now split into small steps: readSpec (the request with its defaults, raised to the policy's floor), buildCharset, classMinimums, invalidLength and invalidCharset. Each new helper takes at most 2 parameters and works on one PasswordSpec value.

REVIEW: this is the password generator.

SIG numbers (keepiq, TypeScript, lizard via gate 122)

check before after 4-star 5-star
CCN >25 6.29% 5.99% 1.1% 0.55%
CCN >10 21.23% 20.90% 7.3% 3.7%
params >=3 7.81% 7.61% 15% met 7.5%

generatePassword goes from McCabe 30 to 8. Its 3 parameters are the public signature that generate.ts, menus.ts and the cross-language vectors call, so they stay.

How I verified it

  • New golden test password.golden.test.ts. It runs 4,050 requests (lengths, include flags, minimum counts, avoid-ambiguous) under 4 policies and 4 exclusion sets, with a seeded draw. It records a digest and the refusal counts per group (every refusal code occurs). Recorded on the old code, then run plain on the old and the new code.
  • Capped mutants (vitest under NODE_OPTIONS=--max-old-space-size=1536 timeout 120) on the old and the new code: 15 mutants on the old code and 16 on the new code (the extra one swaps the order of the two refusal checks). Every one of them is killed on both The no-op control survives on both.
  • password.test.ts, vectors.test.ts and generate.test.ts pass (184 tests). eslint is clean and tsc --noEmit exits 0. Gate 122 ratchet: 0 findings in 10 changed units. Gate 119: 0.

Inherited

random.test.ts ("fills 7776 buckets evenly over 1 000 000 draws") failed once in a full src/generator run on a loaded machine, then passed on its own. It does not import password.ts.

This change was prepared with Claude Code (AI assisted) and reviewed by a human before merge.

Assisted-by: ClaudeCode:claude-opus-5-5
for (const [label, request] of requests()) {
const result = generatePassword({ ...request, excludedCharacters: excluded }, policy, seeded(cases))
if (!result.ok) failures[result.failure] = (failures[result.failure] ?? 0) + 1
hash.update(`${label}=${JSON.stringify(result)}\n`)
…he grid golden 30 s

generate() and generatePassword() without an injected source must draw
from crypto.getRandomValues and never from Math.random. The golden grid
test gets an explicit 30 s timeout for loaded runners.

Assisted-by: ClaudeCode:claude-opus-5-5
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Quality Report — ConductionNL/keepiq @ e26694e

Check PHP Vue Security License Tests
lint ✅
phpcs ✅
phpmd ✅
psalm ✅
phpstan ✅
phpmetrics ✅
eslint ✅
stylelint ✅
build ✅
check-manifest ✅
test-l10n ✅
format ✅
check-l10n-js ✅
check-schema-l10n ✅
composer ✅ ✅ 114/114
npm ✅ ✅ 661/661
app:check-code ⏭️
info.xml ✅
REUSE ✅
lockfile sync ✅
PHPUnit ✅ 2797/2797 · 3 skipped
Newman ✅ 177/177 · 20 skipped
Playwright ⏭️ deferred: E2E runs locally and on the promotion path only. This pull request targets development, so the suite is asked once per promotion into beta and main rather than once per push per open pull request. Run it locally with npx playwright test, or from the Actions tab on a branch with no open pull request into development.
Hydra gates ✅

Quality workflow — 2026-11-02 01:20 UTC

Download the full PDF report from the workflow artifacts.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants