Skip to content

refactor(tracee): encapsulate enrichment config#5211

Open
josedonizetti wants to merge 1 commit intoaquasecurity:mainfrom
josedonizetti:refactor-enrichment
Open

refactor(tracee): encapsulate enrichment config#5211
josedonizetti wants to merge 1 commit intoaquasecurity:mainfrom
josedonizetti:refactor-enrichment

Conversation

@josedonizetti
Copy link
Copy Markdown
Contributor

Refactor enrichment options from OutputConfig to EnrichmentConfig structure.

  • EnrichmentConfig is now a full struct in pkg/config with ToConfig() in flags package
  • GetRuntimeSockets() and CalcHashesOption conversion moved to flags package (runs during parsing)
  • Added nil-safe getters (EnrichUserStack(), EnrichContainers(), etc.)

Added tests for conversion logic, socket handling, and nil safety. All tests pass.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 20, 2026

Codecov Report

❌ Patch coverage is 72.00000% with 28 lines in your changes missing coverage. Please review.
✅ Project coverage is 35.74%. Comparing base (235daa0) to head (184ad67).
⚠️ Report is 181 commits behind head on main.

Files with missing lines Patch % Lines
pkg/ebpf/tracee.go 0.00% 15 Missing ⚠️
pkg/cmd/cobra/cobra.go 0.00% 4 Missing ⚠️
pkg/ebpf/events_pipeline.go 0.00% 4 Missing ⚠️
pkg/ebpf/processor_funcs.go 0.00% 3 Missing ⚠️
pkg/config/config.go 95.74% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5211      +/-   ##
==========================================
+ Coverage   33.51%   35.74%   +2.22%     
==========================================
  Files         250      239      -11     
  Lines       28908    31530    +2622     
==========================================
+ Hits         9688    11269    +1581     
- Misses      18609    19543     +934     
- Partials      611      718     +107     
Flag Coverage Δ
unit 35.74% <72.00%> (+2.22%) ⬆️
Files with missing lines Coverage Δ
pkg/cmd/flags/enrichment.go 95.18% <100.00%> (+14.35%) ⬆️
pkg/cmd/flags/output.go 78.66% <100.00%> (-3.79%) ⬇️
pkg/config/config.go 97.53% <95.74%> (+97.53%) ⬆️
pkg/ebpf/processor_funcs.go 0.00% <0.00%> (ø)
pkg/cmd/cobra/cobra.go 0.00% <0.00%> (ø)
pkg/ebpf/events_pipeline.go 0.00% <0.00%> (ø)
pkg/ebpf/tracee.go 0.00% <0.00%> (ø)

... and 94 files with indirect coverage changes

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

Comment on lines +617 to 624
enrichmentConfig := &config.EnrichmentConfig{}
output, err := PrepareOutput(testcase.outputSlice, config.ContainerModeDisabled, enrichmentConfig)
if err != nil {
require.NotNil(t, testcase.expectedError)
assert.Contains(t, err.Error(), testcase.expectedError.Error())
} else {
assert.Equal(t, testcase.expectedOutput.CalcHashes, output.CalcHashes)
assert.Equal(t, testcase.expectedOutput.EventsSorting, output.EventsSorting)
assert.Equal(t, testcase.expectedOutput.Environment, output.Environment)
assert.Equal(t, testcase.expectedOutput.DecodedData, output.DecodedData)
assert.Equal(t, testcase.expectedOutput.FdPaths, output.FdPaths)
assert.Equal(t, testcase.expectedOutput.UserStack, output.UserStack)
assert.Equal(t, len(testcase.expectedOutput.Streams), len(output.Streams))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do you want to assert enrichment for decoded data is set to true in case table mode is selected?

UserStack bool
DecodedData bool
CalcHashes digest.CalcHashesOption
Sockets runtime.Sockets
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be part of ContainerEnrichmentConfig?
If these are the autodetected sockets, then we should set them in Container.Sockets by default, no?

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