Repository navigation
feat(rulemanager): CEL rule state store for cross-event correlation #875
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
slashben
wants to merge
27
commits into
main
Choose a base branch
from
feat/cel-rule-state-store
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
322c95b
refactor(rulemanager): embed armotypes.RuntimeRule in typesv1.Rule
slashben 218245a
feat(cel): expose the resolved event timestamp as a CEL variable
slashben edff50f
feat(processtree): add GetAncestorPIDs for ancestry-based rule matching
slashben 538fb1d
feat(rulestate): add the TTL-bounded rule state store
slashben ef32094
feat(cel): add state.has/get/has_ancestor/get_ancestor read functions
slashben 864c98b
feat(rulemanager): validate and execute stateWrites clauses
slashben 4fbdfa6
feat(rulemanager): attach correlation evidence to alerts
slashben 2b536ce
feat(rulestate): wire config defaults, metrics and container-removal …
slashben 3982b54
fix(rulemanager): keep ReportRuleProcessed semantics across the loop …
slashben 8cc4087
test(component): add CEL state store test rules and workload
slashben c99012f
test(component): prove the CEL state store end-to-end against real eBPF
slashben 286066c
ci: run the state-store and exec-TTY component tests
slashben f030d6f
fix(crd): add stateWrites to the Rules schema, without which it is pr…
slashben 3cb17a0
docs: record the cluster verification and the helm-charts CRD prerequ…
slashben 4e15e9d
test(processtree): satisfy the creator interface after the boot-time …
slashben ea1c863
docs: add a troubleshooting order for silent correlation failures
slashben da6d7dc
fix(rulestate): address review — node-scope cap, global-cap replaceme…
slashben 2aac452
test(rulemanager): move rule literals onto the embedded RuntimeRule
slashben a81c6f0
fix(rulestate): reclaim pod scope when the pod's last container goes
slashben 98b1fdd
fix(rulemanager): stop counting write-only legs as processed, and gofmt
slashben 93c8df1
perf(rulestate): publish the occupancy gauge, and stop the sweep cliff
slashben 46f5618
perf(rulemanager): cache compiled write clauses, seed state only wher…
slashben 65e3bc0
fix(rulemanager): count writes dropped by suppression, drop Get's unu…
slashben c4d1686
fix(cel): bound the event clock, and answer the review's three questions
slashben f24de01
test(objectcache): move projection rule literals onto the embedded Ru…
slashben 155eb59
test: adapt tests added on main to the state-store signatures
slashben a3acc30
refactor(types): drop the redundant ProfileDataRequired shadow on Rule
slashben File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package processtree | ||
|
|
||
| import ( | ||
| "github.com/armosec/armoapi-go/armotypes" | ||
| ) | ||
|
|
||
| // GetAncestorPIDs returns pid's ancestors, nearest first, up to maxDepth entries. | ||
| // pid itself is excluded. | ||
| // | ||
| // This walks the creator's global process map rather than | ||
| // containerTree.GetPidBranch, because GetPidBranch resolves a container shim and | ||
| // errors out when there is none -- which is every host / cgroup-0 process. Walking | ||
| // the map works identically for containerised and host processes. | ||
| // | ||
| // maxDepth also bounds the walk defensively: a reparenting race could in | ||
| // principle produce a parent cycle, and the evaluator must not hang. | ||
| func (ptm *ProcessTreeManagerImpl) GetAncestorPIDs(pid uint32, maxDepth int) []uint32 { | ||
| if maxDepth <= 0 { | ||
| return nil | ||
| } | ||
|
|
||
| var out []uint32 | ||
| seen := make(map[uint32]struct{}, maxDepth) | ||
| current := pid | ||
|
|
||
| for len(out) < maxDepth { | ||
| var node *armotypes.Process | ||
| func() { | ||
| ptm.mutex.RLock() | ||
| defer ptm.mutex.RUnlock() | ||
| node, _ = ptm.creator.GetProcessNode(int(current)) | ||
| }() | ||
| // PPID 0 means "parent unknown", not "parent is pid 0" -- recording it | ||
| // would add a key no state entry can ever be stored under. | ||
| if node == nil || node.PPID == 0 { | ||
| break | ||
| } | ||
| if _, dup := seen[node.PPID]; dup { | ||
| break | ||
| } | ||
| seen[node.PPID] = struct{}{} | ||
| out = append(out, node.PPID) | ||
| if node.PPID == 1 { | ||
| break | ||
| } | ||
| current = node.PPID | ||
| } | ||
| return out | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
OTEL attribute key for
ReportStateWritediverges from the documented "result" label.ReportStateWrite(ruleID, result string)callsm.suppressedOption(ruleID, result), which hardcodes the OTEL attribute key as"reason". The interface names the second parameterresult, the Prometheus implementation labels it"result"([]string{prometheusRuleIdLabel, "result"}), and the docs table documentsnode_agent_state_writes_total{rule_id,result}. Only the OTEL backend attaches this value under"reason"instead of"result".Today
resultis always"ok"(rulestate/store.goonly callsReportStateWrite(e.RuleID, "ok")), so this has no functional impact yet. But any OTEL-side query or dashboard that filters this counter on aresultattribute will not find it, and the label semantics diverge from Prometheus/docs for what is meant to be the same metric.Add a dedicated option builder (or a
resultOptioncache) that uses the"result"attribute key forReportStateWrite, keepingsuppressedOption's"reason"key forReportStateWriteRejectedandReportAlertSuppressed.🔧 Proposed fix
🤖 Prompt for AI Agents