We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7f79609 commit 6c84bd5Copy full SHA for 6c84bd5
1 file changed
opensca/walk/path.go
@@ -0,0 +1,27 @@
1
+package walk
2
+
3
+import (
4
+ "fmt"
5
+ "path/filepath"
6
+ "strings"
7
+)
8
9
+func resolveExtractPath(output, entry string) (string, error) {
10
+ if filepath.IsAbs(entry) {
11
+ return "", fmt.Errorf("invalid file path: %s", entry)
12
+ }
13
14
+ base := filepath.Clean(output)
15
+ target := filepath.Join(base, entry)
16
17
+ rel, err := filepath.Rel(base, target)
18
+ if err != nil {
19
+ return "", err
20
21
22
+ if rel == ".." || strings.HasPrefix(rel, ".."+string(filepath.Separator)) {
23
24
25
26
+ return target, nil
27
+}
0 commit comments