Compare commits

...
Author SHA1 Message Date
lan-yonghui f994210117 fix: prevent tar option injection 2026-11-08 12:08:42 +08:00
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -43,7 +43,7 @@ func (t TarArchiver) Compress(ctx context.Context, sourcePaths []string, dstFile
return err
}
baseDir := filepath.Dir(sourcePaths[0])
args := []string{t.getOptionStr("compress"), dstFile, "-C", baseDir}
args := []string{t.getOptionStr("compress"), dstFile, "-C", baseDir, "--"}
for _, sourcePath := range sourcePaths {
args = append(args, filepath.Base(sourcePath))
}
+2 -2
View File
@@ -55,9 +55,9 @@ func (t TarGzArchiver) Compress(ctx context.Context, sourcePaths []string, dstFi
aheadDir = "/"
}
if len(secret) != 0 {
err = runTarGzEncryptToFile(cmd.NewCommandMgr(cmd.WithContext(ctx)), tmpFile, secret, append([]string{"-C", aheadDir}, itemDirs...)...)
err = runTarGzEncryptToFile(cmd.NewCommandMgr(cmd.WithContext(ctx)), tmpFile, secret, append([]string{"-C", aheadDir, "--"}, itemDirs...)...)
} else {
err = runTarGzToFile(cmd.NewCommandMgr(cmd.WithContext(ctx)), tmpFile, append([]string{"-C", aheadDir}, itemDirs...)...)
err = runTarGzToFile(cmd.NewCommandMgr(cmd.WithContext(ctx)), tmpFile, append([]string{"-C", aheadDir, "--"}, itemDirs...)...)
}
if err != nil {
return err