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

Added function to escape string in failure message title and descriptions #551

Merged
merged 3 commits into from
Jul 6, 2020
Merged

Conversation

rahul2393
Copy link
Contributor

@rahul2393 rahul2393 commented Jul 5, 2020

Issue

  • Failure and Title should be escaped before exporting to template

Related: #541

tmpl, err := template.New("output template").Parse(outputTemplate)
tmpl, err := template.New("output template").Funcs(template.FuncMap{
"escapeString": func(input string) string {
return html.EscapeString(input)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if we use xml.EscapeText?
https://golang.org/pkg/encoding/xml/#EscapeText

In that case, escapeXML is preferred rather than escapeString.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@knqyf263 done, updated tests passing

@@ -41,7 +43,16 @@ func WriteResults(format string, output io.Writer, results Results, outputTempla
case "json":
writer = &JsonWriter{Output: output}
case "template":
tmpl, err := template.New("output template").Parse(outputTemplate)
tmpl, err := template.New("output template").Funcs(template.FuncMap{
"escapeString": func(input string) string {
Copy link
Collaborator

Choose a reason for hiding this comment

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

As I said, I think escapeXML is preferred because we might escape HTML or other formats other than XML.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@knqyf263 Thanks, check now

@knqyf263 knqyf263 merged commit ccd9b2d into aquasecurity:master Jul 6, 2020
@knqyf263
Copy link
Collaborator

knqyf263 commented Jul 6, 2020

@rahul2393 Thanks a lot!

liamg pushed a commit that referenced this pull request Jun 7, 2022
…ions (#551)

* Added function to escape string in failure message title and descriptions

* updated template to use xml.EscapeText

* Renamed template function
liamg pushed a commit that referenced this pull request Jun 7, 2022
* fix: support for helm chart *.tar.gz

- add test to validate

Signed-off-by: Owen Rumney <[email protected]>

* fix: adding missing test tar

Signed-off-by: Owen Rumney <[email protected]>
liamg pushed a commit that referenced this pull request Jun 7, 2022
* fix: support for helm chart *.tar.gz

- add test to validate

Signed-off-by: Owen Rumney <[email protected]>

* fix: adding missing test tar

Signed-off-by: Owen Rumney <[email protected]>
josedonizetti pushed a commit to josedonizetti/trivy that referenced this pull request Jun 24, 2022
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.

2 participants