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

Issue with adminSettings on FireFox. #2986

Closed
aswgxf opened this issue Sep 6, 2017 · 27 comments
Closed

Issue with adminSettings on FireFox. #2986

aswgxf opened this issue Sep 6, 2017 · 27 comments

Comments

@aswgxf
Copy link

aswgxf commented Sep 6, 2017

I am having issues with the adminSettings config option in Firefox. I am trying to disable the uBlock filters - Privacy and EasyPrivacy filters. The string I am using works fine in Chrome (60.0.3112.113, uBlock Origin version 1.14.8) but does not appear to do anything in Firefox.
Chrome:
I have this text in the registry location for policies:
{"selectedFilterLists":["plowe-0","malware-1","malware-0","easylist","ublock-unbreak","ublock-badware","ublock-filters","user-filters"]}

Firefox:
I have this line in my cck2.cfg file:
defaultPref("extensions.ublock0.adminSettings", "{"selectedFilterLists":["plowe-0","malware-1","malware-0","easylist","ublock-unbreak","ublock-badware","ublock-filters","user-filters"],"filterLists":{"assets/thirdparties/pgl.yoyo.org/as/serverlist":{"off":false},"assets/thirdparties/mirror1.malwaredomains.com/files/justdomains":{"off":false},"assets/thirdparties/www.malwaredomainlist.com/hostslist/hosts.txt":{"off":false},"assets/thirdparties/easylist-downloads.adblockplus.org/easylist.txt":{"off":false},"assets/ublock/unbreak.txt":{"off":false},"assets/ublock/badware.txt":{"off":false},"assets/ublock/filters.txt":{"off":false},"assets/user/filters.txt":{"off":false},"assets/ublock/privacy.txt":{"off":true},"assets/ublock/experimental.txt":{"off":true},"assets/thirdparties/easylist-downloads.adblockplus.org/easyprivacy.txt":{"off":true}}}");

I have also tried going to about:config and pasting the string I have in the registry for chrome into the adminSettings preference then restarting the browser.

  • OS/version: Windows 10 1607
  • Browser/version: Firefox ESR 52.3.0
  • uBlock Origin version: 1.14.4

I tested downgrading to uBlock Origin version 1.13.8 (on Firefox) and the settings were properly applied. Did the method of configuration change in the newer version?

Sorry if this has been addressed elsewhere.

@gorhill
Copy link
Owner

gorhill commented Sep 6, 2017

uBO is now a webext extension in AMO. This means it no longer fetches its adminSettings value from about:config, it has no knowledge of about:config. The adminSettings value for a webext is supposed to be in browser.storage.managed, but Firefox does not support this API yet: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/storage.

This is the related bugzilla entry: https://bugzilla.mozilla.org/show_bug.cgi?id=1230802.

@aswgxf
Copy link
Author

aswgxf commented Sep 7, 2017

Hmm... Alright. So is there no way to set those settings in the new version? Would there be any major issues if we installed 1.13.8 and turned off auto update?

@gorhill
Copy link
Owner

gorhill commented Sep 7, 2017

There is no way that I know -- but I am no reference regarding admin stuff. 1.13.8 is just fine, it still is a recent version.

@gorhill
Copy link
Owner

gorhill commented Sep 8, 2017

Fyi, somebody posted some sort of custom solution i the bugzilla entry: https://bugzilla.mozilla.org/show_bug.cgi?id=1230802#c13.

@Quix0r
Copy link

Quix0r commented Sep 8, 2017

Maybe similar issue? 1.14.4 stopped working here, settings are gone, block list is gone. Maybe no blocking at all? 52.3.0 (64-bit) ESR. I try to use older version and disable auto-update.

Edit: 1.13.4 is the last version working here on ESR.

@aswgxf
Copy link
Author

aswgxf commented Sep 11, 2017

gorhill, I saw that, though it looks like that is something to be implemented in the addon itself?

@gorhill
Copy link
Owner

