in pkg/profiling/continuous/checker/common/checker.go [52:87]
func (c *BaseChecker[Info]) SyncPolicies(policies []*base.SyncPolicyWithProcesses,
getEnabledItem func(items map[base.CheckType]*base.PolicyItem) *base.PolicyItem,
notify func(key int32, isDelete bool)) {
pidWithPolicyItems := make(map[api.ProcessInterface][]*base.PolicyItem)
for _, processWithPolicies := range policies {
item := getEnabledItem(processWithPolicies.Policy.Items)
if item == nil {
continue
}
// create or get the existing windows
// and add the policy into the update
for _, p := range processWithPolicies.Processes {
pidWithPolicyItems[p] = append(pidWithPolicyItems[p], item)
}
}
// generate the new process info
result := make(map[int32]Info)
for p, items := range pidWithPolicyItems {
pid := p.Pid()
if existing := c.PidWithInfos[pid]; reflect.ValueOf(existing).IsZero() && notify != nil {
notify(pid, false)
}
result[pid] = c.InfoGenerator(p, c.PidWithInfos[pid], items)
}
// if the pid is not exist in the new policies, then notify to delete
for key := range c.PidWithInfos {
if newResult := result[key]; reflect.ValueOf(newResult).IsZero() && notify != nil {
notify(key, true)
}
}
c.PidWithInfos = result
}