Skip to content

Conversation

@SaintPatrck
Copy link
Contributor

@SaintPatrck SaintPatrck commented Oct 8, 2025

🎟️ Tracking

PM-26716

📔 Objective

This commit introduces validation for incoming credential exchange requests to ensure they originate from a trusted source (Google Mobile Services).

Previously, the app would immediately process any credential import request. This change adds a validation step at the beginning of the flow. If the request is not valid, an error screen is displayed to the user, preventing further processing.

Specific changes:

  • Add CredentialExchangeRequestValidator to validate incoming import requests by checking the calling package.
  • Introduce a CredentialExchangeRequestValidatorBuilder and a corresponding DSL for easy instantiation.
  • Provide the validator via LocalCredentialExchangeRequestValidator CompositionLocal.
  • In SelectAccountViewModel, validate the request data upon initialization. If validation fails, transition to an error state.
  • Add an error state to the SelectAccountScreen to handle and display validation failures.
  • Update ReviewExportViewModel to rename importCredentialsRequest to importCredentialsRequestData for clarity.
  • Add a new string resource for the import request processing error message.

📸 Screenshots

image

⏰ 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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2025

Logo
Checkmarx One – Scan Summary & Detailsb44f549a-f4e5-410b-9d3d-a929555e3db7

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

@SaintPatrck SaintPatrck marked this pull request as ready for review October 8, 2025 19:47
@SaintPatrck SaintPatrck force-pushed the cxf/app/validate-import-request branch 2 times, most recently from 88f5c94 to 1c79133 Compare October 8, 2025 19:54
as? SpecialCircumstance.CredentialExchangeExport

SelectAccountState(
importRequest = requireNotNull(importRequest?.data),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Couldn't this just be specialCircumstanceManager.specialCircumstance as SpecialCircumstance.CredentialExchangeExport

.onEach(::handleAction)
.launchIn(viewModelScope)
sendEvent(
SelectAccountEvent.ValidateImportRequest(
Copy link
Collaborator

Choose a reason for hiding this comment

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

So we send this here because the validator requires an activity context?

Copy link
Contributor Author

@SaintPatrck SaintPatrck Oct 8, 2025

Choose a reason for hiding this comment

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

Correct. The only mechanism we currently have to validate the request is by ensuring our activity was invoked by GMS. That requires a call to activity.callingPackage.

SelectAccountAction.Internal.SelectionDataReceive(
userState,
itemRestrictedOrgs,
personalOwnershipOrgs,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we add some names to these params?

*/
internal class CredentialExchangeImporterImpl(
private val activity: Context,
@param:VisibleForTesting
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

* @return `true` if the calling package is GMS, `false` otherwise.
*/
override fun validate(
importCredentialsRequestData: ImportCredentialsRequestData,
Copy link
Collaborator

Choose a reason for hiding this comment

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

So we do not actually need the payload to do this check?

Also, if the activity is already open, will the callingPackage value be updated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not at this time. Validations similar to those performed on passkey requests will be performed as the API evolves and makes the information available.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Gotcha

This commit introduces validation for incoming credential exchange requests to ensure they originate from a trusted source (Google Mobile Services).

Previously, the app would immediately process any credential import request. This change adds a validation step at the beginning of the flow. If the request is not valid, an error screen is displayed to the user, preventing further processing.

Specific changes:
- Add `CredentialExchangeRequestValidator` to validate incoming import requests by checking the calling package.
- Introduce a `CredentialExchangeRequestValidatorBuilder` and a corresponding DSL for easy instantiation.
- Provide the validator via `LocalCredentialExchangeRequestValidator` CompositionLocal.
- In `SelectAccountViewModel`, validate the request data upon initialization. If validation fails, transition to an error state.
- Add an error state to the `SelectAccountScreen` to handle and display validation failures.
- Update `ReviewExportViewModel` to rename `importCredentialsRequest` to `importCredentialsRequestData` for clarity.
- Add a new string resource for the import request processing error message.
@SaintPatrck SaintPatrck force-pushed the cxf/app/validate-import-request branch from 1c79133 to fc61db8 Compare October 8, 2025 20:27
@SaintPatrck
Copy link
Contributor Author

Thanks @david-livefront!

@SaintPatrck SaintPatrck enabled auto-merge October 8, 2025 20:39
@codecov
Copy link

codecov bot commented Oct 8, 2025

Codecov Report

❌ Patch coverage is 73.58491% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.58%. Comparing base (572d335) to head (fc61db8).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...e/exportitems/selectaccount/SelectAccountScreen.kt 10.00% 9 Missing ⚠️
...xportitems/selectaccount/SelectAccountViewModel.kt 89.18% 4 Missing ⚠️
.../exportitems/reviewexport/ReviewExportViewModel.kt 66.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5994      +/-   ##
==========================================
+ Coverage   84.57%   84.58%   +0.01%     
==========================================
  Files         720      721       +1     
  Lines       54678    54716      +38     
  Branches     7536     7540       +4     
==========================================
+ Hits        46242    46283      +41     
+ Misses       5802     5793       -9     
- Partials     2634     2640       +6     

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

@SaintPatrck SaintPatrck added this pull request to the merge queue Oct 8, 2025
Merged via the queue into main with commit 3d493bb Oct 8, 2025
9 checks passed
@SaintPatrck SaintPatrck deleted the cxf/app/validate-import-request branch October 8, 2025 21:30
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.

3 participants