mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-08 00:04:21 +01:00
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
399a38893e
commit
d7f790755e
2 changed files with 10 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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": {},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue