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

Add support for SPRIG template functions #77

Open
UiP9AV6Y opened this issue Oct 30, 2022 · 4 comments · May be fixed by #78
Open

Add support for SPRIG template functions #77

UiP9AV6Y opened this issue Oct 30, 2022 · 4 comments · May be fixed by #78
Labels
enhancement Requested feature

Comments

@UiP9AV6Y
Copy link

To get somewhat more dynamic responses, i would like to make use of the sprig template functions.

for security reasons env, expandenv, and getHostByName should not be supported.

@UiP9AV6Y
Copy link
Author

i can come up with a PR to get this feature implemented

UiP9AV6Y added a commit to UiP9AV6Y/request-baskets that referenced this issue Oct 30, 2022
UiP9AV6Y added a commit to UiP9AV6Y/request-baskets that referenced this issue Oct 30, 2022
add additional functions to the template system, for both the layout
and response feature

closes darklynx#77
@UiP9AV6Y UiP9AV6Y linked a pull request Oct 30, 2022 that will close this issue
@darklynx
Copy link
Owner

Hi @UiP9AV6Y

Thank you for your contribution!

It's an interesting idea, although the templating was never an advertised feature of this service, more like a convenience.

For standard pages (index, baskets, basket) I do not need the power of Sprig, I guess.

For responses Sprig probably offers more flexible and powerful language that is easier to use, but it comes with a price. As I can see the language offers some powerful features that can easily lead to a security issues, especially since the template themselves can be created by any visitor of the web-site w/o authentication. I appreciate your effort to mitigate that by removing 3 known functions that may lead to an issue. However, if tomorrow a new version of Sprig will arrive and introduce a new dangerous function - this can lead to a security vulnerabilities by simply automatic update.

From that point of view it would be great to introduce Sprig as an alternative template language that is not used by default. And extra parameter for the service to switch between template engines. I think this should be fair: keep the default language from Go lang, that is simpler, yet safer, and let users configure more complex engine at will with responsibility of higher risk.

What do you think?

@darklynx darklynx added the enhancement Requested feature label Oct 30, 2022
@UiP9AV6Y
Copy link
Author

For standard pages (index, baskets, basket) I do not need the power of Sprig, I guess.

i know. i just applied it to all templating use for consistency reasons

As I can see the language offers some powerful features that can easily lead to a security issues

can you name an example? the current iteration of the templating feature already has access to request data. using sprig offers simply new ways to process that data + generate (non-sensitive) data (e.g. time, date, random strings)

However, if tomorrow a new version of Sprig will arrive and introduce a new dangerous function - this can lead to a security vulnerabilities by simply automatic update.

i assume you do not blindly update dependencies without checking what has actually changed b/c the same can be said about any 3rd party code

keep the default language from Go lang, that is simpler, yet safer, and let users configure more complex engine at will with responsibility of higher risk.

user refers to the server operator here, right?

UiP9AV6Y added a commit to UiP9AV6Y/request-baskets that referenced this issue Jul 5, 2023
add additional functions to the template system, for both the layout
and response feature

closes darklynx#77
@gcleaves
Copy link

gcleaves commented Apr 9, 2024

The ability to build a dynamic response is pretty important because many webhook subscriptions require a dynamic response in order to verify the endpoint is willing to accept the webhook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Requested feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants