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

Prevent page or web component from being registered after traffic has been served #675

Merged
merged 1 commit into from
Jul 27, 2024

Conversation

wwwillchen
Copy link
Collaborator

We want to avoid an anti-pattern where Mesop app developers are defining a page or web component dynamically after any traffic has been served (page and web components are registered globally as part of the runtime singleton, and are not scoped to a specific context/request).

For example, we want to prevent the following:

@me.page()
def p():
   s = me.state(State)

  @me.page(security_policy=me.SecurityPolicy(allowed_frame_parents=[s.user_input]))
  def dynamic_page():
     pass

Copy link
Collaborator

@richard-to richard-to left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting.

What is security issue with the late registration?

It's ok to late register user defined components? What is the difference?

@wwwillchen
Copy link
Collaborator Author

Interesting.

What is security issue with the late registration?

It's ok to late register user defined components? What is the difference?

The issue with late registration for web components is that it could result in a user loading a local JS file (which the mesop app developer didn't intend to serve).

I can't think of a specific issue with late-registering user defined components, but it seems pretty weird to do this, so I'm open to prohibiting it too (mostly for consistency and encouraging good practices).

@wwwillchen wwwillchen merged commit bfa29b9 into google:main Jul 27, 2024
3 checks passed
@wwwillchen wwwillchen deleted the prevent_late_registration branch July 27, 2024 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants