1
0
mirror of https://github.com/tw93/Mole.git synced 2026-03-22 20:15:07 +00:00

fix(timeout): inherit helper state and pass checks

This commit is contained in:
Tw93
2026-03-14 08:32:11 +08:00
parent 0d2f217f28
commit 169be1e1f2
3 changed files with 21 additions and 15 deletions

View File

@@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"slices"
"sort"
"strings"
"sync/atomic"
@@ -165,10 +166,8 @@ func validatePath(path string) error {
return fmt.Errorf("path contains null bytes")
}
// Check for path traversal attempts (.. components).
for _, component := range strings.Split(path, string(filepath.Separator)) {
if component == ".." {
return fmt.Errorf("path contains traversal components: %s", path)
}
if slices.Contains(strings.Split(path, string(filepath.Separator)), "..") {
return fmt.Errorf("path contains traversal components: %s", path)
}
return nil
}