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

Method HandleOnce

agent/app/service/clam.go:316–346  ·  view source on GitHub ↗
(id uint)

Source from the content-addressed store, hash-verified

314}
315
316func (c *ClamService) HandleOnce(id uint) error {
317 if active := clam.CheckWithStopAll(true, clamRepo); !active {
318 return buserr.New("ErrClamdscanNotFound")
319 }
320 clamItem, _ := clamRepo.Get(repo.WithByID(id))
321 if clamItem.ID == 0 {
322 return buserr.New("ErrRecordNotFound")
323 }
324 record := clamRepo.StartRecords(clamItem.ID)
325 taskItem, err := task.NewTaskWithOps("clam-"+clamItem.Name, task.TaskScan, task.TaskScopeClam, record.TaskID, clamItem.ID)
326 if err != nil {
327 return fmt.Errorf("new task for exec shell failed, err: %v", err)
328 }
329 clam.AddScanTask(taskItem, clamItem, record.StartTime.Format(constant.DateTimeSlimLayout))
330 go func() {
331 err := taskItem.Execute()
332 taskRepo := repo.NewITaskRepo()
333 taskItem, _ := taskRepo.GetFirst(taskRepo.WithByID(record.TaskID))
334 if len(taskItem.ID) == 0 {
335 record.TaskID = ""
336 }
337 if err != nil {
338 clamRepo.EndRecords(record, constant.StatusFailed, err.Error())
339 return
340 }
341 clam.AnalysisFromLog(taskItem.LogFile, &record)
342 clamRepo.EndRecords(record, constant.StatusDone, "")
343 handleAlert(record.InfectedFiles, clamItem.Name, clamItem.ID)
344 }()
345 return nil
346}
347
348func (c *ClamService) SearchRecords(req dto.ClamLogSearch) (int64, interface{}, error) {
349 clam, _ := clamRepo.Get(repo.WithByID(req.ClamID))

Callers

nothing calls this directly

Calls 9

WithByIDMethod · 0.95
GetFirstMethod · 0.95
handleAlertFunction · 0.85
GetMethod · 0.65
StartRecordsMethod · 0.65
EndRecordsMethod · 0.65
FormatMethod · 0.45
ExecuteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected