Skip to content

Commit bfd234c

Browse files
committed
codeqlの指摘対応1
1 parent b396786 commit bfd234c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

exec_if.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ func OutputFilter(stdout io.Reader, w http.ResponseWriter) error {
7474

7575
func splitPathInfo(basedir string, path string, suffix string) (string, string, error) {
7676
ret := path
77+
if strings.Contains(path, "..") {
78+
slog.Warn("skip suspicious path", "path", path)
79+
return "", "", fmt.Errorf("not found %s", path)
80+
}
7781
for ret != "" && ret != "." && ret != "/" {
7882
slog.Debug("check", "path", path, "basedir", basedir, "cur", ret)
7983
if strings.HasSuffix(ret, suffix) {
@@ -122,7 +126,7 @@ func RunBy(opts SrvConfig, runner Runner, w http.ResponseWriter, r *http.Request
122126
slog.Error("not found", "error", err, "basename", bn)
123127
span.SetStatus(codes.Error, "not found")
124128
w.WriteHeader(http.StatusNotFound)
125-
fmt.Fprintln(w, bn, "not found")
129+
fmt.Fprintln(w, "not found")
126130
return err
127131
}
128132
slog.Debug("memo(path)", "bn", bn, "bn2", bn2, "rest", rest)

0 commit comments

Comments
 (0)