Skip to content

Do not run URL-supplied parameters on page view - #727

Open
chrisclark wants to merge 1 commit into
masterfrom
fix/autorun-params-inline
Open

chrisclark wants to merge 1 commit into
masterfrom
fix/autorun-params-inline

Conversation

@chrisclark

Copy link
Copy Markdown
Collaborator

Summary

Stops a shared query link from executing SQL in the visitor's session. High.

QueryView.get ran the query on a plain page view whenever show was truthy, which it is by default:

show = url_get_show(request)          # defaults to 1
params = query.available_params()
if not EXPLORER_AUTORUN_QUERY_WITH_PARAMS and params:
    show = False

Parameters in the URL (?params=id:5) are documented as the way to share a parameterized query, so a link carries the values that make it run. Opening such a link executed the query immediately, in the session of whoever clicked it, with no Save & Run and no review of the parameters.

Correction to my earlier report: I initially listed "?show=1 overrides EXPLORER_AUTORUN_QUERY_WITH_PARAMS=False" as part of this. On re-testing that is not true — the setting does suppress the run, and I had validated it badly the first time. It is corrected here rather than left in the history. The real issue is narrower: with the setting left at its default (True), a URL-parameterized link always runs.

Fix

Parameterized queries loaded from the URL now render without executing — the same behaviour EXPLORER_AUTORUN_QUERY_WITH_PARAMS=False already gives, applied to the case where the parameters did not come from the person viewing. The setting keeps its documented meaning, and queries with no URL parameters still autorun as before.

This complements #723. Binding parameter values means a parameter can no longer change the SQL; this removes the remaining case where merely opening a shared link runs a query the visitor never asked for.

Nothing is lost: the detail page renders the parameter values on request, so the user clicks Save & Run to get results.

Tests

  • URL params do not autorun on a plain page view;
  • same with EXPLORER_AUTORUN_QUERY_WITH_PARAMS=True explicitly set (the actual default path);
  • a query with no URL parameters still autoruns, so the documented behaviour is unchanged.

Docs updated in install.rst next to the EXPLORER_AUTORUN_QUERY_WITH_PARAMS entry.

Full suite: 297 tests, OK. ruff check explorer/: clean.

A query link carrying parameters (?params=id:5) executed the query on a
plain page view. Those parameter values travel with the link rather than
coming from the person who opened it, so a shared link ran SQL in the
visitor's session with nothing more than a click on the link -- no Save &
Run, no review of the parameters.

Parameterized queries loaded from the URL now render without executing,
which is what EXPLORER_AUTORUN_QUERY_WITH_PARAMS=False already did for
every parameterized query. The setting keeps its documented meaning for
queries whose parameters did not come from the URL, and queries with no
URL parameters are unaffected.

This complements binding parameter values (they can no longer change the
SQL) by removing the remaining case where merely opening a shared link
runs a query the visitor did not ask for.

The detail page renders the values on request, so no results are lost;
the user just has to ask for them.

This branch has not been deployed

No deployments
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.

1 participant