Skip to content

Commit

Permalink
fix(tmplexec): handle rare case where lastMatcherEvent address change…
Browse files Browse the repository at this point in the history
… after lock
  • Loading branch information
babariviere committed Dec 5, 2024
1 parent 2549592 commit 4c8a166
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/tmplexec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,11 @@ func (e *TemplateExecuter) Execute(ctx *scan.ScanContext) (bool, error) {
ctx.LogError(errx)

if lastMatcherEvent != nil {
lastMatcherEvent.Lock()
lastMatcherEvent.InternalEvent["error"] = getErrorCause(ctx.GenerateErrorMessage())
lastMatcherEvent.Unlock()
writeFailureCallback(lastMatcherEvent, e.options.Options.MatcherStatus)
event := lastMatcherEvent
event.Lock()
event.InternalEvent["error"] = getErrorCause(ctx.GenerateErrorMessage())
event.Unlock()
writeFailureCallback(event, e.options.Options.MatcherStatus)
}

//TODO: this is a hacky way to handle the case where the callback is not called and matcher-status is true.
Expand Down

0 comments on commit 4c8a166

Please sign in to comment.