Skip to content

Commit 7619fc8

Browse files
path parsing
1 parent 9f02891 commit 7619fc8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cmd/munkisrv/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,18 @@ func munkiRepoFunc(w http.ResponseWriter, r *http.Request) {
9999

100100
func munkiPkgFunc(cloudFrontURL string, signer *sign.URLSigner) http.HandlerFunc {
101101
return func(w http.ResponseWriter, r *http.Request) {
102+
pkgPath := chi.URLParam(r, "*")
103+
if pkgPath == "" || strings.Contains(pkgPath, "..") {
104+
http.Error(w, "invalid path", http.StatusBadRequest)
105+
return
106+
}
107+
102108
u, err := url.Parse(cloudFrontURL)
103109
if err != nil {
104110
http.Error(w, "failed to parse base url", http.StatusInternalServerError)
105111
return
106112
}
107-
u.Path = path.Join(u.Path, r.URL.Path)
113+
u.Path = path.Join(u.Path, "repo", "pkgs", pkgPath)
108114
finalURL := u.String()
109115

110116
signedURL, err := signer.Sign(finalURL, time.Now().Add(1*time.Hour))

0 commit comments

Comments
 (0)