Skip to content

Map generate character classes to opt-in CLI flags - #229

Open
Steve0x2a wants to merge 2 commits into
bitwarden:mainfrom
Steve0x2a:fix/generate-opt-in-character-flags
Open

Steve0x2a wants to merge 2 commits into
bitwarden:mainfrom
Steve0x2a:fix/generate-opt-in-character-flags

Conversation

@Steve0x2a

Copy link
Copy Markdown

handleGenerate now maps character-class booleans to the CLI's opt-in flags (--uppercase, --lowercase, --number, --special) instead of emitting unregistered --no* options.

Credit: @WhimsicalCat
Fixes #223

@Steve0x2a
Steve0x2a requested a review from a team as a code owner August 25, 2026 09:15
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@bitwarden-bot

Copy link
Copy Markdown

Thank you for your contribution! We've added this to our internal tracking system for review.
ID: PM-42447
Link: https://bitwarden.atlassian.net/browse/PM-42447

Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process.

@SaintPatrck SaintPatrck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Steve0x2a

Thank you for your contribution. Please sign the CLA so we can accept these changes.

Comment thread src/handlers/cli.ts Outdated
Comment on lines 159 to 170
if (validatedArgs.uppercase) {
params.push('--uppercase');
}
if (validatedArgs.lowercase === false) {
params.push('--noLowercase');
if (validatedArgs.lowercase) {
params.push('--lowercase');
}
if (validatedArgs.number === false) {
params.push('--noNumbers');
if (validatedArgs.number) {
params.push('--number');
}
if (validatedArgs.special === false) {
params.push('--noSpecial');
if (validatedArgs.special) {
params.push('--special');
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ We only push a flag when a class is true, so an explicit false is silently dropped instead of excluded. bw generate reinstates its default classes whenever none of the four flags is present, so {uppercase: false} still comes back with uppercase enabled. Could we default the three CLI-defaulted classes to true so an explicit exclusion actually holds?

Suggested change
if (validatedArgs.uppercase) {
params.push('--uppercase');
}
if (validatedArgs.lowercase === false) {
params.push('--noLowercase');
if (validatedArgs.lowercase) {
params.push('--lowercase');
}
if (validatedArgs.number === false) {
params.push('--noNumbers');
if (validatedArgs.number) {
params.push('--number');
}
if (validatedArgs.special === false) {
params.push('--noSpecial');
if (validatedArgs.special) {
params.push('--special');
}
if (validatedArgs.uppercase ?? true) {
params.push('--uppercase');
}
if (validatedArgs.lowercase ?? true) {
params.push('--lowercase');
}
if (validatedArgs.number ?? true) {
params.push('--number');
}
if (validatedArgs.special) {
params.push('--special');
}

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.

generate tool cannot emit special characters, and any false value fails with an unknown option

4 participants