Skip to content

test(rules): sync default-rules.yaml from rulelibrary; add R0040 + Test_32 + lint guard#844

Merged
matthyx merged 4 commits into
mainfrom
feat/bundle-r0040-sync-test32
Jun 26, 2026
Merged

test(rules): sync default-rules.yaml from rulelibrary; add R0040 + Test_32 + lint guard#844
matthyx merged 4 commits into
mainfrom
feat/bundle-r0040-sync-test32

Conversation

@matthyx

@matthyx matthyx commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to rulelibrary#39 (merged): syncs node-agent's bundled default-rules.yaml from rulelibrary's rules-crd.yaml, enables R0040 in the binding, and adds the Test_32_UnexpectedProcessArguments component test + a default-rules.yaml lint guard. Replaces #805 (whose engine landed separately via #843). The engine (3-arg get_exec_path overload + ap.was_executed_with_args) is already on main.

What's in it

  • default-rules.yaml ← synced from rulelibrary#39's rules-crd.yaml. Adds R0040, the R1000 /dev/shm rewrite, the R0001/R0007/R1001/R1004 exepath-first ternary, plus R2000/R2001 and the rule renames already in rulelibrary. (Purely additive — no bundled rule is dropped.)
  • default-rule-binding.yaml ← enables "Unexpected process arguments" (R0040) and updates the renamed rule names (R1000/R1003/R1015/R2001) so every ruleName still resolves. Verified: all 27 bound names exist in default-rules.yaml.
  • Test_32_UnexpectedProcessArguments + fixtures, registered in the component-tests matrix.
  • default_rules_yaml_lint_test.go guard — 3 checks, all green against the synced bundle.

Two things for reviewers

  1. Migrated rules use the ternary, not the 3-arg overload. R0001/R0007/R1001/R1004 use event.exepath != "" ? event.exepath : parse.get_exec_path(event.args, event.comm) — backward-compatible (runs on any agent). Only R0040 uses the 3-arg overload (it also needs ap.was_executed_with_args). The lint guard was adapted accordingly: it now rejects an unguarded 2-arg call but allows the ternary and the 3-arg forms.

  2. Wildcard sentinel / storage version. Test_32 uses dynamicpathdetector.WildcardIdentifier — the zero-or-more exec-args sentinel in the pinned storage v0.0.278 (where "*" = zero-or-more), matching the existing exec_test.go convention. Storage v0.0.287 later renamed this to ExecArgsWildcard ("⋯⋯") and made "*" literal. R0040's bundled description (inherited verbatim from rulelibrary) already speaks in "⋯⋯" terms, so it fully aligns only after a coordinated storage v0.0.278 → v0.0.287 bump (which also touches exec_test.go's "*" cases) — out of scope here, flagged as a follow-up.

Verification

  • go test ./pkg/rulemanager/cel/libraries/parse/ -run TestDefaultRulesYAML → 3/3 pass
  • go vet -tags=component ./tests/ → compiles (Test_32 included)
  • binding ↔ rules name consistency checked (27/27)
  • Test_32 itself runs in the component-tests CI job (needs a cluster)

Closes #805.

…t_32, lint guard

Syncs the bundled tests/chart/templates/node-agent/default-rules.yaml from
kubescape/rulelibrary's rules-crd.yaml (the source of truth after rulelibrary#39):
- adds R0040 "Unexpected process arguments" (3-arg get_exec_path overload +
  ap.was_executed_with_args, both in node-agent v0.3.147)
- the migrated exec rules (R0001/R0007/R1001/R1004) use the backward-compatible
  exepath-first ternary rather than the 3-arg overload
- adds R2000/R2001 and picks up the rule renames already in rulelibrary
- reconciles default-rule-binding.yaml: enables R0040 and updates the renamed
  rule names (R1000/R1003/R1015/R2001) so every binding still resolves

Adds Test_32_UnexpectedProcessArguments (+ fixtures) and registers it in the
component-tests matrix. Test_32 uses dynamicpathdetector.WildcardIdentifier
(the zero-or-more exec-args sentinel in the pinned storage v0.0.278), matching
the existing exec_test.go convention. The ExecArgsWildcard ("⋯⋯") form and the
"*"->literal flip arrived in storage v0.0.287 and are a separate coordinated
storage bump.

Adds pkg/rulemanager/cel/libraries/parse/default_rules_yaml_lint_test.go to
guard the bundled rules: no UNGUARDED 2-arg get_exec_path (the exepath-first
ternary or the 3-arg form is required), no string(event.args), and R1000
detects /dev/shm via argv[0]. All three pass against the synced bundle.

Replaces node-agent#805 (its engine landed separately via #843).

Signed-off-by: matthyx <matthias.bertschy@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Docs-exempt: test-only + rule-bundle sync; node-agent engine/behavior unchanged (R0040 engine shipped in #843, rule bodies are sourced from kubescape/rulelibrary).
@matthyx matthyx added the ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin) label Jun 26, 2026
@matthyx matthyx mentioned this pull request Jun 26, 2026
5 tasks
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@matthyx, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 41 minutes and 24 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2fe12c88-0b22-4f13-9932-db4f8303f949

📥 Commits

Reviewing files that changed from the base of the PR and between 86de444 and 104b834.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (10)
  • .github/workflows/component-tests.yaml
  • go.mod
  • pkg/rulemanager/cel/libraries/applicationprofile/exec_test.go
  • pkg/rulemanager/cel/libraries/parse/default_rules_yaml_lint_test.go
  • tests/chart/templates/node-agent/default-rule-binding.yaml
  • tests/chart/templates/node-agent/default-rules.yaml
  • tests/component_test.go
  • tests/resources/curl-exec-arg-wildcards-deployment.yaml
  • tests/resources/exec-arg-wildcards-profile.yaml
  • tests/resources/r0002-files-access-enabled.yaml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/bundle-r0040-sync-test32

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.

@github-actions

Copy link
Copy Markdown

Performance Benchmark Results

Node-Agent Resource Usage
Metric BEFORE AFTER Delta
Avg CPU (cores) 0.188 0.191 +1.5%
Peak CPU (cores) 0.198 0.198 +0.1%
Avg Memory (MiB) 328.781 266.961 -18.8%
Peak Memory (MiB) 332.074 270.504 -18.5%
Dedup Effectiveness

No data available.

matthyx and others added 2 commits June 26, 2026 13:06
… case

- Test_02_AllAlertsFromMaliciousApp: update the R1000 expectation key from the
  old "Process executed from malicious source" to the synced name
  "Process Executed from /dev/shm" (rule renamed in rulelibrary).
- Test_32/echo_literal_star_does_not_broaden_R0040: t.Skip — it asserts the
  "*"-is-literal semantics introduced in storage v0.0.287, but main pins
  v0.0.278 where "*" (WildcardIdentifier) is a zero-or-more wildcard, so a
  literal "*" does broaden. Re-enable with the coordinated storage bump. The
  other 9 Test_32 subtests pass.

Test_27 (R0002 was disabled by the wholesale bundle sync) is still pending a
decision on whether to keep R0002 enabled in node-agent's bundle.

Docs-exempt: test-only fix, no node-agent behavioral/API change.

Signed-off-by: matthyx <matthias.bertschy@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…n Test_27

#3 (the original #805 intent): bump kubescape/storage v0.0.278 -> v0.0.287,
which introduces ExecArgsWildcard ("⋯⋯") as the zero-or-more exec-args wildcard
and makes "*" a literal in exec args. Migrate exec_test.go's "*"-as-wildcard
profile entries to dynamicpathdetector.ExecArgsWildcard, revert Test_32 from the
v0.0.278 WildcardIdentifier stopgap back to ExecArgsWildcard, and un-skip
echo_literal_star_does_not_broaden_R0040 (it now passes — "*" is literal). Engine
code is unchanged: it routes through dynamicpathdetector.MatchExecArgs (stable
signature); only test fixtures supply the sentinel.

#2: Test_27_ApplicationProfileOpens enables R0002 ("Files Access Anomalies"),
which ships disabled in the synced bundle, for its own cluster only — by applying
tests/resources/r0002-files-access-enabled.yaml (an override Rules CRD with R0002
enabled). The rules-watcher filters disabled rules before its per-ID merge, so it
uses the enabled override; default-rules.yaml is untouched. Component-test matrix
jobs run on isolated clusters. (Test_33 also exercises R0002 but is not in the
matrix.)

Unit tests (applicationprofile, parse, objectcache) pass under v0.0.287; the
component tests compile.

Docs-exempt: dependency bump + test updates; the exec-args wildcard sentinel is
documented in storage and the rulelibrary R0040 rule, not in node-agent docs.

Signed-off-by: matthyx <matthias.bertschy@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Performance Benchmark Results

Node-Agent Resource Usage
Metric BEFORE AFTER Delta
Avg CPU (cores) 0.000 0.000 N/A
Peak CPU (cores) 0.000 0.000 N/A
Avg Memory (MiB) 0.000 0.000 N/A
Peak Memory (MiB) 0.000 0.000 N/A
Dedup Effectiveness

No data available.

Test_02_AllAlertsFromMaliciousApp expects "Files Access Anomalies in container"
(R0002) to fire, but R0002 ships disabled in the synced bundle — so last commit's
rename fix alone left Test_02 red on R0002. Extract enableR0002ForTest (apply the
override Rules CRD, return a cleanup func) and use it from both Test_02 and
Test_27, replacing Test_27's inline copy.

Docs-exempt: test-only change.

Signed-off-by: matthyx <matthias.bertschy@gmail.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Performance Benchmark Results

Node-Agent Resource Usage
Metric BEFORE AFTER Delta
Avg CPU (cores) 0.219 0.212 -3.4%
Peak CPU (cores) 0.231 0.222 -4.0%
Avg Memory (MiB) 328.842 270.934 -17.6%
Peak Memory (MiB) 333.996 276.762 -17.1%
Dedup Effectiveness

No data available.

@matthyx
matthyx merged commit d8f928a into main Jun 26, 2026
31 of 32 checks passed
@matthyx
matthyx deleted the feat/bundle-r0040-sync-test32 branch June 26, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Created through Armosec AI tooling (armosec-shared-rules plugin)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant