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
41
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
41 commits
Select commit
Hold shift + click to select a range
ae7c2a2
refactor(rulemanager): embed armotypes.RuntimeRule in typesv1.Rule
slashben ed744dd
feat(cel): expose the resolved event timestamp as a CEL variable
slashben db055f5
feat(processtree): add GetAncestorPIDs for ancestry-based rule matching
slashben bf9b72d
feat(rulestate): add the TTL-bounded rule state store
slashben 8f2bdeb
feat(cel): add state.has/get/has_ancestor/get_ancestor read functions
slashben 5c2171b
feat(rulemanager): validate and execute stateWrites clauses
slashben fb305a4
feat(rulemanager): attach correlation evidence to alerts
slashben 9d90be1
feat(rulestate): wire config defaults, metrics and container-removal …
slashben d41693a
fix(rulemanager): keep ReportRuleProcessed semantics across the loop …
slashben 4dd1f31
test(component): add CEL state store test rules and workload
slashben 1d7d29e
test(component): prove the CEL state store end-to-end against real eBPF
slashben 99ae472
ci: run the state-store and exec-TTY component tests
slashben 3d5a274
fix(crd): add stateWrites to the Rules schema, without which it is pr…
slashben cb2af2d
docs: record the cluster verification and the helm-charts CRD prerequ…
slashben 531c3d0
test(processtree): satisfy the creator interface after the boot-time …
slashben eaa7ccd
docs: add a troubleshooting order for silent correlation failures
slashben f9a7a13
fix(rulestate): address review — node-scope cap, global-cap replaceme…
slashben 139d9f9
test(rulemanager): move rule literals onto the embedded RuntimeRule
slashben 03a1173
fix(rulestate): reclaim pod scope when the pod's last container goes
slashben ce423a2
fix(rulemanager): stop counting write-only legs as processed, and gofmt
slashben a6fbacb
perf(rulestate): publish the occupancy gauge, and stop the sweep cliff
slashben 633cf4a
perf(rulemanager): cache compiled write clauses, seed state only wher…
slashben 337c29b
fix(rulemanager): count writes dropped by suppression, drop Get's unu…
slashben 463ff39
fix(cel): bound the event clock, and answer the review's three questions
slashben 0ef67f3
test(objectcache): move projection rule literals onto the embedded Ru…
slashben a699419
test: adapt tests added on main to the state-store signatures
slashben c1758ed
refactor(types): drop the redundant ProfileDataRequired shadow on Rule
slashben e36aa67
fix(rulemanager): reset correlation evidence per rule and keep cached…
slashben d76ec5d
fix(rulestate): map the production host container ID to the host bucket
slashben 7bd2f75
fix(statewrites): route DNS writes by the rule-facing event type
slashben ddde67f
test: adapt tests added on main to the state-store signatures
slashben a9d2124
docs(rulestate): separate value failures from write-skipping failures
slashben 577abc9
feat(rulestate): atomic Incr with a fixed window, and Delete
slashben 1f9861d
feat(statewrites): validate increment and clear operations
slashben 0b3cb96
feat(state): accessor count snapshot and _count provenance
slashben ab7604c
feat(state): state.count(name[, key]) CEL member
slashben 23b3f3f
feat(rulestate): counters -- increment and clear writes, state.count
slashben 26d63a9
test(component): counter rule alerts on the third exec
slashben 334a2ba
fix(statewrites): measure a counter's window on the agent clock
slashben cec1702
feat(statewrites): reject an explicit increment: 0 or clear: false
slashben adabbca
chore(deps): bump armoapi-go to v0.0.774 for StateWrite increment and…
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
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