Skip to content

cel(network): peer-selector matching for egress/ingress (rebase of #62) - #90

Open
ConstanzeTU wants to merge 1 commit into
mainfrom
rebase/celnetwork
Open

cel(network): peer-selector matching for egress/ingress (rebase of #62)#90
ConstanzeTU wants to merge 1 commit into
mainfrom
rebase/celnetwork

Conversation

@ConstanzeTU

Copy link
Copy Markdown

Rebase of the celnetwork feature (#62, previously merged to mirrormain) onto the current main.

What it adds

  • cp.was_selector_in_{egress,ingress} CEL helpers: match a runtime network peer by the namespace + pod labels that the kubeipresolver enrichment stamps onto the event — identity-based matching that survives pod IP churn and works across nodes.
  • The projection now carries each network-neighbor entry's podSelector/namespaceSelector (IngressPeers/EgressPeers); the golden projection corpus pins this surface.
  • Registered through the shared func-spec table, so the helpers are available under both cp.* and the nn.* backward-compat alias (feat(cel): restore ap./nn. namespace aliases for backward compatibility kubescape/node-agent#901) automatically.

Semantics (NetworkPolicyPeer-aligned, differs from the mirrormain version)

  • A nil namespaceSelector matches only the profiled workload's own namespace — the learned generator omits the selector exactly for same-namespace peers; treating nil as any-namespace allowed a label-matching pod in a foreign namespace to suppress the alert (cross-namespace false negative).
  • An unresolved peer is detected by the empty resolved namespace, not empty labels — a resolved label-less pod can match an empty podSelector instead of alerting on its own learned traffic.
  • Selector matching bypasses the CEL function cache (a map argument has no stable scalar cache key; the match is O(selectors)).

Validation

…tor_in_*)

Port of the celnetwork feature onto the alias-restructured CEL library:
the projection carries each network-neighbor entry's podSelector and
namespaceSelector (IngressPeers/EgressPeers), and the new
cp.was_selector_in_{egress,ingress} helpers match a runtime peer by the
namespace and pod labels the kubeipresolver enrichment stamps onto the
event - stable across pod IP churn and across nodes. Selector matching
follows NetworkPolicyPeer semantics: a nil namespaceSelector matches only
the profiled workload's own namespace, an unresolved peer is detected by
the empty resolved namespace, and an empty podSelector selects all pods
in the namespace. The functions register under cp.* and the nn.* legacy
alias; the golden projection corpus pins the peer surface.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant