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

CSP error from Page Editor analysis rule in MV3 #7265

Closed
twschiller opened this issue Jan 4, 2024 · 10 comments · Fixed by #7426
Closed

CSP error from Page Editor analysis rule in MV3 #7265

twschiller opened this issue Jan 4, 2024 · 10 comments · Fixed by #7426
Assignees
Labels
analysis bug Something isn't working mv3

Comments

@twschiller
Copy link
Contributor

twschiller commented Jan 4, 2024

Describe the bug

The TemplateAnalysis Page Editor analysis rule uses new Template which calls eval under the hood

To Reproduce

  1. Load the MV3 extension
  2. Add a trigger
  3. Add the Show Sidebar brick and click into the template field
image

Actual behavior

Error shown due to the invalid template

Discussion

We may need to add a sandbox to the devtools to be able to compile the template (preferred?). Or will need to message the content script which then messages its sandbox

Expected behavior

No error

Additional context

  • 1.8.6-beta.1
@fregante
Copy link
Collaborator

fregante commented Jan 21, 2024

@grahamlangford I think this PR was supposed to fix this issue? Or is it something else?

We may need to add a sandbox to the devtools to be able to compile the template

Yes it's possible to add a sandbox iframe anywhere (except the MV3 background worker) and it's preferred.

@twschiller
Copy link
Contributor Author

twschiller commented Jan 21, 2024

@grahamlangford I think this PR was supposed to fix this issue? Or is it something else?

This is something else. It's a use on Nunjucks in the analysis:

new Template(expression.__value__, undefined, undefined, true);

The analysis is instantiating the template to determine whether or not it's a valid template

@twschiller
Copy link
Contributor Author

@grahamlangford I'd recommend bumping this up as it's a blockers to me using the MV3 build as my daily driver

@grahamlangford
Copy link
Collaborator

@fregante feel free to pick this up when you're looking for next work, otherwise @BLoe or I will pick it up when one of us finishes up our current issues.

@fregante
Copy link
Collaborator

Source of the error:

new Template(expression.__value__, undefined, undefined, true);

@fregante
Copy link
Collaborator

I opened a PR but this requires larger changes that need to be discussed first (visitExpression must be async)

@fregante fregante removed their assignment Jan 25, 2024
@twschiller
Copy link
Contributor Author

I opened a PR but this requires larger changes that need to be discussed first (visitExpression must be async)

I would think we'd want to avoid changing the color of the visitExpression method because that will result in every visitor method needing to be async.

This is what we've done for others:

await Promise.allSettled(this.permissionCheckPromises);

@fregante
Copy link
Collaborator

It's already similar to that but the annotation is not added. What am I doing wrong? The "add annotation" method is called in the async .catch callback but I only see my own logging, not the annotation

@twschiller
Copy link
Contributor Author

twschiller commented Jan 25, 2024

The "add annotation" method is called in the async .catch callback but I only see my own logging, not the annotation

You're missing the await allSettled in the async run method for the analysis. The idea is to keep track of which promises are created in an array and await them being settled

The analysis results go into redux. Changes to the analysis annotation after the fact won't flow through because the Redux state is an immutable copy of the results

@fregante
Copy link
Collaborator

Oh yes I remember seeing this being implemented a while ago actually. I'll give it a try

@fregante fregante self-assigned this Jan 26, 2024
twschiller pushed a commit that referenced this issue Jan 26, 2024
---------
Co-authored-by: Todd Schiller <todd.schiller@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis bug Something isn't working mv3
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants