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

REQUEST now supports POST #588

Merged
merged 8 commits into from Jul 30, 2023

Conversation

johncant
Copy link
Contributor

@johncant johncant commented Jul 24, 2023

The experimental REQUEST function now supports any HTTP method.

This makes sense if

  • Your formula is idempotent, taking actions that make external state consistent with the data in your document
  • You have an endpoint with GET behaviour, but it actually requires a POST/PUT method

@fflorent
Copy link
Collaborator

If the backend handles the POST requests, wouldn't a malicious user be able to execute commands to other services with the IP of the server? (making a security breach)

Copy link
Member

@paulfitz paulfitz left a comment

Choose a reason for hiding this comment

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

Looks about right, some comments, thanks @johncant.

My main concern is whether this could come as a surprise to other Grist self-hosters. GRIST_EXPERIMENTAL_PLUGINS would need a stronger warning now I think, since turning it on will result in a quite exploitable system (especially if GRIST_HTTPS_PROXY is not set to at least protect internal endpoints). Perhaps a new flag would be the way to go, for example a separate GRIST_ENABLE_REQUEST_FUNCTION? I'd be ok with surprising some users with the method stopping working until they find and enable this flag - the existing "experimental" flag suggests flux is possible.

sandbox/grist/functions/info.py Outdated Show resolved Hide resolved
sandbox/grist/functions/info.py Show resolved Hide resolved
app/server/lib/Requests.ts Outdated Show resolved Hide resolved
sandbox/grist/functions/info.py Outdated Show resolved Hide resolved
@johncant
Copy link
Contributor Author

If the backend handles the POST requests, wouldn't a malicious user be able to execute commands to other services with the IP of the server? (making a security breach)

Yes, although it depends on who can access your Grist and what internal endpoints are accessible from the Grist backend. Also true for GET requests, but this PR widens the potential for damage. I'd agree that GRIST_ENABLE_REQUEST_FUNCTION flag, disabled by default, and with some documentation, would solve this problem.

@paulfitz @alexmojaki I could implement when I have time, also address your comments.

@fflorent
Copy link
Collaborator

I didn't know the function were disabled by default. That solves my main concern :).

Perhaps a new flag would be the way to go, for example a separate GRIST_ENABLE_REQUEST_FUNCTION?

I wonder if there wouldn't be a way to name this function to be future-proof, in case other possibly-harmful functions would be introduce (unless you say it's much probably the only function of that sort). In that case, I would suggest to introduce a variable whose value would not be a boolean but a list of function names (GRIST_..._FUNCTIONS="request").

Though I am not sure about how to name them (GRIST_EXTRA_FUNCTIONS_USE_WITH_CAUTION="request"? GRIST_REMOTE_EXECUTION_FUNCTIONS_USE_WITH_CAUTION="request"?).

@johncant
Copy link
Contributor Author

It makes no difference to me either way - will go with GRIST_ENABLE_REQUEST_FUNCTION for now and change depending on outcome of any discussion :)

@paulfitz
Copy link
Member

At Grist Labs we are not planning on introducing several functions like this. REQUEST is a stalled project, something that got started but foundered on some complications - security questions, and concern that naive users could end up doing a LOT of requests. Glad to see it getting use.

@johncant
Copy link
Contributor Author

@paulfitz this makes sense - I can't imagine a way of making REQUEST work in an environment where the users aren't trusted and could be naive and expect speed, that doesn't involve a lot of complexity. It's a killer feature though for integrating Grist with things, so thanks a lot!

This PR is now ready to be re-reviewed.

I've manually tested that GRIST_ENABLE_REQUEST_FUNCTION=1 is needed to enable REQUEST, also some simple examples of GET and POST with actual Grist.

@alexmojaki
Copy link
Contributor

It's a killer feature though for integrating Grist with things, so thanks a lot!

REQUEST is my baby, so thanks for saying this, it warms my heart 😊

app/server/lib/Requests.ts Outdated Show resolved Hide resolved
sandbox/grist/functions/info.py Outdated Show resolved Hide resolved
sandbox/grist/functions/info.py Outdated Show resolved Hide resolved
@johncant
Copy link
Contributor Author

Ok - this PR is now ready for re-re-review.

Copy link
Contributor

@alexmojaki alexmojaki left a comment

Choose a reason for hiding this comment

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

LGTM, thanks! @paulfitz are you satisfied?

@paulfitz
Copy link
Member

LGTM, thanks! @paulfitz are you satisfied?

Yup, thank you both!

@paulfitz paulfitz merged commit e1df603 into gristlabs:main Jul 30, 2023
13 checks passed
@johncant johncant deleted the feature/make_REQUEST_POST branch July 30, 2023 21:20
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.

None yet

4 participants