Lista conteudo de .zip, .tar, .tar.gz e .gz sem extrair, com limite anti-bomba.
This commit is contained in:
1 parent
dc829b9d43
commit
f6a74e1092
6 files changed
+389
-15
No files matched your search
@@ -55,6 +55,19 @@ func (s *Server) handleFileTree(w http.ResponseWriter, r *http.Request) {
|
||||
})
|
||||
}
|
||||
|
||||
// handleFileArchiveList devolve a listagem amigável do conteúdo de um
|
||||
// compactado (.zip, .tar, .tar.gz/.tgz, .gz) sem extrair nada.
|
||||
func (s *Server) handleFileArchiveList(w http.ResponseWriter, r *http.Request) {
|
||||
entries, total, truncated, err := s.st.ListArchive(r.PathValue("id"))
|
||||
if err != nil {
|
||||
mapStoreErrorFor(w, err, "arquivo")
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, map[string]any{
|
||||
"entries": entries, "total": total, "truncated": truncated,
|
||||
})
|
||||
}
|
||||
|
||||
func (s *Server) handleFileStatic(w http.ResponseWriter, r *http.Request) {
|
||||
if err := s.st.ServeFile(w, r, r.PathValue("id")); err != nil {
|
||||
mapStoreErrorFor(w, err, "arquivo")
|
||||
|
||||
@@ -98,6 +98,7 @@ func (s *Server) Handler() http.Handler {
|
||||
// gerenciador de arquivos / anexos
|
||||
mux.HandleFunc("POST /api/files/upload", s.auth(s.handleFileUpload))
|
||||
mux.HandleFunc("GET /api/files/tree", s.auth(s.handleFileTree))
|
||||
mux.HandleFunc("GET /api/files/archive/{id}", s.auth(s.handleFileArchiveList))
|
||||
mux.HandleFunc("GET /api/files/static/{id}", s.auth(s.handleFileStatic))
|
||||
mux.HandleFunc("DELETE /api/files/{id}", s.auth(s.handleFileDelete))
|
||||
mux.HandleFunc("PUT /api/files/{id}/move", s.auth(s.handleFileMove))
|
||||
|
||||
Reference in new issue
Block a user