mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-04-20 19:38:39 +00:00
Sanitize path api params
- fix path traversal complains by CodeQL
This commit is contained in:
@@ -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