Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/10354 - In-App Feedback: Phone number, SSN, Email are not properly recognized if they end in punctuation #10395

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

matt-guest-wilcore
Copy link
Contributor

Description of Change

Ticket

The in-app feedback screen doesn't allow for personal information such as phone numbers, SSN and emails, if they are detected then we must show the user a warning.

As described in the ticket, if someone input an email but ended it with punctuation then we wouldn't show the user the warning.

This PR fixes that issue, we can now detect sensitive information even if it has punctuation.

Screenshots/Video

Testing

Navigate to the developer screen to find the in-app feedback screen

  • Tested on iOS
  • Tested on Android

Reviewer Validations

Verify that sensitive information like emails, phone numbers and SSNs that end in punctuation trigger a warning alert.

EX:

PR Checklist

Reviewer: Confirm the items below as you review

  • PR is connected to issue(s)
  • Tests are included to cover this change (when possible)
  • No magic strings (All string unions follow the Union -> Constant type pattern)
  • No secrets or API keys are checked in
  • All imports are absolute (no relative imports)
  • New functions and Redux work have proper TSDoc annotations

For QA

Run a build for this branch

Copy link
Contributor

@DonMcCaugheyUSDS DonMcCaugheyUSDS left a comment

Choose a reason for hiding this comment

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

The checkStringForPII() function likely still has the inverse problem when there is leading punctuation (e.g. My SS:123-45-6789 or even call me415-321-1234). Looking at EMAIL_REGEX_EXP and its mates, they're anchored to the start (^) and end ($). Did you consider alternate regex patterns that might find the forbidden patterns without requiring the string to be split on whitespace?

Also, this seems like an easy function to unit test, but I didn't see any tests for it. If I didn't miss something, would you add unit tests?

Matthew Guest - Work added 4 commits January 5, 2025 21:39
…. Updated checkStringForPII to rely on regex patterns instead of splitting by whitespace. Preserved original phone and mailto regex patterns for linkify by creating separate constants, resolving issues in getLinkifiedText tests.
… detection, and have not had issues. However, I couldn't do the same for phone numbers. I opted to keep separate patterns for linking and PII as phone number detection is a lot more complex than SSN, and emails.
… the PII function and the other for linking and other uses. I think mixing the two into a unified pattern creates a lot of complexity as PII relies less on anchoring and is more flexible while linking is more strict. I also had issues with mailto links not working with past changes, so maintaining two different sets of patterns solved this.
Copy link
Contributor

@DonMcCaugheyUSDS DonMcCaugheyUSDS left a comment

Choose a reason for hiding this comment

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

Approved, thanks Matt for improving this and adding tests! Please fix the linting error and merge as it.

I am requesting some follow-on work. You added tests for the InAppFeedbackScreen component, which is a correct and important to test, but you use this component to drive all the test cases for checkStringForPII().

I strongly prefer that tests focus on the smallest unit of code possible, which is the checkStringForPII() function in this case. Testing InAppFeedbackScreen is important too, but is more of an integration test than a unit test.

Small, focused tests are easier to understand and maintain and usually run significantly faster. In this case, InAppFeedbackScreen.test.tsx is 177 lines long, requires loading heavyweight React libraries and creating a new InAppFeedbackScreen component instance for each test case and waiting asynchronously for the component to respond to events. I bet that unit tests for just checkStringForPII() run 10 to 100 times faster and significantly smaller code than InAppFeedbackScreen.test.tsx. And from personal experience, focused tests will make extending checkStringForPII() much easier (and I can envision us discovering new PII patterns to filter for).

Please keep a couple representative test cases for InAppFeedbackScreen and look into adding unit tests for checkStringForPII(). Let me know if there's anything challenging about writing smaller, focused tests like this.

@github-actions github-actions bot added the FE-With QA A PR waiting for QA Activity label Jan 17, 2025
@matt-guest-wilcore
Copy link
Contributor Author

@DonMcCaugheyUSDS I was making the updates for the follow on work you mentioned and I found an issue with the checkStringForPII function itself. Basically, my current implementation erases the entire string and returns the censored portion but the entire string needs to be maintained with the appropriate pattern censored. This became apparent as I was writing the unit tests for checkStringForPII.

The fix shouldn't be too drastic but I'd wait on merging this until I get that fix in. My apologies for the delay.

Matthew Guest - Work and others added 4 commits January 21, 2025 12:26
…allows any instance of a pattern to be identified in a string. This also fixes the issue where checkStringForPII was returning only the censored portion of the message, now we return the whole message with all sensitive info replaced with placeholder data. I also wrote unit tests for checkStringForPII function.
… wanted to remove a few test cases from the integration tests I wrote earlier to improve test runtime and cutback on redundancy.
Copy link
Contributor

@kimmccaskill-oddball kimmccaskill-oddball left a comment

Choose a reason for hiding this comment

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

Looks to address Don's concerns and I appreciate all the test cases!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FE-With QA A PR waiting for QA Activity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants