Skip to content

[PM-34125] feat: Add card text analysis pipeline#6720

Draft
SaintPatrck wants to merge 1 commit intocard-scanner/1-generalize-camera-previewfrom
card-scanner/2-text-analysis-pipeline
Draft

[PM-34125] feat: Add card text analysis pipeline#6720
SaintPatrck wants to merge 1 commit intocard-scanner/1-generalize-camera-previewfrom
card-scanner/2-text-analysis-pipeline

Conversation

@SaintPatrck
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-34125

📔 Objective

Add the complete text analysis pipeline for credit card scanning:

  • CardNumberUtils: Shared Luhn validation and card number sanitization (ui module)
  • CardDataParser: Interface and regex-based implementation for extracting card details from OCR text (number, expiry, CVV, cardholder name)
  • CardTextAnalyzer: ML Kit Text Recognition integration for camera frame analysis
  • CardScanOverlay: Camera overlay composable for scan UI
  • CardScanData: Data class for parsed card fields
  • CardNumberUtils in app: Brand detection (detectCardBrand) using VaultCardBrand

Includes full test coverage for parser logic, Luhn validation, and sanitization.

@SaintPatrck SaintPatrck added the ai-review-vnext Request a Claude code review using the vNext workflow label Mar 26, 2026
@github-actions github-actions bot added app:password-manager Bitwarden Password Manager app context app:authenticator Bitwarden Authenticator app context t:deps Change Type - Dependencies t:feature Change Type - Feature Development labels Mar 26, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2026

Overall Assessment: APPROVE

This PR adds the complete text analysis pipeline for credit card scanning. Changes include Luhn validation and card number sanitization utilities, a regex-based OCR data parser for extracting card details, ML Kit Text Recognition integration for camera frame analysis, a card scan overlay composable, and card brand detection. The implementation correctly follows the existing QrCodeAnalyzer pattern, with an appropriate upgrade to AtomicBoolean for thread-safe gating around the asynchronous ML Kit processing. Test coverage is thorough for the parser and validation logic.

Code Review Details

No findings. The code is well-structured, follows established codebase conventions (interface/impl pairs, CompositionLocal provision, @OmitFromCoverage for platform-dependent code, test fixtures), and includes comprehensive test coverage for the parsing and validation logic.

@SaintPatrck SaintPatrck removed the t:deps Change Type - Dependencies label Mar 26, 2026
@codecov
Copy link

codecov bot commented Mar 26, 2026

Codecov Report

❌ Patch coverage is 66.00000% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.65%. Comparing base (c04ac3b) to head (d776756).

Files with missing lines Patch % Lines
...m/x8bit/bitwarden/ui/vault/util/CardNumberUtils.kt 44.73% 0 Missing and 21 partials ⚠️
...orm/feature/cardscanner/util/CardDataParserImpl.kt 75.60% 0 Missing and 10 partials ⚠️
...itwarden/ui/platform/composition/LocalProviders.kt 33.33% 2 Missing ⚠️
...atform/feature/cardscanner/util/CardNumberUtils.kt 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@                             Coverage Diff                              @@
##           card-scanner/1-generalize-camera-preview    #6720      +/-   ##
============================================================================
- Coverage                                     85.72%   85.65%   -0.07%     
============================================================================
  Files                                           944      950       +6     
  Lines                                         60660    60493     -167     
  Branches                                       8566     8592      +26     
============================================================================
- Hits                                          51998    51813     -185     
+ Misses                                         5682     5673       -9     
- Partials                                       2980     3007      +27     
Flag Coverage Δ
app-data 17.89% <0.00%> (+0.11%) ⬆️
app-ui-auth-tools 20.86% <1.00%> (+0.06%) ⬆️
app-ui-platform 15.60% <1.00%> (-0.40%) ⬇️
app-ui-vault 26.83% <19.00%> (+0.09%) ⬆️
authenticator 6.53% <1.00%> (+0.02%) ⬆️
lib-core-network-bridge 4.24% <0.00%> (+0.01%) ⬆️
lib-data-ui 1.03% <48.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ 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.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 26, 2026

Logo
Checkmarx One – Scan Summary & Detailsb1c77782-29ff-43dc-9373-2831ab6431b5

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

Add the complete text analysis pipeline for credit card scanning:
- CardNumberUtils: sanitize, Luhn validation, brand detection
- CardDataParser: interface and implementation for OCR text parsing
- CardTextAnalyzer: ML Kit-based camera frame analysis
- CardScanOverlay: camera overlay composable
- CardScanData: data class for parsed card fields
- FakeCardTextAnalyzer: test fixture
- LocalProviders: composition local for CardTextAnalyzer
@SaintPatrck SaintPatrck force-pushed the card-scanner/2-text-analysis-pipeline branch from 2333a61 to d776756 Compare March 26, 2026 11:37
@github-actions github-actions bot added the t:deps Change Type - Dependencies label Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review-vnext Request a Claude code review using the vNext workflow app:authenticator Bitwarden Authenticator app context app:password-manager Bitwarden Password Manager app context t:deps Change Type - Dependencies t:feature Change Type - Feature Development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant