mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-10-20 10:57:09 +00:00
Sanitize path api params
- fix path traversal complains by CodeQL
This commit is contained in:
1 parent
ce2966e547
commit
57639c4adf
4 files changed
+30
-15
No files matched your search
@@ -4,6 +4,7 @@ package utils
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
@@ -22,3 +23,10 @@ func DirIsAccessible(filename string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove leading '/', remove '..'
|
||||
func PathSanitize(path string) (result string) {
|
||||
result = strings.Replace(path, "..", "", -1)
|
||||
result = strings.TrimLeft(result, "/")
|
||||
return
|
||||
}
|
||||
Reference in new issue
Block a user