-
Notifications
You must be signed in to change notification settings - Fork 26
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
25
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
25 commits
Select commit
Hold shift + click to select a range
698a9cc
refactor(rulemanager): embed armotypes.RuntimeRule in typesv1.Rule
slashben ed06bb6
feat(cel): expose the resolved event timestamp as a CEL variable
slashben 8b60e87
feat(processtree): add GetAncestorPIDs for ancestry-based rule matching
slashben 6f30b1f
feat(rulestate): add the TTL-bounded rule state store
slashben 1284af0
feat(cel): add state.has/get/has_ancestor/get_ancestor read functions
slashben d8cda9a
feat(rulemanager): validate and execute stateWrites clauses
slashben cab04de
feat(rulemanager): attach correlation evidence to alerts
slashben 9d28fea
feat(rulestate): wire config defaults, metrics and container-removal …
slashben 8e3d6ac
fix(rulemanager): keep ReportRuleProcessed semantics across the loop …
slashben 1ee9689
test(component): add CEL state store test rules and workload
slashben f07c520
test(component): prove the CEL state store end-to-end against real eBPF
slashben 3a393c1
ci: run the state-store and exec-TTY component tests
slashben 3149b06
fix(crd): add stateWrites to the Rules schema, without which it is pr…
slashben 1436624
docs: record the cluster verification and the helm-charts CRD prerequ…
slashben df038f8
test(processtree): satisfy the creator interface after the boot-time …
slashben 149fb6c
docs: add a troubleshooting order for silent correlation failures
slashben 1b7520f
fix(rulestate): address review — node-scope cap, global-cap replaceme…
slashben 44c4b1f
test(rulemanager): move rule literals onto the embedded RuntimeRule
slashben 8076cdf
fix(rulestate): reclaim pod scope when the pod's last container goes
slashben 989eba1
fix(rulemanager): stop counting write-only legs as processed, and gofmt
slashben 4b8606b
perf(rulestate): publish the occupancy gauge, and stop the sweep cliff
slashben 969fe89
perf(rulemanager): cache compiled write clauses, seed state only wher…
slashben 8613ca7
fix(rulemanager): count writes dropped by suppression, drop Get's unu…
slashben 0b90bd3
fix(cel): bound the event clock, and answer the review's three questions
slashben f513e83
test(objectcache): move projection rule literals onto the embedded Ru…
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
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