Skip to content

Conversation

SaintPatrck
Copy link
Contributor

🎟️ Tracking

TBD

📔 Objective

This change introduces several improvements to the CXF (Credential Exchange Format) importer, focusing on better handling of credit card items and expanding test coverage.

The primary goal is to enhance the user experience when importing credit card data from CXF files by providing more sensible default names for items. A secondary objective is to add comprehensive integration tests for Dashlane exports to ensure compatibility and prevent regressions.

Behavioral Changes:

When importing a credit card from a CXF file, if the item's main title is empty or consists only of whitespace, the importer will now use the cardholder's name as the item name. If both the title and cardholder name are absent, it will fall back to "Untitled Card". This prevents the creation of nameless credit card entries in the vault.

Specific Changes:

  • cxf/import.rs:

    • The internal add_item helper function has been updated to accept an optional custom_name parameter, allowing the item's name to be overridden during creation.
    • For credit card credentials, logic has been added to check if the item.title is blank. If it is, the cardholder's name (card.cardholder_name) is used as the item name. A fallback to "Untitled Card" is implemented if the cardholder's name is also unavailable.
    • Added several new unit tests to verify the new naming logic for credit cards under various conditions:
      • Empty title uses cardholder name.
      • Whitespace-only title uses cardholder name.
      • Title is present, so cardholder name is ignored for naming.
      • Both title and cardholder name are missing, resulting in a fallback name.
  • cxf/tests/dashlane_import_test.rs:

    • A new integration test file has been added to validate the import of Dashlane-generated CXF files.
    • This includes a full test suite (test_import_dashlane) that parses a sample dashlane_export.json file and asserts that all items (Logins, Cards, Notes, Identities, etc.) are correctly converted into Bitwarden cipher objects.
  • resources/dashlane_export.json:

    • A new resource file containing a sample export from Dashlane has been added. This file serves as the test case for the new Dashlane integration test.
  • cxf/tests/mod.rs:

    • The new dashlane_import_test module is now included in the test suite.

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation
    team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed
    issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

This commit introduces several improvements to the CXF (Credential Exchange Format) importer, focusing on better handling of credit card items and expanding test coverage.

Objective:
The primary goal is to enhance the user experience when importing credit card data from CXF files by providing more sensible default names for items. A secondary objective is to add comprehensive integration tests for Dashlane exports to ensure compatibility and prevent regressions.

Behavioral Changes:
When importing a credit card from a CXF file, if the item's main title is empty or consists only of whitespace, the importer will now use the cardholder's name as the item name. If both the title and cardholder name are absent, it will fall back to "Untitled Card". This prevents the creation of nameless credit card entries in the vault.

Specific Changes:
- **`cxf/import.rs`**:
    - The internal `add_item` helper function has been updated to accept an optional `custom_name` parameter, allowing the item's name to be overridden during creation.
    - For credit card credentials, logic has been added to check if the `item.title` is blank. If it is, the cardholder's name (`card.cardholder_name`) is used as the item name. A fallback to "Untitled Card" is implemented if the cardholder's name is also unavailable.
    - Added several new unit tests to verify the new naming logic for credit cards under various conditions:
        - Empty title uses cardholder name.
        - Whitespace-only title uses cardholder name.
        - Title is present, so cardholder name is ignored for naming.
        - Both title and cardholder name are missing, resulting in a fallback name.

- **`cxf/tests/dashlane_import_test.rs`**:
    - A new integration test file has been added to validate the import of Dashlane-generated CXF files.
    - This includes a full test suite (`test_import_dashlane`) that parses a sample `dashlane_export.json` file and asserts that all items (Logins, Cards, Notes, Identities, etc.) are correctly converted into Bitwarden cipher objects.

- **`resources/dashlane_export.json`**:
    - A new resource file containing a sample export from Dashlane has been added. This file serves as the test case for the new Dashlane integration test.

- **`cxf/tests/mod.rs`**:
    - The new `dashlane_import_test` module is now included in the test suite.
@SaintPatrck SaintPatrck requested a review from a team as a code owner October 10, 2025 20:46
@SaintPatrck SaintPatrck requested a review from coroiu October 10, 2025 20:46
Copy link
Contributor

Logo
Checkmarx One – Scan Summary & Detailsf9a30291-0d7d-42da-89fa-09972f0243c6

Great job! No new security vulnerabilities introduced in this pull request

Copy link

Copy link

codecov bot commented Oct 10, 2025

Codecov Report

❌ Patch coverage is 99.31034% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 78.08%. Comparing base (cc36132) to head (a91fd31).

Files with missing lines Patch % Lines
crates/bitwarden-exporters/src/cxf/import.rs 99.31% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #503      +/-   ##
==========================================
+ Coverage   77.97%   78.08%   +0.10%     
==========================================
  Files         287      287              
  Lines       27673    27808     +135     
==========================================
+ Hits        21579    21714     +135     
  Misses       6094     6094              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant