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

Disable HTML escaping when output in JSON #555

Open
t-katsumura opened this issue Nov 20, 2024 · 1 comment
Open

Disable HTML escaping when output in JSON #555

t-katsumura opened this issue Nov 20, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@t-katsumura
Copy link

t-katsumura commented Nov 20, 2024

cyclonedx-gomod output SBOM with HTML escaped when --json flag was specified.
This converts & in purl to \u0026 which sometimes is not parsed correctly in other tools.

We can find an example at

"purl": "pkg:golang/k8s.io/[email protected]?type=module\u0026goos=linux\u0026goarch=arm64#cmd/minikube",

Proposal:

  • DIsable HTML escape globally
    or
  • Add CLI option to disable HTML escaping

Because the BOMEncoder in cyclonedx-go already has the method SetEscapeHTML(escapeHTML bool), changes should be necessary only around here.

encoder := cdx.NewBOMEncoder(outputWriter, outputFormat)
encoder.SetPretty(true)

@Aswinr24
Copy link
Contributor

Hi, I’d love to pick this issue and work on it.
My proposed solution is to add a CLI flag or option to disable HTML escaping in the JSON output. This would allow users to handle special characters like & properly in other tools.
Let me know if that sounds good, and I can start working on a PR!

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

No branches or pull requests

3 participants