Closed Bug 1762253 Opened 3 years ago Closed 3 years ago

Managed storage properties are read from Windows registry as incorrect types

Categories

(WebExtensions :: Untriaged, defect)

Firefox 98
defect

Tracking

(Not tracked)

RESOLVED INVALID

People

(Reporter: playbynumbers, Unassigned)

Details

Attachments

(5 files)

Attached file uBlockPolicy.reg.txt

Steps to reproduce:

Note: I'm using uBlock Origin as an example extension affected by this issue, but it's not an issue with the extension itself.

When configuring a managed storage property that uses a complex type like an array or object, Firefox presents the property as a string if the configuration is done via the Windows registry, but as the correct type if configured using a native storage manifest.

Example: configure uBlock Origin's toOverwrite property via the registry as in uBlockPolicy.reg.txt

Actual results:

Firefox reads the registry setting's value and provides it to the extension as-is

browser.storage.managed.get(['toOverwrite'], function(result) {console.log(typeof result.toOverwrite)})
returns string

Expected results:

Firefox reads the json from the registry setting's value, parses it, and provides to the extension as (in this example) an object.

browser.storage.managed.get(['toOverwrite'], function(result) {console.log(typeof result.toOverwrite)})
returns object

This matches behaviour when configuring using a managed storage manifest.

An example managed storage manifest which is read and presented to the extension as an object
browser.storage.managed.get(['toOverwrite'], function(result) {console.log(typeof result.toOverwrite)})
returns object

The Bugbug bot thinks this bug should belong to the 'WebExtensions::Untriaged' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Product: Firefox → WebExtensions

Hello,

I’m from QA and I’m attempting to reproduce the issue in order to confirm it, however I’m having some trouble configuring the registries as I’m not sure I’m doing it correctly and the results of calling “browser.storage.managed.get(['toOverwrite'], function(result) {console.log(typeof result.toOverwrite)})” in the add-on console returns “undefined”. So I’m clearly not doing something right.

As per the attached uBlockPolicy.reg.txt, I’ve added keys up to and including “uBlock0@raymondhil.net” and then I modified the (Default) string’s data to "toOverwrite"="{\"trustedSiteDirectives\": [\"example.com\",\"example.org\"]}". Afterwards, I’ve installed uBlock Origin, and called “browser.storage.managed.get(['toOverwrite'], function(result) {console.log(typeof result.toOverwrite)})” in the add-on’s console. “Undefined” got returned.

I’ve also added a toOverwrire string with {\"trustedSiteDirectives\": [\"example.com\",\"example.org\"]} as data. I’m sure this is not correct but I tried it out just in case.

Attached you can see how I’ve modified the registries.

Would you be so kind as to attach a screenshot/s to show me exactly how the registries look so I can do the same? And maybe if the STR I described above are correct? Thank you !

Flags: needinfo?(playbynumbers)
Attached image 2022-04-01_06h30_15.png

key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Mozilla\Firefox\3rdparty\Extensions\uBlock0@raymondhill.net property toOverwrite set to {"trustedSiteDirectives": ["example.com","example.org"]}

Flags: needinfo?(playbynumbers)

Sure thing, attached.
It should be a property called toOverwrite with the value {"trustedSiteDirectives": ["example.com","example.org"]}, so yours is nearly right except for the extra escaping - the reg export I attached's added that, sorry.
As for it returning undefined, relaunching Firefox might sort that - I believe both the addin and Firefox only pick up new/changed settings at launch, it should be showing up on about:policies if Firefox has got it.
Thanks very much!

Just in case, he config for using a json manifest is (Default) in HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\ManagedStorage\uBlock0@raymondhill.net set to the path of the "example managed storage manifest" file attached. The other registry value has to be removed for this, or it'll take precedence. Settings in this file also won't show up on about:policies.

Hello playbynumbers and thank you for the additional info !

I’ve corrected the property as per you instructions from Comment 6, but when running browser.storage.managed.get(['toOverwrite'], function(result) {console.log(typeof result.toOverwrite)}), “undefined” is still returned and nothing else.

I relaunched Firefox after modifying the registries, restarted my pc and even uninstalled/re-installed uBlock. The result is the same.

about:policies#active does not list anything.

If you have other debugging solutions/ideas, I’m eager to try them.

As for the second part of this (configuring a managed storage manifest), I managed to properly set up the registries as per you instructions, and running browser.storage.managed.get(['toOverwrite'], function(result) {console.log(typeof result.toOverwrite)}) in the add-on console will, as mentioned in the bug description, return “object”.

Flags: needinfo?(playbynumbers)

Hey Mike, can you please take a look?

Flags: needinfo?(mozilla)

Does ublock Origin have an ADMX template for Chrome?

Flags: needinfo?(mozilla)

Sort of, I noticed the issue while creating templates and trying to configure the same setting for Firefox. This template has all the setting for Chrome, Edge, and Firefox in. https://github.com/theaquamarine/uBlock/tree/admx/tools/GroupPolicy

Can you try changing your template to use multiText?

This will cause it to create a MULTI_SZ which means we will preprocess the data in the entry as JSON

<multiText text id="toOverwriteDialog" valueName="toOverwrite" required="true" />

You might need to add a maxLength as well.

Yeah, that's working, thanks! Is that the expected behaviour then, reg_multi_sz get treated as json as reg_sz are handled literally?

Flags: needinfo?(playbynumbers)

Is that the expected behaviour then, reg_multi_sz get treated as json as reg_sz are handled literally?

it's a compromise I had to make because we don't know the schema of the data. Chrome bundles a data file that describe the 3rdparty schema, but I chose not to.

You also could have been more explicit and added nested entries in the registry for the various options and they would have been mapped to the proper objects.

That makes sense.

Thanks very much for all your help!

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: