Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2026-01-28 22:21:40 +08:00
commit 94271e67df
2 changed files with 10 additions and 0 deletions

View file

@ -141,6 +141,14 @@ func copyFile(c *gin.Context) {
}
dest := arg["dest"].(string)
if util.IsSensitivePath(dest) {
msg := fmt.Sprintf("refuse to copy sensitive file [%s]", dest)
logging.LogErrorf(msg)
ret.Code = -2
ret.Msg = msg
return
}
if err = filelock.Copy(src, dest); err != nil {
logging.LogErrorf("copy file [%s] to [%s] failed: %s", src, dest, err)
ret.Code = -1

View file

@ -373,6 +373,7 @@ func IsSensitivePath(p string) bool {
"/etc/ssh",
"/root",
"/etc/ssl",
"/etc/cron.d/",
"/etc/letsencrypt",
"/var/lib/docker",
"/.gnupg",
@ -404,6 +405,7 @@ func IsSensitivePath(p string) bool {
base := filepath.Base(pp)
n := strings.ToLower(base)
sensitiveNames := map[string]struct{}{
".bashrc": {},
".env": {},
".env.local": {},
".npmrc": {},