Repository navigation
Conversation
…ed fields Clipperz marks locked fields with hidden: true; they were imported as plain-text custom fields or silently dropped. Multiple fields sharing an actionType (e.g. several locked password-type fields) overwrote each other unconditionally, so the last field won the slot and earlier values were lost. - hidden: true fields now import as hidden custom fields - the password slot prefers a field actually labeled as a password; a displaced or additional field becomes a hidden custom field instead of vanishing - the same no-silent-overwrite guard applies to username and url fields fixes #24365
|
|
| const labelLower = field.label != null ? field.label.toLowerCase() : null; | ||
| const labeled = | ||
| labelLower != null && this.passwordFieldNames.indexOf(labelLower) > -1; | ||
| if (cipher.login.password == null || (labeled && !passwordFieldIsLabeled)) { |
There was a problem hiding this comment.
The password-slot condition combines || and &&, making its precedence harder to scan.
| if (cipher.login.password == null || (labeled && !passwordFieldIsLabeled)) { | |
| const passwordSlotIsEmpty = cipher.login.password == null; | |
| const shouldPreferLabeledPassword = labeled && !passwordFieldIsLabeled; | |
| if (passwordSlotIsEmpty || shouldPreferLabeledPassword) { |
Details
✨ AI Reasoning
The password-slot selection condition combines || and && in one expression, requiring the reader to track operator precedence alongside the grouped checks. This makes the decision harder to scan than the surrounding conditions.
Reply on this comment to give feedback or ignore the issue.
More info
| // Prefer a field actually labeled as a password: an earlier | ||
| // unlabeled field that held the slot is demoted to a hidden | ||
| // custom field rather than overwritten. | ||
| if (cipher.login.password != null && passwordFieldLabel != null) { |
There was a problem hiding this comment.
The displaced-password check is nested five control-flow levels deep, making the password-slot handling difficult to follow.
Details
✨ AI Reasoning
The password handling adds conditional branches inside the existing field iteration and switch. The displaced-password check is nested further within the slot-selection branch, making this path five control-flow levels deep and harder to follow.
🔧 How do I fix it?
Keep nesting levels under 4. Extract complex logic into separate functions when indentation exceeds 4 levels.
Reply on this comment to give feedback or ignore the issue.
More info
|
Thank you for your contribution! We've added this to our internal tracking system for review. Details on our contribution process can be found here: https://contributing.bitwarden.com/contributing/pull-requests/community-pr-process. |
| if (cipher.login.password == null || (labeled && !passwordFieldIsLabeled)) { | ||
| // Prefer a field actually labeled as a password: an earlier | ||
| // unlabeled field that held the slot is demoted to a hidden | ||
| // custom field rather than overwritten. | ||
| if (cipher.login.password != null && passwordFieldLabel != null) { | ||
| this.processKvp( | ||
| cipher, | ||
| passwordFieldLabel, | ||
| cipher.login.password, | ||
| FieldType.Hidden, | ||
| ); | ||
| } | ||
| cipher.login.password = this.getValueOrDefault(field.value); | ||
| passwordFieldIsLabeled = labeled; | ||
| passwordFieldLabel = field.label; | ||
| } else { | ||
| this.processKvp(cipher, field.label, field.value, fieldType); | ||
| } |
There was a problem hiding this comment.
This will fix the Avoid deep nesting levels issue detected on line: 62.
Show Fix
Aikido AutoFix Patch Suggestion - medium confidence
This patch mitigates excessive control-flow nesting by introducing a guard clause in the password field handler to exit early when the password slot is already filled and should not be replaced, reducing the nesting depth of the displaced-password check from six to five levels.
| if (cipher.login.password == null || (labeled && !passwordFieldIsLabeled)) { | |
| // Prefer a field actually labeled as a password: an earlier | |
| // unlabeled field that held the slot is demoted to a hidden | |
| // custom field rather than overwritten. | |
| if (cipher.login.password != null && passwordFieldLabel != null) { | |
| this.processKvp( | |
| cipher, | |
| passwordFieldLabel, | |
| cipher.login.password, | |
| FieldType.Hidden, | |
| ); | |
| } | |
| cipher.login.password = this.getValueOrDefault(field.value); | |
| passwordFieldIsLabeled = labeled; | |
| passwordFieldLabel = field.label; | |
| } else { | |
| this.processKvp(cipher, field.label, field.value, fieldType); | |
| } | |
| // If password slot is already filled and this field doesn't have priority, store as custom field | |
| if (cipher.login.password != null && !(labeled && !passwordFieldIsLabeled)) { | |
| this.processKvp(cipher, field.label, field.value, fieldType); | |
| break; | |
| } | |
| // Prefer a field actually labeled as a password: an earlier | |
| // unlabeled field that held the slot is demoted to a hidden | |
| // custom field rather than overwritten. | |
| if (cipher.login.password != null && passwordFieldLabel != null) { | |
| this.processKvp( | |
| cipher, | |
| passwordFieldLabel, | |
| cipher.login.password, | |
| FieldType.Hidden, | |
| ); | |
| } | |
| cipher.login.password = this.getValueOrDefault(field.value); | |
| passwordFieldIsLabeled = labeled; | |
| passwordFieldLabel = field.label; |
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
|
Closing this in favor of #24423, which includes the same Clipperz changes plus the KeePass2 fix. Thanks for pointing it out. |
🎟️ Tracking
fixes #24365
📔 Objective
The Clipperz importer loses or corrupts locked fields on exports that contain more than one:
hidden: true. The importer ignored the flag, so locked secrets landed in the vault as plain-text custom fields.actionType/labelmapping overwrote its target unconditionally. With several password-typed (locked) fields — the usual case, since Clipperz assignsactionType: "password"to locked secrets — the last field won the password slot and all earlier values were discarded entirely. Reporters saw a bogus value in the password field for exactly this reason.Changes:
hidden: truefields import asFieldType.Hiddencustom fields instead of plain text.Regression tests added to
clipperz-html-importer.spec.tscovering hidden-field import, multiple password-typed fields, and the labeled-password preference.📸 Screenshots