Skip to content

Introduce new summary component.#695

Open
vovakrk wants to merge 3 commits intokubernetes-sigs:mainfrom
vovakrk:main
Open

Introduce new summary component.#695
vovakrk wants to merge 3 commits intokubernetes-sigs:mainfrom
vovakrk:main

Conversation

@vovakrk
Copy link
Copy Markdown

@vovakrk vovakrk commented Apr 29, 2026

Summary component is intended for rendering markdown (MD) files.

Summary component is intended for rendering markdown (MD) files.
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 29, 2026

Deploy Preview for k8s-prow ready!

Name Link
🔨 Latest commit 9809d42
🔍 Latest deploy log https://app.netlify.com/projects/k8s-prow/deploys/69f95744ea8a4500080a2faf
😎 Deploy Preview https://deploy-preview-695--k8s-prow.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 29, 2026
@k8s-ci-robot k8s-ci-robot added area/deck Issues or PRs related to prow's deck component area/spyglass Issues or PRs related to prow's spyglass UI size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 29, 2026
@vovakrk
Copy link
Copy Markdown
Author

vovakrk commented Apr 29, 2026

/retest

Copy link
Copy Markdown
Contributor

@michelle192837 michelle192837 left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good to me for implementation (though I'd feel better with another maintainer's approval, @petr-muller or another if you'd like to take a look).

/lgtm

/hold

(in case Petr wants to take a look)

continue
}

htmlContent := blackfriday.Run(content)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

note: I believe this is a case where we'd want to consider sanitizing the input, but executeTemplate() later should take care of that, so this should be fine.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's not fine, the output is fed to template.HTML below which is documented to assume the input to be safe:

HTML encapsulates a known safe HTML document fragment. It should not be used for HTML from a third-party

I guess we could use it this way if the markdown processor is trusted to emit safe HTML from potentially unsafe markdown, but the blackfriday one does not seem to do that at least by default:

Blackfriday itself does nothing to protect against malicious content. If you are dealing with user-supplied markdown, we recommend running Blackfriday's output through HTML sanitizer such as Bluemonday.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FWIW the goldmark processor claims to be safe:

By default, goldmark does not render raw HTML or potentially dangerous links

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Goldmark seems reasonable 👍

I think you're right that template.HTML isn't safe, but I think ExecuteTemplate() is? (Though it is parsing arbitrary content, so the "template author is trusted" assumption isn't quite there).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😅 I'm just roleplaying a web developer here, it is possible that I'm wrong :D

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 30, 2026
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 30, 2026
@vovakrk
Copy link
Copy Markdown
Author

vovakrk commented May 4, 2026

/assign @petr-muller

@vovakrk
Copy link
Copy Markdown
Author

vovakrk commented May 4, 2026

Hi @petr-muller, Could you take a look at my PR? Thank you!

Copy link
Copy Markdown
Contributor

@petr-muller petr-muller left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! I thought about having a Markdown lens in the past, I believe it can be very useful.

Some high-level notes:

  1. Should it just be called markdown lens instead of "summary"?
  2. I'm no expert on Markdown Go libraries, but https://github.com/russross/blackfriday seems essentially abandoned; is there a reason why you chose it? Quick google search showed https://github.com/yuin/goldmark as an actively developed candidate but I really did not do any deeper research.
  3. The logic is fairly simple but I still think we'd benefit from having basic tests. It makes it easier for folks to extend the behavior in the future.

continue
}

htmlContent := blackfriday.Run(content)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it's not fine, the output is fed to template.HTML below which is documented to assume the input to be safe:

HTML encapsulates a known safe HTML document fragment. It should not be used for HTML from a third-party

I guess we could use it this way if the markdown processor is trusted to emit safe HTML from potentially unsafe markdown, but the blackfriday one does not seem to do that at least by default:

Blackfriday itself does nothing to protect against malicious content. If you are dealing with user-supplied markdown, we recommend running Blackfriday's output through HTML sanitizer such as Bluemonday.


t, err := template.ParseFiles(filepath.Join(resourceDir, "template.html"))
if err != nil {
logrus.WithError(err).Error("Error executing template.")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
logrus.WithError(err).Error("Error executing template.")
logrus.WithError(err).Error("Failed to load template.")

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 5, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: michelle192837, vovakrk
Once this PR has been reviewed and has the lgtm label, please ask for approval from petr-muller. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deck Issues or PRs related to prow's deck component area/spyglass Issues or PRs related to prow's spyglass UI cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants