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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web Extension Transformer: a broken web_accessible_resources field is added #7953

Closed
fregante opened this issue Apr 14, 2022 · 3 comments 路 Fixed by #7958 or #7971
Closed

Web Extension Transformer: a broken web_accessible_resources field is added #7953

fregante opened this issue Apr 14, 2022 · 3 comments 路 Fixed by #7958 or #7971

Comments

@fregante
Copy link
Contributor

馃悰 bug report

When building a web extension, it seems that the hosts specified in the content scripts are copied to the web_accessible_resources field, even if unnecessary, breaking the manifest altogether in some cases.

馃帥 Configuration (.babelrc, package.json, cli command)

No custom configuration. It happens on both build and watch.

馃 Expected Behavior

No web_accessible_resources unless required:

{
	"name": "Awesome Extension",
	"version": "0.0.0",
	"manifest_version": 3,
	"content_scripts": [
		{
			"matches": ["https://github.com/fregante/browser-extension-template/*"],
			"css": ["manifest.b7514168.css"]
		}
	]
}

or at least use a supported origin glob:

{
	"name": "Awesome Extension",
	"version": "0.0.0",
	"manifest_version": 3,
	"content_scripts": [
		{
			"matches": ["https://github.com/fregante/browser-extension-template/*"],
			"css": ["manifest.b7514168.css"]
		}
	],
	"web_accessible_resources": [
		{
			"matches": ["https://github.com/*"],
			"extension_ids": [],
			"resources": []
		}
	]
}

馃槸 Current Behavior

{
	"name": "Awesome Extension",
	"version": "0.0.0",
	"manifest_version": 3,
	"content_scripts": [
		{
			"matches": ["https://github.com/fregante/browser-extension-template/*"],
			"css": ["manifest.b7514168.css"]
		}
	],
	"web_accessible_resources": [
		{
			"matches": ["https://github.com/fregante/browser-extension-template/*"],
			"extension_ids": [],
			"resources": []
		}
	]
}

馃捇 Code Sample

Input manifest:

{
	"name": "Awesome Extension",
	"version": "0.0.0",
	"manifest_version": 3,
	"content_scripts": [
		{
			"matches": [ "https://github.com/fregante/browser-extension-template/*" ],
			"css": [ "content.css" ]
		}
	]
}

馃實 Your Environment

Software Version(s)
Parcel 2.0.0-nightly.1049
parcel/config-webextension 2.4.2-nightly.2674
Node v16.4.2
npm/Yarn 7.18.1
Operating System macOS 11
@101arrowz
Copy link
Member

We'd have to parse out the matches key for content scripts to make this work properly. It's probably better just to not use the matches field at all (though marginally less secure). We could also have the packager skip injecting a file into web_accessible_resources if it's already there.

@fregante
Copy link
Contributor Author

parse out

I think the main issue is that the content scripts allow pathnames other than /* while the other key doesn't. You can probably pass the glob to a regular URL constructor and replace the pathname. That might be a quick fix, as well as avoiding adding web accessible resources when the list of resources is empty.

@101arrowz
Copy link
Member

content scripts allow pathnames other than /*

They also allow raw protocols, <all_urls>, and potentially a bunch of other stuff that it's really not worth the effort to handle. The main reason matches exists is to try to combat fingerprinting AFAIK, you can check for the presence of popular extensions for very accurate browser fingerprinting. But I'd think the injected sites are the ones most likely to want to detect the extension's presence in the first place, so I'm not sure if there's really a good way to avoid this anyway.

For now I'm going to submit a PR that just removes the matches field, maybe it can be worked on more later.

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

Successfully merging a pull request may close this issue.

3 participants