gorhill commented Sep 11, 2017

I have this line in my cck2.cfg file:

Where is that cck2.cfg file? Is it a local file, or is it accessed through some URL?

@aswgxf
Copy link
Author

aswgxf commented Sep 11, 2017

cck2.cfg is a config file used by the CCK2 wizard for some customization. It's loaded through pref("general.config.filename", "cck2.cfg") in the autoconfig.js. It is included in our package source files for installing Firefox.

@gorhill
Copy link
Owner

gorhill commented Sep 11, 2017

So if I understand correctly it's a local file once Firefox is installed? If there was a URL uBO could use to fetch something in a standard way until the storage.managed becomes available, I could implement a workaround. Since it would be a built-in URL, this really would have to be a URL which makes sense for typical deployment of Firefox everywhere. Something like uBO trying to read http://localhost/uBlock0.cfg (assuming localhost is not forbifdden by webext of course).

@aswgxf
Copy link
Author

aswgxf commented Sep 11, 2017

Yes, once installed, the file exists here: "C:\Program Files (x86)\Mozilla Firefox\cck2.cfg". It is technically a javascript file, not just a text config, I'm not sure if that would cause any issues. We would also be able to include any additional files we need to during the install. (Linking this because it seems possibly related: https://bugzilla.mozilla.org/show_bug.cgi?id=1386427)

@gorhill
Copy link
Owner

gorhill commented Sep 11, 2017

the file exists here: "C:\Program Files (x86)\Mozilla Firefox\cck2.cfg". It is technically a javascript file, not just a text config, I'm not sure if that would cause any issues.

uBO can't read that file, webext does not allow to fetch using file:/// URL. This would have to be http:///https://.

@aswgxf
Copy link
Author

aswgxf commented Sep 11, 2017

Hmm... I did some looking and I might be able to create a login script to modify "C:\Users<username>\AppData\Roaming\Mozilla\Firefox\Profiles<Profile>\browser-extension-data\uBlock0@raymondhill.net\storage.js"

I don't think we'd be able to provide the file via http:// without having a local webserver running.

This is definitely not an ideal solution, so if you have any other ideas that would be amazing.

@gorhill
Copy link
Owner

gorhill commented Sep 12, 2017

if you have any other ideas

Well your idea of modifying storage.js seems the most sensible. It's a json file, so I suppose it's just a matter of writing a python script to import values.

@aswgxf
Copy link
Author

aswgxf commented Sep 25, 2017

Update about storage.manged: https://bugzilla.mozilla.org/show_bug.cgi?id=1230802

Also, for anyone else in this situation, I managed to work around it by deploying the extension using a registry key (https://developer.mozilla.org/en-US/Add-ons/Adding_extensions_using_the_Windows_registry) and then wrote a script that runs on first logon to delete any old versions of the extension from the user's profile and to create/overwrite the storage.js in the profile.

If you aren't working with existing profiles, you should just be able to put the storage.js file in \core\defaults\profile\browser-extension-data\uBlock0@raymondhill.net\storage.js
to have it be copied over when any new profile is created.

@gorhill
Copy link
Owner

gorhill commented Sep 29, 2017

Update, https://blog.mozilla.org/addons/2017/09/28/webextensions-in-firefox-57/:

A basic implementation of chrome.storage.managed has landed. This allows administrators or other applications to configure extensions for users. In Firefox you can place a JSON file in a directory, just like for native messaging. For example, a file called favourite-colour-examples@mozilla.org.json could be placed in the appropriate place:

{
 "name": "favourite-colour-examples@mozilla.org",
 "description": "ignored",
 "type": "storage",
 "data": {
    "colour": "blue!"
 }
}

Then in the favourite-colour-examples@mozilla.org extension:

 browser.storage.managed.get('colour').then((colour) => {
   console.log(colour);
 });

So for uBO I am totally guessing this would look like:

{
 "name": "uBlock0@raymondhill.net",
 "description": "ignored",
 "type": "storage",
 "data": {
    "adminSettings": "[settings as JSON-encoded string]"
 }
}

Double-encoding to JSON can be tricky, so this tool should be helpful: http://raymondhill.net/ublock/adminSetting.html.

@spec1re
Copy link

spec1re commented Sep 30, 2017

Hello Gorhill, this sounds great.

In Firefox you can place a JSON file in a directory

Any idea which directory this is?

@gorhill
Copy link
Owner

gorhill commented Sep 30, 2017

@gorhill
Copy link
Owner

gorhill commented Sep 30, 2017

By the way, whoever succeeds using that basic implementation of storage.managed in Firefox, that would be nice to provide feedback about it in this bugzilla issue:

Please note that bug 1386427 contains a basic implementation of chrome.storage.managed and I've successfully used this to configure extensions. A test of uBlock Origin would be appreciated.

@spec1re
Copy link

spec1re commented Oct 2, 2017

Hello Gorhill, I cant make it work, here the steps I did:

Created a uBlock0@raymondhill.net.json file and put it in

C:\Program Files\Mozilla Firefox\browser\extensions

with following content:

{
 "name": "uBlock0@raymondhill.net",
 "description": "ignored",
 "type": "storage",
 "data": {
    "adminSettings": "{\"userFilters\":\"www.bild.de##script:contains(!de.bild.cmsKonfig)\\n\"}"
 }
}

and added this reg-key:

[HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ManagedStorage]
"uBlock0@raymondhill.net"="C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\uBlock0@raymondhill.net.json"

But userFilters is empty, do I miss something?

FF 57.0 b3 x64
uBlock 1.14.10

@gorhill
Copy link
Owner

gorhill commented Oct 2, 2017

Best is to provide feedback in the bugzilla issue, I know nothing about administration stuff, and even less about Windows stuff.

@gorhill
Copy link
Owner

gorhill commented Oct 2, 2017

I tried your file with Linux and all worked fine here -- using 58.0a1 (2017-10-01) (64-bit).

@spec1re
Copy link

spec1re commented Oct 4, 2017

No luck here, also tried it with the nightly 58.0a1 and reg-keys in HKEY_CURRENT_USER and
HKEY_LOCAL_MACHINE. Maybe this function is not implemented in the windows version yet?

@spec1re
Copy link

spec1re commented Feb 8, 2018

Okay, I've got it working finally!

OS/version: Windows 7 Pro x64 SP1
Browser/version: Firefox 58.0.2 (64-bit)
uBlock Origin version: 1.15.4

First create a json file eg. in:

C:\Program Files\Mozilla Firefox\browser\extensions\uBlock0@raymondhill.net.json

with content:

{
 "name": "uBlock0@raymondhill.net",
 "description": "ignored",
 "type": "storage",
 "data": {
    "adminSettings": "{\"userFilters\":\"www.test.de##script:contains(!de.test.cmsKonfig)\\n\"}"
 }
}

add following reg-key:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ManagedStorage\uBlock0@raymondhill.net]
@="C:\\Program Files\\Mozilla Firefox\\browser\\extensions\\uBlock0@raymondhill.net.json"

and start FireFox

image

So the json file and reg-key, can now easily deployed via AD extensions.

Example files: json+regkey.zip

@Quix0r
Copy link

Quix0r commented Feb 8, 2018

Maybe close the ticket when your issue is solved?

@flagoda
Copy link

flagoda commented Mar 15, 2021

Hi,
Is it possible to this just add new rules / whitelist ans not overwrite all after firefox restart ?
For example in my JSON, i have add mydomain.com in whitelist, but users have it's own websites in whitelist, and this method overwrite Ublock whitelists and replace by only mydomain.com (instead of only add mydomain.com to whitelist)

@gwarser
Copy link
Contributor

gwarser commented Mar 15, 2021

@flagoda
Copy link

flagoda commented Mar 15, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants