Skip to content

Commit 12ba9c2

Browse files
committed
syz-cluster/dashboard: share test step artifacts
If the test artifacts are present, let the user download them.
1 parent d9f74b6 commit 12ba9c2

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

syz-cluster/dashboard/handler.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func (h *dashboardHandler) Mux() *http.ServeMux {
5858
mux := http.NewServeMux()
5959
mux.HandleFunc("/sessions/{id}/log", errToStatus(h.sessionLog))
6060
mux.HandleFunc("/sessions/{id}/test_logs", errToStatus(h.sessionTestLog))
61+
mux.HandleFunc("/sessions/{id}/test_artifacts", errToStatus(h.sessionTestArtifacts))
6162
mux.HandleFunc("/series/{id}", errToStatus(h.seriesInfo))
6263
mux.HandleFunc("/patches/{id}", errToStatus(h.patchContent))
6364
mux.HandleFunc("/findings/{id}/{key}", errToStatus(h.findingInfo))
@@ -254,11 +255,24 @@ func (h *dashboardHandler) sessionTestLog(w http.ResponseWriter, r *http.Request
254255
if err != nil {
255256
return err
256257
} else if test == nil {
257-
return fmt.Errorf("%w: test log", errNotFound)
258+
return fmt.Errorf("%w: test", errNotFound)
258259
}
259260
return h.streamBlob(w, test.LogURI)
260261
}
261262

263+
func (h *dashboardHandler) sessionTestArtifacts(w http.ResponseWriter, r *http.Request) error {
264+
test, err := h.sessionTestRepo.Get(r.Context(), r.PathValue("id"), r.FormValue("name"))
265+
if err != nil {
266+
return err
267+
} else if test == nil {
268+
return fmt.Errorf("%w: test", errNotFound)
269+
}
270+
filename := fmt.Sprintf("%s_%s.tar.gz", test.SessionID, test.TestName)
271+
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename))
272+
w.Header().Set("Content-Type", "application/octet-stream")
273+
return h.streamBlob(w, test.ArtifactsArchiveURI)
274+
}
275+
262276
func (h *dashboardHandler) streamBlob(w http.ResponseWriter, uri string) error {
263277
if uri == "" {
264278
return nil

syz-cluster/dashboard/templates/series.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ <h3>Session {{.CreatedAt.Format "2006-01-02"}}</h3>
130130
{{if .LogURI}}
131131
<a href="/sessions/{{.SessionID}}/test_logs?name={{.TestName}}" class="modal-link-raw">[Log]</a>
132132
{{end}}
133+
{{if .ArtifactsArchiveURI}}
134+
<a href="/sessions/{{.SessionID}}/test_artifacts?name={{.TestName}}">[Artifacts]</a>
135+
{{end}}
133136
</th>
134137
</tr>
135138
{{if .Findings}}

0 commit comments

Comments
 (0)