Skip to content

acquisition: fix transformation being ignored - #4609

Open
blotus wants to merge 3 commits into
masterfrom
acquis-fix-transform
Open

acquisition: fix transformation being ignored#4609
blotus wants to merge 3 commits into
masterfrom
acquis-fix-transform

Conversation

@blotus

@blotus blotus commented Aug 13, 2026

Copy link
Copy Markdown
Member

Since the datasource refactoring, we were passing the output chan to the datasources even if a transform expression was provided, instead of the transform chan.

This PR also fixes the transform goroutine being kept alive after the acquisition ended in replay mode.

@github-actions

Copy link
Copy Markdown

@blotus: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind enhancement
  • /kind refactoring
  • /kind fix
  • /kind chore
  • /kind dependencies
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@blotus

blotus commented Aug 13, 2026

Copy link
Copy Markdown
Member Author

/kind fix
/area agent

@github-actions

Copy link
Copy Markdown

@blotus: There are no area labels on this PR. You can add as many areas as you see fit.

  • /area agent
  • /area local-api
  • /area cscli
  • /area appsec
  • /area security
  • /area configuration
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes acquisition transform handling introduced by the datasource refactor by ensuring datasources write into the transform channel (when configured) and ensures the transform goroutine terminates cleanly in CAT/replay mode.

Changes:

  • Route datasource output to the transform channel when a transform expression is configured, and forward transformed events to the final output channel.
  • Ensure the transformer exits when the transform channel is closed (CAT mode), preventing acquisition hangs.
  • Add tests validating transform behavior and CAT-mode termination with transforms.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/acquisition/acquisition.go Fixes channel wiring so transforms are applied; closes transform channel in CAT mode so transformer can exit.
pkg/acquisition/acquisition_test.go Adds regression tests for transform application and CAT-mode termination with transforms.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread pkg/acquisition/acquisition_test.go Outdated
Comment on lines +701 to +722
out := make(chan pipeline.Event)
acquisTomb := tomb.Tomb{}

go func() {
_ = StartAcquisition(ctx, sources, out, &acquisTomb)
}()

got := []string{}

READLOOP:
for {
select {
case evt := <-out:
got = append(got, evt.Line.Raw)
case <-time.After(1 * time.Second):
break READLOOP
}
}

acquisTomb.Kill(nil)

assert.Equal(t, tc.expected, got)
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.77%. Comparing base (51ec508) to head (615e7f7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4609      +/-   ##
==========================================
+ Coverage   64.10%   64.77%   +0.66%     
==========================================
  Files         520      503      -17     
  Lines       39649    38922     -727     
==========================================
- Hits        25418    25210     -208     
+ Misses      11848    11370     -478     
+ Partials     2383     2342      -41     
Flag Coverage Δ
bats 41.37% <18.18%> (-0.01%) ⬇️
unit-linux 41.15% <100.00%> (+0.13%) ⬆️
unit-windows ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants