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

Add Malicious Site Protection algorithm pixels #5604

Conversation

CrisBarreiro
Copy link
Contributor

@CrisBarreiro CrisBarreiro commented Feb 6, 2025

Task/Issue URL: https://app.asana.com/0/488551667048375/1209304069660515

Description

  • Add Malicious Site Protection algorithm pixels

Steps to test this PR

Feature 1

Feature 2

Feature 3

UI changes

Before After
!(Upload before screenshot) (Upload after screenshot)

Copy link
Contributor Author

CrisBarreiro commented Feb 6, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@CrisBarreiro CrisBarreiro force-pushed the feature/cris/malicious-site-protection/add-algorithm-pixels branch from 2592f74 to 39aa159 Compare February 6, 2025 12:20
@CrisBarreiro CrisBarreiro force-pushed the feature/cris/malicious-site-protection/add-algorithm-pixels branch 3 times, most recently from 3d36dce to 79c5789 Compare February 10, 2025 16:52
@CrisBarreiro CrisBarreiro changed the base branch from develop to feature/cris/malicious-site-protection/do-not-auto-focus-omnibar-on-resume February 10, 2025 16:52
@CrisBarreiro CrisBarreiro force-pushed the feature/cris/malicious-site-protection/do-not-auto-focus-omnibar-on-resume branch from 7001024 to 97b9ac5 Compare February 11, 2025 18:10
@CrisBarreiro CrisBarreiro force-pushed the feature/cris/malicious-site-protection/add-algorithm-pixels branch from 79c5789 to 40577d8 Compare February 11, 2025 18:11
Base automatically changed from feature/cris/malicious-site-protection/do-not-auto-focus-omnibar-on-resume to feature/cris/malicious-site-protection/integrate-privacy-dashboard-2 February 11, 2025 18:11
Base automatically changed from feature/cris/malicious-site-protection/integrate-privacy-dashboard-2 to develop February 12, 2025 07:39
@CrisBarreiro CrisBarreiro force-pushed the feature/cris/malicious-site-protection/add-algorithm-pixels branch from 40577d8 to 3cff846 Compare February 13, 2025 14:26
Copy link
Contributor

@cmonfortep cmonfortep left a comment

Choose a reason for hiding this comment

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

Code looks good, left a note in Asana about testing.

@CrisBarreiro CrisBarreiro force-pushed the feature/cris/malicious-site-protection/add-algorithm-pixels branch 3 times, most recently from 3910261 to d3e8362 Compare February 21, 2025 17:07
Copy link
Contributor

@cmonfortep cmonfortep left a comment

Choose a reason for hiding this comment

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

LGTM

Few comments, and I see also a bunch of logs that not sure if we want to keep, but we should use the right tag for consistency. (I've commented in some of them, but there are a more).

@@ -243,7 +270,7 @@ class RealMaliciousSiteBlockerWebViewIntegration @Inject constructor(
} else {
Safe
}
processedUrls.clear()
processedUrls[url] = isMalicious
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a previous check if (checkId == currentCheckId.get()) that validates this is related to the latest site trying to load. If we detect another site has started loading, we return safe to avoid showing the phishing page in the wrong context. However, we are assigning Safe to possible phishing pages here. I believe the right value here is processedUrls[url] = it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes a lot of sense, thanks!

@@ -397,4 +397,6 @@ enum class AppPixelName(override val pixelName: String) : Pixel.PixelName {
SET_AS_DEFAULT_PROMPT_CLICK("m_set-as-default_prompt_click"),
SET_AS_DEFAULT_PROMPT_DISMISSED("m_set-as-default_prompt_dismissed"),
SET_AS_DEFAULT_IN_MENU_CLICK("m_set-as-default_in-menu_click"),

MALICIOUS_SITE_DETECTED_IN_IFRAME("m_malicious-site-protection_iframe-loaded"),
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this one here if we have MaliciousSitePixelName? this should be inside malicious module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because MaliciousSitePixelName belongs to the MSP implementation module, and the MSP module knows nothing about iframes, that happens on the browser level

Match(it.hostname, it.url, it.regex, it.hash, feed)
} else {
null
withTimeout(1000) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't found why 1000 is the timeout here in the pixel definition, or in Asana. Do we have it somewhere? would be good to move it into a const, and leave a comment or link with context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cmonfortep, I believe this was discussed on a meeting. We recently created a task to document timeouts and it looks like all other platforms are using a different value, so I'll probably need to update this one. We also want to update the timeout for dataset downloads, and I've created a task for it, so for now I'm just extracting it to a constant. I've asked whether we want to update this timeout in particular to 5s, so in case the answer is yes, I'll use the task for dataset downloads timeout to also update this one

if (!exempted) {
if (currentBrowserViewState().maliciousSiteDetected && previousSite?.url == url.toString()) return
Timber.tag("Cris").d("Received MaliciousSiteWarning for $url, feed: $feed, exempted: false, clientSideHit: $clientSideHit")
Copy link
Contributor

Choose a reason for hiding this comment

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

if you want to keep this log, we should use a the right tag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed the tag, since we don't seem to be setting any specific one for this class

@@ -137,6 +140,9 @@ class RealMaliciousSiteBlockerWebViewIntegration @Inject constructor(
if (!isEnabled()) {
return IsMaliciousViewData.Safe
}

Timber.d("shouldIntercept ${request.url}")
Copy link
Contributor

Choose a reason for hiding this comment

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

👀

val exemptedUrl = exemptedUrlsHolder.exemptedMaliciousUrls.firstOrNull { it.url.toString() == decodedUrl }

if (exemptedUrl != null) {
Timber.tag("MaliciousSiteDetector").d("Previously exempted, skipping $decodedUrl as ${exemptedUrl.feed}")
Timber.d("Previously exempted, skipping $decodedUrl as ${exemptedUrl.feed}")
Copy link
Contributor

Choose a reason for hiding this comment

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

I see we've removed tag, not sure if intentional

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, similar to #5604 (comment), we don't use tag for other logs in this class

@CrisBarreiro CrisBarreiro force-pushed the feature/cris/malicious-site-protection/add-algorithm-pixels branch from d3e8362 to 991e53b Compare March 3, 2025 09:01
@CrisBarreiro CrisBarreiro merged commit 2796ef7 into develop Mar 3, 2025
6 checks passed
@CrisBarreiro CrisBarreiro deleted the feature/cris/malicious-site-protection/add-algorithm-pixels branch March 3, 2025 09:16
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.

2 participants