MCPcopy Create free account
hub / github.com/1Panel-dev/1Panel / AddScanTask

Function AddScanTask

agent/utils/clam/clam.go:21–47  ·  view source on GitHub ↗
(taskItem *task.Task, clam model.Clam, timeNow string)

Source from the content-addressed store, hash-verified

19)
20
21func AddScanTask(taskItem *task.Task, clam model.Clam, timeNow string) {
22 taskItem.AddSubTask(i18n.GetWithName("Clamscan", clam.Path), func(t *task.Task) error {
23 strategy := ""
24 switch clam.InfectedStrategy {
25 case "remove":
26 strategy = "--remove"
27 case "move", "copy":
28 dir := path.Join(clam.InfectedDir, "1panel-infected", clam.Name, timeNow)
29 taskItem.Log("infected dir: " + dir)
30 if _, err := os.Stat(dir); err != nil {
31 _ = os.MkdirAll(dir, os.ModePerm)
32 }
33 strategy = fmt.Sprintf("--%s=%s", clam.InfectedStrategy, dir)
34 }
35 args := []string{"--fdpass"}
36 if strategy != "" {
37 args = append(args, strategy)
38 }
39 args = append(args, clam.Path)
40 taskItem.Logf("clamdscan %s", strings.Join(args, " "))
41 mgr := cmd.NewCommandMgr(cmd.WithIgnoreExist1(), cmd.WithTimeout(time.Duration(clam.Timeout)*time.Second), cmd.WithTask(*taskItem))
42 if err := mgr.Run("clamdscan", args...); err != nil {
43 return fmt.Errorf("clamdscan failed, %v", err)
44 }
45 return nil
46 }, nil)
47}
48
49func AnalysisFromLog(pathItem string, record *model.ClamRecord) {
50 file, err := os.ReadFile(pathItem)

Callers

nothing calls this directly

Calls 6

MkdirAllMethod · 0.80
RunMethod · 0.65
AddSubTaskMethod · 0.45
LogMethod · 0.45
StatMethod · 0.45
LogfMethod · 0.45

Tested by

no test coverage detected