Repository navigation
Fix core bugs in GRIB, SQLite, OGC paging, Aeqd, analysis, tiles, assistant, and Python embed #2927
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
12 commits
Select commit
Hold shift + click to select a range
78ee26a
Fix core data, geometry, analysis, tile, assistant, and Python embed …
giswqs 5ee0d2f
Address PR review comments on embed URL checks, GRIB test, and OGC em…
giswqs 576a8a4
Merge remote-tracking branch 'origin/main' into pr-2927
giswqs d8054e2
fix(analysis): say cells past the range of 32-bit floats
giswqs 97bddd0
fix(data, engine): check each SQLite cell's place; say a spectral
giswqs 69930dc
fix: count Kriging cells once, give SQLite cells four bytes, qualify
giswqs 5554f45
Merge remote-tracking branch 'origin/main' into pr-2927
giswqs 50a57c8
fix(kriging): say which output lost cells past the f32 range
giswqs 675bc44
fix(raster): one f32-range notice per chain, bounded after any halo
giswqs 80cdeda
fix(suitability): one f32-range notice for all criteria
giswqs 9c3a3c6
Merge remote-tracking branch 'origin/main' into pr-2927
giswqs 3be9dce
Merge remote-tracking branch 'origin/main' into pr-2927
giswqs 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """URL construction and validation for the embedded web app widgets.""" | ||
|
|
||
| import shutil | ||
| import subprocess | ||
|
|
||
| import pytest | ||
|
|
||
| from rustgis._embed import WIDGET_JS, _app_src | ||
|
|
||
|
|
||
| @pytest.mark.parametrize( | ||
| "bad_url", | ||
| [ | ||
| "javascript:alert(1)", | ||
| "JAVASCRIPT:alert(1)", | ||
| "data:text/html,<h1>x</h1>", | ||
| "file:///etc/passwd", | ||
| "https://", | ||
| "http://", | ||
| "https://:443", | ||
| "/relative/path", | ||
| "ftp://example.org/app", | ||
| ], | ||
| ) | ||
| def test_app_src_rejects_non_http_or_hostless_urls(bad_url): | ||
| with pytest.raises(ValueError): | ||
| _app_src(bad_url, None) | ||
|
|
||
|
|
||
| def test_widget_js_refuses_non_http_and_frames_https(tmp_path): | ||
| node = shutil.which("node") | ||
| if node is None: | ||
| pytest.skip("node not installed") | ||
| mjs = tmp_path / "_widget.mjs" | ||
| mjs.write_text(WIDGET_JS.read_text(encoding="utf-8"), encoding="utf-8") | ||
| script = f""" | ||
| import widget from {mjs.as_uri()!r}; | ||
| globalThis.window = {{ location: {{ href: "https://notebook.example/" }}, addEventListener() {{}}, removeEventListener() {{}} }}; | ||
| globalThis.document = {{ createElement() {{ return {{ style: {{}} }}; }} }}; | ||
| const model = (src) => ({{ get: (k) => (k === "_src" ? src : ""), on() {{}}, off() {{}} }}); | ||
| const el = {{ appended: 0, appendChild() {{ this.appended += 1; }} }}; | ||
| // The guard refuses a javascript: address with its own message, not some other failure. | ||
| let message = null; | ||
| try {{ | ||
| widget.render({{ model: model("javascript:alert(1)"), el }}); | ||
| }} catch (e) {{ | ||
| message = String(e && e.message); | ||
| }} | ||
| if (!message || !message.includes("Refusing non-HTTP(S) RustGIS app URL")) {{ | ||
| console.error(`expected the scheme guard to refuse javascript:, got ${{message}}`); | ||
| process.exit(1); | ||
| }} | ||
| // The same harness frames an https: address. | ||
| const cleanup = widget.render({{ model: model("https://web.rustgis.app/?embed"), el }}); | ||
| if (el.appended !== 1 || typeof cleanup !== "function") {{ | ||
| console.error("expected an https: address to be framed"); | ||
| process.exit(1); | ||
| }} | ||
| """ | ||
| proc = subprocess.run([node, "--input-type=module", "-e", script], capture_output=True, text=True) | ||
| assert proc.returncode == 0, proc.stderr | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.