Skip to content

Commit

Permalink
Merge pull request #1855 from daemon1024/fix-dp-policymatch
Browse files Browse the repository at this point in the history
fix(policymatcher): skip future matching in case block/audit matches
  • Loading branch information
Aryan-sharma11 authored Sep 3, 2024
2 parents c8471b1 + d572138 commit 8525ec6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions KubeArmor/feeder/policyMatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,11 @@ func (fd *Feeder) UpdateMatchedPolicy(log tp.Log) tp.Log {
continue
}

// when one of the below rule is already matched for the log event, we will skip for further matches
if skip {
break // break, so that once source is matched for a log it doesn't look for other cases
}

// match sources
if (!secPolicy.IsFromSource) || (secPolicy.IsFromSource && (secPolicy.Source == log.ParentProcessName || secPolicy.Source == log.ProcessName)) {
matchedRegex := false
Expand Down Expand Up @@ -1159,6 +1164,7 @@ func (fd *Feeder) UpdateMatchedPolicy(log tp.Log) tp.Log {
log.Enforcer = "eBPF Monitor"
log.Action = secPolicy.Action

skip = true
continue
}

Expand Down Expand Up @@ -1190,6 +1196,7 @@ func (fd *Feeder) UpdateMatchedPolicy(log tp.Log) tp.Log {

log.Action = secPolicy.Action

skip = true
continue
}

Expand Down

0 comments on commit 8525ec6

Please sign in to comment.