Skip to content

Commit

Permalink
fix: no push
Browse files Browse the repository at this point in the history
  • Loading branch information
zema1 committed Nov 19, 2024
1 parent 9bbc19a commit 272cc7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ctrl/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ use webhook: %s --webhook WEBHOOK_URL`
if pusherCount > 1 {
golog.Infof("multi pusher detected, push retry will be disabled")
c.PushRetryCount = 0
} else {
c.PushRetryCount = 2
}
// 固定一个推送的间隔 1s,避免 dingding 等推送过快的问题
interval := time.Second
Expand Down
8 changes: 7 additions & 1 deletion ctrl/ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,23 @@ func (w *WatchVulnApp) collectAndPush(ctx context.Context) {
w.log.Infof("Pushing %s", v)

// 默认重试3次,如果有多种推送方式,禁用重置机制,避免出现一个成功一个失败,重试的话,成功那个会被重复推送
for i := 0; i < w.config.PushRetryCount; i++ {
i := 0
for {
if err := w.pushVuln(v); err == nil {
// 如果两种推送都成功,才标记为已推送
_, err = dbVuln.Update().SetPushed(true).Save(ctx)
if err != nil {
w.log.Errorf("failed to save pushed %s status, %s", v.UniqueKey, err)
}
w.log.Infof("pushed %s successfully", v)
break
} else {
w.log.Errorf("failed to push %s, %s", v.UniqueKey, err)
}
i++
if i > w.config.PushRetryCount {
break
}
w.log.Infof("retry to push %s after 30s", v.UniqueKey)
time.Sleep(time.Second * 30)
}
Expand Down

0 comments on commit 272cc7b

Please sign in to comment.