fix: resolve compile errors in phase 2 remediation
Some checks failed
Automated Container Build / build-and-push (push) Failing after 51s
Some checks failed
Automated Container Build / build-and-push (push) Failing after 51s
This commit is contained in:
parent
a7f76e2e97
commit
f69c6d825e
3 changed files with 15 additions and 1 deletions
|
|
@ -1290,3 +1290,17 @@ func (h *FSHandler) CheckConflicts(c *fiber.Ctx) error {
|
||||||
|
|
||||||
return c.JSON(fiber.Map{"conflicts": conflicts})
|
return c.JSON(fiber.Map{"conflicts": conflicts})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// safeRemovePath ensures we never delete a base directory.
|
||||||
|
func safeRemovePath(baseDir, targetAbsPath string) error {
|
||||||
|
cleanBase := filepath.Clean(baseDir)
|
||||||
|
cleanTarget := filepath.Clean(targetAbsPath)
|
||||||
|
if cleanTarget == cleanBase || cleanTarget == "." || cleanTarget == "/" {
|
||||||
|
return fmt.Errorf("cannot remove base directory %s", baseDir)
|
||||||
|
}
|
||||||
|
// Ensure it's inside the baseDir
|
||||||
|
if !strings.HasPrefix(cleanTarget, cleanBase+string(os.PathSeparator)) {
|
||||||
|
return fmt.Errorf("path escapes base directory")
|
||||||
|
}
|
||||||
|
return os.RemoveAll(cleanTarget)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import (
|
||||||
"archive/zip"
|
"archive/zip"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ import (
|
||||||
|
|
||||||
"git.elijahkuntz.com/Elijah/drive/config"
|
"git.elijahkuntz.com/Elijah/drive/config"
|
||||||
"git.elijahkuntz.com/Elijah/drive/database"
|
"git.elijahkuntz.com/Elijah/drive/database"
|
||||||
|
"git.elijahkuntz.com/Elijah/drive/middleware"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/valyala/fasthttp/fasthttpadaptor"
|
"github.com/valyala/fasthttp/fasthttpadaptor"
|
||||||
"golang.org/x/net/webdav"
|
"golang.org/x/net/webdav"
|
||||||
|
|
|
||||||
Reference in a new issue