Skip to content

Commit 89fbf1b

Browse files
committed
fix: prevent feedback loop caused by updating findings
1 parent 2994487 commit 89fbf1b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

internal/app/app.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,16 @@ func (a *App) Process(ctx context.Context, evt events.SecurityHubEventInput) err
160160
a.Logger.Debug("finding matched rule", "rule", matchedRule.Name)
161161
}
162162

163+
// skip if finding is already in the desired state to avoid feedback loops
164+
if int32(finding.StatusID) == matchedRule.Action.StatusID {
165+
if a.Config.DebugEnabled {
166+
a.Logger.Debug("finding already in desired state, skipping update",
167+
"uid", finding.Metadata.UID,
168+
"status_id", finding.StatusID)
169+
}
170+
return nil
171+
}
172+
163173
err := a.CloseFinding(ctx, finding, matchedRule.Action.StatusID, matchedRule.Action.Comment)
164174
if err != nil {
165175
return errors.Wrap(err, "failed to auto-close finding")

0 commit comments

Comments
 (0)