feat(actions): Add artifact preview in Actions run view - #36754
Conversation
|
you can test with http://localhost:3000/devtest/repo-action-view |
|
What's up with the font in second screenshot? Is that just the devtest mockup? We should not render serif fonts. |
|
How do we secure this iframe from exploiting the parent page? Common practices include: And these HTTP headers on the parent page: |
|
AI seldom designs correct tests or mocks. You can't make the the template be a mock. |
|
I suggest the following:
|
|
I don't fully understand the use case of this yet, but I guess it wouldn't hurt being able to disable it. |
Update: #36754 (comment)
As long as the design is good enough, no need to use an option to toggle the future. |
|
I want to rework artifacts to support other file types, previewing a zip is not something I think is good. My Reasoning https://github.blog/changelog/2026-02-26-github-actions-now-supports-uploading-and-downloading-non-zipped-artifacts/, so the backend can get some love. |
Oh yes please!! |
|
Created a draft of artifacts v4 with custom mime types #36786, maybe I should remove the unsecure inline content-disposition l had experimentally enabled there. This is GitHub.com https://github.com/actions/toolkit/actions/runs/22458120907 As I expected they use the blob storage url that has a domain sensitive sandbox for inline content disposition. |
|
Either |
|
With iframe this is looks to be ok. As long nobody can navigate you to the direct url to exploit your browser sandbox (bypassing iframe via special crafted link)
The type attachment prevents previewing the html + js in context of our gitea instance by forcing the browser to always download the file. Effectively makes the html not part of the gitea website. (only client side security) EDIT msedge and firefox appl the sandbox rule without iframe from http headers |
|
I think you can refer to our external render: Make external iframe render work #35730 If it is right, you can use the same approach. If you find security problems, let's fix 😄 |
|
Ok I know it better now, you are right CSP header works fine served stand alone (tested manually in firefox and msedge) Not sure if we should really allow file previews within zipped artifacts via backend unpacking, since this makes serve direct impossible. |
|
@ChristopherHX is this still needed or already covered by another PR from you? |
Not covered by me (basically everything you did here)
|
I think its enough to only support the newr ones - what do you think? |
4a73b1a to
979572f
Compare
| req := NewRequestf(t, "GET", "/%s/actions/runs/791/artifacts/artifact-download", repo.FullName()) | ||
| resp := session.MakeRequest(t, req, http.StatusOK) | ||
| assert.Contains(t, resp.Header().Get("Content-Disposition"), "attachment; filename=artifact-download.zip") | ||
| } |
There was a problem hiding this comment.
Make these are fast and consolidated, I assume they are rather slow currently with all the serial sequencing.
|
Also I recommend a security review pass on this. HTML rendering business is always security-critical. |
@silverwind fixed and fixed your reviews - will do a security review now |
Security Review:
|
# Conflicts: # custom/conf/app.example.ini # modules/setting/actions.go
| ;; Artifacts could have their own retention periods by setting the `retention-days` option in `actions/upload-artifact` step. | ||
| ;ARTIFACT_RETENTION_DAYS = 90 | ||
| ;; Max artifact size in bytes that can be browsed or previewed in the web UI. Set to 0 to disable artifact previews, or -1 for no limit. | ||
| ;ARTIFACT_PREVIEW_MAX_SIZE = 104857600 |
There was a problem hiding this comment.
Reduced the default to 10 MiB. Administrators can increase it or set -1 for no limit
|
--> Conclusion Reviewed by CodeT with Socrates, Stoic and the Security Gang Teams cc @lunny |
|
I think it means that on a public instance, any user can run a full static site under the instance's domain to let other visitors to view it? Although its origin is sandboxed, but I think we were preventing from such case because it allows attackers to publish malicious phishing content under the instance's domain? |
Should we just disable it per default? |
|
Or only serve it to signed-in users? Then crawlers won't read the phishing content. If a user already has an account, maybe it's fine to assume that they should know what the site is for? And I don't see why an anonymous user should preview the artifact output. Also add a banner to prompt saying that "the content is automatically generated by XXX", then it won't mislead users to view it as a standalone static site. |
|
@wxiaoguang added the following
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|

Closes #33579.
Adds browser preview support for Actions artifacts in the run view, so files can be viewed without downloading the ZIP. Clicking an artifact name now opens a lightweight file browser at
/preview; clicking a file opens its rendered or raw content in a new tab.Previews are read-only and sandboxed: HTML is rendered with a strict CSP (
sandbox, noallow-same-origin,connect-src 'none'), onlytext/*andapplication/pdfare previewable, and a configurable[actions] ARTIFACT_PREVIEW_MAX_SIZEbounds how large an artifact can be before preview is disabled. The existing ZIP download action is unchanged.docs PR: https://gitea.com/gitea/docs/pulls/533