-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
feat: disable cookie access under restricted sandboxes #1080
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d6ad43c
feat: disable cookie access under restricted sandboxes
josegonzalez f936df1
tests: assert that the error length is 1
josegonzalez bab71de
tests: 2 log lines are output in the restricted iframe test
josegonzalez 0609adf
add app interaction
d28c961
there should be warnings
74c9a97
warn once
b87ad7b
changelog
b4e7824
Merge branch 'dev' into iframe-sandbox-support
Marc-Andre-Rivet 126b7a1
undo bad copypasta
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| from multiprocessing import Value | ||
|
|
||
| import dash | ||
| from dash.dependencies import Input, Output | ||
| from dash.exceptions import PreventUpdate | ||
|
|
||
| import dash_html_components as html | ||
|
|
||
|
|
||
| def test_rdif001_sandbox_allow_scripts(dash_duo): | ||
| app = dash.Dash(__name__) | ||
| call_count = Value("i") | ||
|
|
||
| N_OUTPUTS = 50 | ||
|
|
||
| app.layout = html.Div([ | ||
| html.Button("click me", id="btn"), | ||
| ] + [html.Div(id="output-{}".format(i)) for i in range(N_OUTPUTS)]) | ||
|
|
||
| @app.callback( | ||
| [Output("output-{}".format(i), "children") for i in range(N_OUTPUTS)], | ||
| [Input("btn", "n_clicks")] | ||
| ) | ||
| def update_output(n_clicks): | ||
| if n_clicks is None: | ||
| raise PreventUpdate | ||
|
|
||
| call_count.value += 1 | ||
| return ["{}={}".format(i, i + n_clicks) for i in range(N_OUTPUTS)] | ||
|
|
||
| @app.server.after_request | ||
| def apply_cors(response): | ||
| response.headers["Access-Control-Allow-Origin"] = "*" | ||
| response.headers["Access-Control-Allow-Headers"] = "Origin, X-Requested-With, Content-Type, Accept, Authorization" | ||
| return response | ||
|
|
||
| dash_duo.start_server(app) | ||
|
|
||
| iframe = """ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <iframe src="{0}" sandbox="allow-scripts"> | ||
| </iframe> | ||
| </html> | ||
| """ | ||
|
|
||
| html_content = iframe.format(dash_duo.server_url) | ||
|
|
||
| dash_duo.driver.get("data:text/html;charset=utf-8," + html_content) | ||
|
|
||
| dash_duo.driver.switch_to.frame(0) | ||
|
|
||
| dash_duo.wait_for_element('#output-0') | ||
| dash_duo.wait_for_element_by_id('btn').click() | ||
| dash_duo.wait_for_element('#output-0').text == '0=1' | ||
|
|
||
| assert len(dash_duo.get_logs()) != 0 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.