Skip to content

fix(rulemanager): enforce required profiles for host events - #1031

Merged
matthyx merged 1 commit into
mainfrom
fix/host-required-profile-gate
Oct 14, 2026
Merged

matthyx merged 1 commit into
mainfrom
fix/host-required-profile-gate

Conversation

@matthyx

@matthyx matthyx commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Host and standalone events currently bypass profileDependency: Required in ReportEnrichedEvent. A host IMDS request can therefore trigger R1059 without a profile: the missing-profile lookup returns false and the rule negates it into a match.

Enforce the existing profile gate for every event context before CEL evaluation and alert export. Optional and NotRequired behavior, context selection, and suppression metrics remain unchanged. Remove the comments describing the old Kubernetes-only exception.

Regression coverage

A 24-case matrix exercises host, standalone container, Kubernetes, and legacy nil-context events against all three profile dependencies with missing and available profiles. It asserts evaluation, export, and profile_incomplete suppression. Before the fix, the host and standalone Required/missing cases failed because they evaluated and exported an alert.

Validation

  • Rule manager package tests, race regression, go vet, scoped golangci-lint (0 issues), and upstream make binary passed.
  • Package tests passed again after the bounded cleanup review; independent reviews are recorded in workflow evidence.
  • Private node-agent integration: applied this production patch to its pinned upstream v0.3.258 using a temporary modfile; make node and host rule manager/exporter tests passed. No replace directive is committed.
  • Broader rule-manager subtree lint reports 19 pre-existing findings in unchanged subpackages.

Rollout

Private node-agent consumes this package as a dependency and needs a compatible upstream release/backport containing this fix. A blind bump to current upstream main fails against the consumer’s existing storage implementation (ListContainerProfiles is newly required). This PR fixes the shared source; it does not change deployment configuration.

Required detections stay suppressed while a profile is unavailable, for host events as well as container events, and retain the profile_incomplete suppression metric.

Independent code review: APPROVE, zero findings. Independent architecture review: CLEAR, including a passing matrix rerun and confirmation that the cache supports host profiles.

Summary by CodeRabbit

  • Bug Fixes
    • Rules that require an unavailable profile are now consistently skipped across host, standalone, Kubernetes, and legacy Kubernetes events. These rules no longer generate alerts and are recorded as suppressed due to an incomplete profile.
    • Rules with their required profiles available continue to be evaluated and can generate alerts across these event types.

@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 29244659-75f5-48da-a7ad-8dbbd3c9042d
📥 Commits

Reviewing files that changed from the base of the PR and between 7734619 and 01ae737.

📒 Files selected for processing: 2
  • pkg/rulemanager/rule_manager.go
  • pkg/rulemanager/rule_manager_profile_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The rule manager now suppresses rules with a missing required profile in every event context. A table-driven test checks rule evaluation, alert export, and suppression records across contexts and profile dependency combinations.

Changes: Required-profile suppression

Layer / File(s) Summary
Apply and verify required-profile suppression
pkg/rulemanager/rule_manager.go, pkg/rulemanager/rule_manager_profile_test.go
The rule manager suppresses a rule with profile_incomplete when its required profile is missing, regardless of event context. Tests cover evaluation, alert export, and suppression records across four contexts and profile dependency combinations.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: khuswant18

Merge Risk: ⚪ Minimal · up to 01ae7

Rules that require a profile are now suppressed for host and standalone events when no profile is available, matching the stated intent. No merge-blocking risk is evident from the supplied change.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: enforcing required profiles for host events.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
@matthyx
matthyx requested a balanced review from Copilot October 14, 2026 06:10
@matthyx
matthyx force-pushed the fix/host-required-profile-gate branch from e2526eb to 01ae737 Compare October 14, 2026 06:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix is consistent with profile dependency semantics and has comprehensive regression coverage.

0 open findings

What changed in this PR

Ensures profile-required rules suppress host and standalone events when profiles are unavailable.

Changes:

  • Applies the existing required-profile gate to every event context.
  • Adds a 24-case regression matrix covering contexts, dependencies, and profile availability.
File Description
pkg/​rulemanager/​rule_manager.go Removes the Kubernetes-only profile-gate restriction.
pkg/​rulemanager/​rule_manager_profile_test.go Verifies evaluation, export, and suppression behavior.

🧠 Review effort: Balanced


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

@matthyx matthyx added the release Create release label Oct 14, 2026
@matthyx
matthyx merged commit 579ded7 into main Oct 14, 2026
40 checks passed
@matthyx
matthyx deleted the fix/host-required-profile-gate branch October 14, 2026 06:41
@github-actions

Copy link
Copy Markdown

Performance Benchmark Results

Node-Agent Resource Usage
Metric BEFORE AFTER Delta
Avg CPU (cores) 0.199 0.192 -3.8%
Peak CPU (cores) 0.209 0.201 -4.0%
Peak CPU p95 (cores) 0.208 0.200 -3.8%
Avg Memory (MiB) 384.636 316.177 -17.8%
Peak Memory (MiB) 388.848 326.469 -16.0%
Dedup Effectiveness

No data available.

@matthyx matthyx moved this from WIP to To Archive in KS PRs tracking Oct 14, 2026
slashben added a commit that referenced this pull request Oct 18, 2026
Main gained tests after this branch was cut that predate its interface
changes: the profile-gate test (#1031) stubs CreateRuleFailure with the
old arity and does not implement EvaluateStringExpressionWithContext, so
message rendering hit the nil embedded evaluator; the network creator
test builds typesv1.Rule with a depth-0 ProfileDependency, which now
lives on the embedded RuntimeRule. Also drops a duplicate
GetProcessBootTimeNs on the ancestry test stub.

Docs-exempt: test-only changes
Signed-off-by: Ben <ben@armosec.io>
slashben added a commit that referenced this pull request Nov 2, 2026
Main gained tests after this branch was cut that predate its interface
changes: the profile-gate test (#1031) stubs CreateRuleFailure with the
old arity and does not implement EvaluateStringExpressionWithContext, so
message rendering hit the nil embedded evaluator; the network creator
test builds typesv1.Rule with a depth-0 ProfileDependency, which now
lives on the embedded RuntimeRule. Also drops a duplicate
GetProcessBootTimeNs on the ancestry test stub.

Docs-exempt: test-only changes
Signed-off-by: Ben <ben@armosec.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Create release

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants