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

[FEAT] Test domain against filter lists in extension #3362

Closed
9 tasks done
micsthepick opened this issue Sep 2, 2024 · 10 comments
Closed
9 tasks done

[FEAT] Test domain against filter lists in extension #3362

micsthepick opened this issue Sep 2, 2024 · 10 comments
Labels
enhancement New feature or request fixed issue has been addressed

Comments

@micsthepick
Copy link

micsthepick commented Sep 2, 2024

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is NOT a YouTube, Facebook or Twitch report. These sites MUST be reported by clicking their respective links.
  • This is not a support issue or a question. For support, questions, or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

Description

I would like to test a simple list I have written, to see if the domain(s) I want to block and not to block are working as intended. Ideally I'd like to not actually visit e.g. a malware or phishing domain if all I want to do is block it and ensure that the extension is working correctly

A specific URL where the issue occurs.

ANY

Steps to Reproduce

  1. Import a list (optional)
  2. Visit a site that should be blocked

Expected behavior

  1. Import list as above
  2. somewhere in the extension, test domain
  3. observe whether the domain is blocked, and where in the lists the appropriate rules are applied, like as if viewing a log entry

Actual behavior

oops, I visited the site, accidentally because the list was written wrong.

uBO version

Latest (1.59.0 as of writing)

Browser name and version

Any

Operating System and version

Any

@github-actions github-actions bot deleted a comment Sep 2, 2024
@garry-ut99
Copy link

garry-ut99 commented Sep 2, 2024

Duplicate of:

unless you have seen that thread already, and you were inspired by it, and you still want to embed the solution into uBO itself to be even better.


Also another idea for your problem is to put the same domain list not only into uBO, but also into Hosts file: if uBO fails to block a domain, you will see that in uBO logger, but the domain will be still blocked by Hosts file outside browser.

@micsthepick
Copy link
Author

unless you have seen that thread already, and you were inspired by it, and you still want to embed the solution into uBO itself to be even better.

The above is a discussion, which is why when I did a "cursory search" for simillar issues I didn't find anything. To be clear I didn't see that discussion until you linked it. You seem to be very agressive toward me, but I will take that as potentially a language barrier. From now on I request that you please assume good faith from me.

@krystian3w

This comment was marked as spam.

@micsthepick
Copy link
Author

@krystian3w if I understand what you are saying, my one critique of that is that an isolated env. is going to be far more effort to spin up one for maybe a couple of domains in my use case (writing a few rules at a time).

@garry-ut99

This comment was marked as off-topic.

@krystian3w
Copy link

krystian3w commented Sep 2, 2024

Maybe someone can advise you on how to pretend that there is network traffic without deactivating the network card and real tabs with address bar (maybe commands to standard devtools).

@micsthepick

This comment was marked as off-topic.

@gorhill
Copy link
Member

gorhill commented Sep 2, 2024

In the meantime, a workaround to test various URLs is to use the format used by the benchmarkDatasetURL advanced setting. Create a JSON file where each line matches the following format:

{"frameUrl":"https://www.guildwars2.com/en/","url":"https://www.google-analytics.com/analytics.js","cpt":"script"}

frameUrl is the context from within which url is fetched. cpt is the type of the resource (I am not sure what cpt means, the format comes from Ghostery benchmark data).

Set benchmarkDatasetURL to the URL of the file, for example file:///home/.../path/to/requests.json, then go to dashboard, Support, click More, then click SNFE: Benchmark. This will load the file and evaluate each JSON line through the static network filtering engine. This won't be reported in the logger because the benchmark is meant to measure performance in normal condition, but the number of blocked/not blocked requests will be reported.

When the content of the JSON file is changed, best to restart uBO to ensure is not using the older version as it holds onto the last loaded version for a while to avoid overhead of reloading the file everytime we click benchmark/report buttons.

gorhill added a commit to gorhill/uBlock that referenced this issue Sep 2, 2024
Related issue:
uBlockOrigin/uBlock-issues#3362

There used to be a way to test URL against the network filtering engine,
but this was removed in a distant past during refactoring.

The ability has been brought back through uBO's own developer tools,
accessible through the _More_ button in the _Support_ pane in the
dashboard.

To query the static network filtering engine, enter the following
in the text editor:

snfe?url-to-test [type] [url-of-context]

`snfe?` is a prompt indicating the intent to query the static network
filtering engine.

At a minimum there must be a URL to test.

Optionally the type of the resource to match, default to `xhr` if
none specified. Also optionally, the context from within which the
request is made. Example:

Enter:
snfe?https://www.google-analytics.com/analytics.js

Result:
url: https://www.google-analytics.com/analytics.js
blocked: ||google-analytics.com^

Enter:
snfe?https://www.google-analytics.com/analytics.js script

Result:
url: https://www.google-analytics.com/analytics.js
type: script
blocked: ||google-analytics.com^
modified: ||google-analytics.com/analytics.js$script,redirect-rule=google-analytics_analytics.js:5

Enter:
snfe?https://example.com/

Result:
url: https://example.com/
not blocked

Enter:
snfe?https://example.com/ ping

Result:
url: https://example.com/
type: ping
blocked: *$ping,3p
@gorhill
Copy link
Member

gorhill commented Sep 2, 2024

This can now be done in dashboard => Support => More button, by using the snfe? prompt in the text editor.

Please refer to commit message for usage: gorhill/uBlock@b7ed3b45ed

@garry-ut99

This comment was marked as off-topic.

@uBlockOrigin uBlockOrigin locked as resolved and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

5 participants