Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
219 commits
Select commit Hold shift + click to select a range
d5be2e9
added interfaces for rule manager refactor
afek854 Jul 24, 2025
eddcef6
added structure
afek854 Jul 24, 2025
f350c8a
added profile validator
afek854 Jul 24, 2025
531da25
added v1
afek854 Jul 27, 2025
a0c3245
added profile validators
afek854 Jul 27, 2025
d2c6899
go mod tidy
amitschendel Jul 27, 2025
13331e4
Adding base helpers pkg
amitschendel Jul 27, 2025
92cd0b2
added rule failure creator and changed rule_manager logic
afek854 Jul 27, 2025
9c36107
Adding lib
amitschendel Jul 27, 2025
021a6aa
Caching programs
amitschendel Jul 27, 2025
197b7da
integrate new rule manager
afek854 Jul 27, 2025
c9f6110
Merge branch 'feature/refactor_rule_engine' into dev/rre
amitschendel Jul 28, 2025
cfab916
Resolving conflicts
amitschendel Jul 28, 2025
151c993
Adding crd
amitschendel Jul 28, 2025
7a9f009
Dev/rre (#594)
amitschendel Jul 28, 2025
289e81a
organized imports
afek854 Jul 28, 2025
9edf8c5
added watcher & tests
afek854 Jul 28, 2025
001c265
added watcher and integration with binding
afek854 Jul 28, 2025
c62f51b
Changing types
amitschendel Jul 28, 2025
ffc45cf
Defining types
amitschendel Jul 29, 2025
a0c86a9
Fixing code
amitschendel Jul 29, 2025
4e297ae
merged
afek854 Jul 29, 2025
62e82bf
fixed container name
afek854 Jul 29, 2025
e79fd44
fixed conflicts
afek854 Jul 29, 2025
f1419d2
separated mock
afek854 Jul 29, 2025
e719619
fixed watcher & create event with check struct
afek854 Jul 29, 2025
8cf32cf
Changing event
amitschendel Jul 29, 2025
9550178
Updating code
amitschendel Jul 29, 2025
dce926b
modify cel arguments & events check struct
afek854 Jul 29, 2025
efd6a1e
Adding some code
amitschendel Jul 29, 2025
9659531
Adding opt
amitschendel Jul 29, 2025
c83b5d6
Adding fixed code
amitschendel Jul 29, 2025
1d06f36
Fixing nested event check
amitschendel Jul 29, 2025
f5f4522
Updating struct to support list of rules
amitschendel Jul 30, 2025
82b8507
updated rule struct
afek854 Jul 30, 2025
006e83a
removed logs and fixed nil
afek854 Jul 30, 2025
b9db557
set process tree correctly
afek854 Jul 30, 2025
f11cca7
added ap library
afek854 Jul 30, 2025
917bf04
added exec libraries
afek854 Jul 30, 2025
383a253
added open library functions
afek854 Jul 30, 2025
276a0ab
added ap syscall & capability libs
afek854 Jul 30, 2025
af6bfb5
added network functions
afek854 Jul 30, 2025
f40189e
added network functions
afek854 Jul 30, 2025
3c41a5c
implement interface
afek854 Jul 30, 2025
cc763d0
idk what is this conflict
amitschendel Jul 31, 2025
be5a901
Doing some cleanups
amitschendel Jul 31, 2025
40d073b
Changing event serialize interface
amitschendel Jul 31, 2025
7c88a5d
Adding extra check for deprecated field
amitschendel Jul 31, 2025
539abdc
Adding api server helper
amitschendel Jul 31, 2025
559d86b
Adding validation for event type
amitschendel Jul 31, 2025
c5f2dd3
added profile metadata
afek854 Aug 3, 2025
e8dab1b
added cache for cel profile checks libraries
afek854 Aug 3, 2025
00d5e1e
added cache config
afek854 Aug 3, 2025
15d1bd8
reorganized cel libraries structure
afek854 Aug 3, 2025
29e603c
added parse lib and moved k8s lib
afek854 Aug 3, 2025
00931e4
added net library
afek854 Aug 3, 2025
b1191a3
added network helper functions
afek854 Aug 3, 2025
28655b1
removed cache for k8s and parse functions
afek854 Aug 3, 2025
4671fd7
added support for rule policy
afek854 Aug 3, 2025
2b8dda8
set wlid details
afek854 Aug 3, 2025
5294c64
added strings model
afek854 Aug 3, 2025
5392938
removed profile validator & fixed rule policy logic
afek854 Aug 3, 2025
b05292a
hash unique id
afek854 Aug 3, 2025
e2f0df8
added mock & fixed rule cooldown
afek854 Aug 3, 2025
6909ef0
remove log
afek854 Aug 3, 2025
a92d812
added process lib and get container by name
afek854 Aug 4, 2025
85e202b
added process lib
afek854 Aug 4, 2025
88b4458
fixed rules
afek854 Aug 4, 2025
c455557
Updating chart
amitschendel Aug 5, 2025
cea4cb6
Adding rules
amitschendel Aug 5, 2025
018b72f
Removing old interface
amitschendel Aug 5, 2025
c619141
fixed rule cooldown
afek854 Aug 5, 2025
b37e5ed
added logs and reduced cachee
afek854 Aug 5, 2025
d7aa3b9
fixed get container by name
afek854 Aug 5, 2025
456c04c
bump rules
afek854 Aug 5, 2025
b5388db
Feature/cpu (#602)
amitschendel Aug 5, 2025
6db62cd
added rule adapters
afek854 Aug 6, 2025
58a25c4
added tomap to rule adapters and event as cel
afek854 Aug 6, 2025
6865825
update rules
afek854 Aug 6, 2025
20a89de
Merge branch 'main' of github.com:kubescape/node-agent into feature/r…
afek854 Aug 6, 2025
53db1f0
fixed config
afek854 Aug 7, 2025
1ef4026
remove comments
afek854 Aug 7, 2025
71cfa2e
added third party tracers initialzation
afek854 Aug 10, 2025
28b3255
use ResultCallBack
afek854 Aug 10, 2025
0cf1495
fixed tests
afek854 Aug 10, 2025
bb2cd3c
rule adapters as argument
afek854 Aug 10, 2025
06ecac1
fixed deadlock bug
afek854 Aug 10, 2025
7128e27
initialize cel from outside
afek854 Aug 11, 2025
79fbd39
Merge branch 'main' of github.com:kubescape/node-agent into feature/r…
afek854 Aug 12, 2025
7e7a2de
Merge branch 'main' of github.com:kubescape/node-agent into feature/r…
afek854 Aug 13, 2025
62a8571
set http rule alert
afek854 Aug 17, 2025
1087158
Merge branch 'main' of github.com:kubescape/node-agent into feature/r…
amitschendel Aug 17, 2025
19550b4
Feature/cel efficiency (#623)
afek854 Aug 18, 2025
57fe135
added a comment regarding 3rd party tracers
afek854 Aug 19, 2025
16302ee
Perf enhancements (#624)
amitschendel Aug 19, 2025
1de6a17
Adding metrics and cooldown check (#628)
amitschendel Aug 20, 2025
b313c63
Merge branch 'main' into feature/refactor_rule_engine
amitschendel Aug 21, 2025
39e4c3b
CEL evaluate native types with xcel (#621)
matthyx Aug 24, 2025
748e3bd
Updating rule struct with AgentVersionRequirement
amitschendel Aug 24, 2025
34ff7c8
Adding semver for rules (#631)
amitschendel Aug 24, 2025
4d99174
added extra to rule failure (#632)
afek854 Aug 24, 2025
7c33d1c
ignore rulebinding configurable (#629)
afek854 Aug 24, 2025
0394bd7
http evaluation by map (#633)
afek854 Aug 25, 2025
721a336
Adding option to register custom types (#634)
amitschendel Aug 25, 2025
7dfb639
Fix http evaluation by map (#635)
afek854 Aug 25, 2025
fa5bef8
added error log on enrichment
afek854 Aug 25, 2025
32b94fd
added rule policy test
afek854 Aug 25, 2025
e3f454b
added event type
afek854 Aug 25, 2025
c062305
Removing log
amitschendel Aug 27, 2025
e344f6f
Fix custom type registration
amitschendel Aug 27, 2025
71c9e61
Bumping to go 1.25
amitschendel Aug 27, 2025
4943734
added container receivers
afek854 Aug 27, 2025
ff45d67
Merge branch 'main' of github.com:kubescape/node-agent into feature/r…
afek854 Aug 31, 2025
b21bf9b
updated rule names
afek854 Aug 31, 2025
5d04059
Fixing Identifiers of http
amitschendel Sep 3, 2025
94428ae
add RuleManagerMock
matthyx Sep 3, 2025
7a001ed
Adding http profile checks
amitschendel Sep 4, 2025
6d39ca5
Merge branch 'feature/refactor_rule_engine' of github.com:kubescape/n…
amitschendel Sep 4, 2025
66b1ac4
Adding host check for http
amitschendel Sep 4, 2025
89e2521
refactor: update tracer configuration to use typed config parameters
matthyx Sep 10, 2025
3d6a003
Merge pull request #647 from kubescape/fix-config
matthyx Sep 10, 2025
92fef0b
bump inspektor gadget
matthyx Sep 12, 2025
aadc90d
cleaning up code
matthyx Sep 12, 2025
628d939
add open tracer
matthyx Sep 12, 2025
27570cc
wip add other tracers
matthyx Sep 24, 2025
a0a1080
add CEL accessors
matthyx Oct 8, 2025
b54babb
Fixing dns tracer (#653)
amitschendel Oct 8, 2025
c8f4aab
bump ig to v0.45.0
matthyx Oct 8, 2025
da0c853
fix sbom_manager with sqlite import
matthyx Oct 8, 2025
90a9164
refactor interfaces and CEL accessors
matthyx Oct 9, 2025
6737893
Adding initial eBPF refactor
amitschendel Oct 9, 2025
d48a03c
add Makefile target for tracers.tar
matthyx Oct 10, 2025
0e2ab85
enable our tracers
matthyx Oct 10, 2025
28091dc
Adding http eBPF image based
amitschendel Oct 12, 2025
bfe48a5
Adding randmox refactor
amitschendel Oct 12, 2025
bb60c3f
plug http and randomx tracers
matthyx Oct 13, 2025
c97c894
Adding network gadget
amitschendel Oct 15, 2025
9ac2058
Adding network tracer to Makefile
amitschendel Oct 15, 2025
63dfeb8
use network tracer instead of trace_tcp
matthyx Oct 15, 2025
45ea3b3
removing GetPort in favor of GetDstPort
matthyx Oct 16, 2025
a0881d0
enable paths option in dns and exec tracers
matthyx Oct 16, 2025
fb803d6
add missing datasource accessors
matthyx Oct 16, 2025
5b7b07f
remove full path from open events
matthyx Oct 16, 2025
5aca7a2
Switching map type to LRU
amitschendel Oct 16, 2025
7005944
Fixing make file
amitschendel Oct 16, 2025
e89a6a6
Adding new rules
amitschendel Oct 16, 2025
cce1c4b
Fixing CI
amitschendel Oct 16, 2025
7408a03
Fixing make file
amitschendel Oct 16, 2025
d2c33ee
Update socket enricher initialization to set parameters for cwd and e…
matthyx Oct 16, 2025
e7eb602
enable io-uring tracer
matthyx Oct 16, 2025
ae6c27b
check for nils in datasource, add logs for unimplemented
matthyx Oct 16, 2025
394a0ec
enable procfs tracer
matthyx Oct 16, 2025
673b1aa
add debug logs for events
matthyx Oct 16, 2025
db8f98e
remove EverythingEvent for strict interface safety
matthyx Oct 17, 2025
ccade61
add missing bindings
matthyx Oct 17, 2025
217d38c
Commenting out json format
amitschendel Oct 19, 2025
3a0b84a
Fixing potential panic
amitschendel Oct 19, 2025
a738b41
Fixing nil deref
amitschendel Oct 19, 2025
815be54
Fixing comm access
amitschendel Oct 19, 2025
121d844
Adding dns proto
amitschendel Oct 19, 2025
ed8fd13
Removing proto
amitschendel Oct 19, 2025
570d480
Adding protocol translation
amitschendel Oct 19, 2025
c318110
Adding more fixes
amitschendel Oct 19, 2025
1ddfaba
Removing ip raw translation
amitschendel Oct 19, 2025
da9da58
Removing the bpf_htonl call to maintain the network byte order
amitschendel Oct 19, 2025
98a5488
Removing bpf_htonl
amitschendel Oct 19, 2025
3e2c1fd
handle exit events, replicate datasource changes to struct event
matthyx Oct 20, 2025
a7e2e0f
Switching to CamelCase
amitschendel Oct 20, 2025
e35c2fc
Removing enum of event types
amitschendel Oct 20, 2025
c375f2d
trigger one callback call for each syscall in event
matthyx Oct 20, 2025
b2edf98
Adding annotations for struct event
amitschendel Oct 20, 2025
d086a9e
use IG patch for wrong container attribution of events
matthyx Oct 21, 2025
faae5e3
update rules
matthyx Oct 21, 2025
9f9f55f
update rules
matthyx Oct 21, 2025
4f377db
use IG patch for wrong container attribution of events
matthyx Oct 21, 2025
7c5ba81
Merge branch 'feature/ebpf-ibg' of github.com:kubescape/node-agent in…
amitschendel Oct 21, 2025
6caddb8
Adding some logs
amitschendel Oct 21, 2025
686a4f0
Fixing buffer
amitschendel Oct 21, 2025
8f1abd4
Adding some fixes
amitschendel Oct 21, 2025
c66e2de
Fixing http
amitschendel Oct 21, 2025
4e744e3
Pushing some debug loogs
amitschendel Oct 21, 2025
d23745f
complain when containerID is empty
matthyx Oct 21, 2025
0b7ecbd
fix http event enrichment
matthyx Oct 21, 2025
fb3c259
Fixing types
amitschendel Oct 21, 2025
850c2dc
Adding upper layer event types
amitschendel Oct 21, 2025
3d92443
Doing some fixes in field access of fork events
amitschendel Oct 22, 2025
eeb4410
Fixing pid
amitschendel Oct 22, 2025
2430c86
comment out missing fields in syscall events
matthyx Oct 21, 2025
4e32c2e
enabling again all rules
matthyx Oct 22, 2025
2820c56
Removing old eBPF infra
amitschendel Oct 22, 2025
aa58034
Merge branch 'feature/ebpf-ibg' of github.com:kubescape/node-agent in…
amitschendel Oct 22, 2025
a389055
use container name as comm for syscall events
matthyx Oct 22, 2025
022a8e5
Switching to uint32_t
amitschendel Oct 22, 2025
baae7da
add info log for syscall fields override
matthyx Oct 22, 2025
ccfb987
getting rid of GetCommFromEvent
matthyx Oct 22, 2025
8e71e6b
add log for syscall reporting
matthyx Oct 22, 2025
e42b469
add log for syscall reporting
matthyx Oct 22, 2025
af77b1f
Adding gadgets
amitschendel Oct 22, 2025
3d0ae7a
Merge branch 'feature/ebpf-ibg' of github.com:kubescape/node-agent in…
amitschendel Oct 22, 2025
50a2684
add log for syscall reporting
matthyx Oct 22, 2025
dce6a4f
disambiguate child and parent pid for fork events
matthyx Oct 22, 2025
7c685f5
do not fail test if PrintAppLogs finds no pod
matthyx Oct 22, 2025
c761a31
fix syscall callbacks by using new events
matthyx Oct 22, 2025
d008000
adding logs for processtree test
matthyx Oct 23, 2025
6d530d2
Removing event from stdout and http logs
amitschendel Oct 23, 2025
8575bdb
Adding tracers
amitschendel Oct 23, 2025
6635584
Adding new rules
amitschendel Oct 23, 2025
9b43b2d
Adding new exit fields
amitschendel Oct 23, 2025
434ea0b
add log for exec event
matthyx Oct 23, 2025
de07c49
Adding some types
amitschendel Oct 23, 2025
c157839
Merge branch 'feature/ebpf-ibg' of github.com:kubescape/node-agent in…
amitschendel Oct 23, 2025
1ba467c
Adding buffer for container eol notifications
amitschendel Oct 23, 2025
a93d1fe
Fixing config test
amitschendel Oct 23, 2025
b78df2e
print logs of process-tree pod after test 24
matthyx Oct 23, 2025
2d5947a
increase waiting time for alerts
matthyx Oct 23, 2025
e270455
increase map-fetch-interval for syscall tracer
matthyx Oct 23, 2025
b0f4778
refactor: update process event handling and clean up unused methods
matthyx Oct 23, 2025
4b41532
try to avoid race in AlertManagerExporter
matthyx Oct 24, 2025
90b6d1c
proposal: use strong types for events
matthyx Oct 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/bypass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
CGO_ENABLED: 0
GO111MODULE: "on"
BUILD_PLATFORM: linux/amd64,linux/arm64
GO_VERSION: "1.24"
GO_VERSION: "1.25"
REQUIRED_TESTS: ''
FORCE: true
COSIGN: true
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/component-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ jobs:
registry: quay.io/kubescape
username: ${{ secrets.QUAYIO_REGISTRY_USERNAME }}
password: ${{ secrets.QUAYIO_REGISTRY_PASSWORD }}
- name: Install IG
run: |
sudo apt-get update
sudo apt-get install -y jq curl
IG_ARCH=amd64
IG_VERSION=$(curl -s https://api.github.com/repos/inspektor-gadget/inspektor-gadget/releases/latest | jq -r .tag_name)
echo "Installing IG version: ${IG_VERSION}"
curl -sL https://github.com/inspektor-gadget/inspektor-gadget/releases/download/${IG_VERSION}/ig-linux-${IG_ARCH}-${IG_VERSION}.tar.gz | sudo tar -C /usr/local/bin -xzf - ig
sudo chmod +x /usr/local/bin/ig
- name: Build the Image and Push to Quay.io
id: build-and-push-image
run: |
Expand Down Expand Up @@ -104,7 +113,7 @@ jobs:
CGO_ENABLED: 0
uses: actions/setup-go@v4
with:
go-version: "1.24"
go-version: "1.25"
- name: Run test
run: |
cd tests && go test -v ./... -run ${{ matrix.test }} --timeout=20m --tags=component
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-created.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
pr-created:
uses: kubescape/workflows/.github/workflows/incluster-comp-pr-created.yaml@main
with:
GO_VERSION: "1.24"
GO_VERSION: "1.25"
CGO_ENABLED: 0
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/pr-merged.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
CGO_ENABLED: 0
GO111MODULE: "on"
BUILD_PLATFORM: linux/amd64,linux/arm64
GO_VERSION: "1.24"
GO_VERSION: "1.25"
REQUIRED_TESTS: '[
"relevantCVEs",
"relevancy_enabled_stop_sniffing",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ temp
resources/ebpf/falco/*
node-agent
__pycache__
tracers.tar
15 changes: 13 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,25 @@ DOCKERFILE_PATH=./build/Dockerfile
BINARY_NAME=node-agent

IMAGE?=quay.io/kubescape/$(BINARY_NAME)
GADGETS=advise_seccomp trace_capabilities trace_dns trace_exec trace_open
VERSION=:v0.45.0
KUBESCAPE_GADGETS=exit fork hardlink http iouring_new iouring_old network ptrace randomx ssh symlink kmod unshare bpf
TAG?=test
# TAG?=v0.0.1

binary:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BINARY_NAME) ./cmd/main.go

docker-build:
docker-build-only:
docker buildx build --platform linux/amd64 -t $(IMAGE):$(TAG) -f $(DOCKERFILE_PATH) --load .

docker-build: gadgets
docker buildx build --platform linux/amd64 -t $(IMAGE):$(TAG) -f $(DOCKERFILE_PATH) --load .

docker-push:
docker push $(IMAGE):$(TAG)
docker push $(IMAGE):$(TAG)

gadgets:
$(foreach img,$(KUBESCAPE_GADGETS),$(MAKE) -C ./pkg/ebpf/gadgets/$(img) build IMAGE=$(img) TAG=latest;)
$(foreach img,$(GADGETS),sudo ig image pull $(img)$(VERSION);)
sudo ig image export $(foreach img,$(GADGETS),$(img)$(VERSION)) $(foreach img,$(KUBESCAPE_GADGETS),$(img):latest) tracers.tar
3 changes: 2 additions & 1 deletion build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM --platform=$BUILDPLATFORM golang:1.24-bookworm AS builder
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder

ENV GO111MODULE=on CGO_ENABLED=0
WORKDIR /work
Expand All @@ -12,6 +12,7 @@ RUN --mount=target=. \
FROM gcr.io/distroless/static-debian12:latest

COPY --from=builder /out/node-agent /usr/bin/node-agent
COPY tracers.tar /root/tracers.tar
COPY configuration/ig-config.yaml /root/.ig/config.yaml

ARG image_version
Expand Down
24 changes: 24 additions & 0 deletions build/Dockerfile.debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder

ENV GO111MODULE=on CGO_ENABLED=0
WORKDIR /work
ARG TARGETOS TARGETARCH

RUN go install github.com/go-delve/delve/cmd/dlv@latest
RUN --mount=target=. \
--mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /out/node-agent ./cmd/main.go

FROM gcr.io/distroless/static-debian12:debug

COPY --from=builder /go/bin/dlv /usr/bin/dlv
COPY --from=builder /out/node-agent /usr/bin/node-agent
COPY tracers.tar /root/tracers.tar
COPY configuration/ig-config.yaml /root/.ig/config.yaml

ARG image_version
ENV RELEASE=$image_version

WORKDIR /root
ENTRYPOINT ["/usr/bin/dlv", "--listen=:40000", "--headless=true", "--continue", "--accept-multiclient", "--api-version=2", "--log", "exec", "/usr/bin/node-agent"]
41 changes: 32 additions & 9 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ import (
apitypes "github.com/armosec/armoapi-go/armotypes"
utilsmetadata "github.com/armosec/utils-k8s-go/armometadata"
"github.com/cilium/ebpf/rlimit"
mapset "github.com/deckarep/golang-set/v2"
"github.com/goradd/maps"
"github.com/grafana/pyroscope-go"

igconfig "github.com/inspektor-gadget/inspektor-gadget/pkg/config"
containercollection "github.com/inspektor-gadget/inspektor-gadget/pkg/container-collection"
beUtils "github.com/kubescape/backend/pkg/utils"
Expand All @@ -24,6 +27,7 @@ import (
"github.com/kubescape/node-agent/pkg/config"
"github.com/kubescape/node-agent/pkg/containerprofilemanager"
containerprofilemanagerv1 "github.com/kubescape/node-agent/pkg/containerprofilemanager/v1"
"github.com/kubescape/node-agent/pkg/containerwatcher"
containerwatcherv2 "github.com/kubescape/node-agent/pkg/containerwatcher/v2"
"github.com/kubescape/node-agent/pkg/dnsmanager"
"github.com/kubescape/node-agent/pkg/exporters"
Expand All @@ -42,14 +46,17 @@ import (
"github.com/kubescape/node-agent/pkg/objectcache/k8scache"
"github.com/kubescape/node-agent/pkg/objectcache/networkneighborhoodcache"
objectcachev1 "github.com/kubescape/node-agent/pkg/objectcache/v1"
processtree "github.com/kubescape/node-agent/pkg/processtree"
"github.com/kubescape/node-agent/pkg/processtree"
containerprocesstree "github.com/kubescape/node-agent/pkg/processtree/container"
processtreecreator "github.com/kubescape/node-agent/pkg/processtree/creator"
rulebinding "github.com/kubescape/node-agent/pkg/rulebindingmanager"
rulebindingcachev1 "github.com/kubescape/node-agent/pkg/rulebindingmanager/cache"
"github.com/kubescape/node-agent/pkg/rulemanager"
rulemanagerv1 "github.com/kubescape/node-agent/pkg/rulemanager/v1"
"github.com/kubescape/node-agent/pkg/rulemanager/v1/rulecooldown"
"github.com/kubescape/node-agent/pkg/rulemanager/cel"
"github.com/kubescape/node-agent/pkg/rulemanager/ruleadapters"
"github.com/kubescape/node-agent/pkg/rulemanager/rulecooldown"
"github.com/kubescape/node-agent/pkg/rulemanager/rulecreator"
"github.com/kubescape/node-agent/pkg/rulemanager/ruleswatcher"
"github.com/kubescape/node-agent/pkg/sbommanager"
sbommanagerv1 "github.com/kubescape/node-agent/pkg/sbommanager/v1"
"github.com/kubescape/node-agent/pkg/seccompmanager"
Expand Down Expand Up @@ -167,7 +174,6 @@ func main() {

// Create watchers
dWatcher := dynamicwatcher.NewWatchHandler(k8sClient, storageClient.StorageClient, cfg.SkipNamespace)
// create k8sObject cache
k8sObjectCache, err := k8scache.NewK8sObjectCache(cfg.NodeName, k8sClient)
if err != nil {
logger.L().Ctx(ctx).Fatal("error creating K8sObjectCache", helpers.Error(err))
Expand All @@ -189,7 +195,12 @@ func main() {

var ruleBindingCache *rulebindingcachev1.RBCache
if cfg.EnableRuntimeDetection {
ruleBindingCache = rulebindingcachev1.NewCache(cfg.NodeName, k8sClient)
ruleCreator := rulecreator.NewRuleCreator()
ruleBindingCache = rulebindingcachev1.NewCache(cfg, k8sClient, ruleCreator)
rulesWatcher := ruleswatcher.NewRulesWatcher(k8sClient, ruleCreator, func() {
ruleBindingCache.RefreshRuleBindingsRules()
})
dWatcher.AddAdaptor(rulesWatcher)
}

// Create and DNS managers
Expand Down Expand Up @@ -268,8 +279,15 @@ func main() {

ruleCooldown := rulecooldown.NewRuleCooldown(cfg.RuleCoolDown)

adapterFactory := ruleadapters.NewEventRuleAdapterFactory()

celEvaluator, err := cel.NewCEL(objCache, cfg)
if err != nil {
logger.L().Ctx(ctx).Fatal("error creating CEL evaluator", helpers.Error(err))
}

// create runtimeDetection managers
ruleManager, err = rulemanagerv1.CreateRuleManager(ctx, cfg, k8sClient, ruleBindingCache, objCache, exporter, prometheusExporter, cfg.NodeName, clusterData.ClusterName, processTreeManager, dnsResolver, nil, ruleCooldown)
ruleManager, err = rulemanager.CreateRuleManager(ctx, cfg, k8sClient, ruleBindingCache, objCache, exporter, prometheusExporter, processTreeManager, dnsResolver, nil, ruleCooldown, adapterFactory, celEvaluator)
if err != nil {
logger.L().Ctx(ctx).Fatal("error creating RuleManager", helpers.Error(err))
}
Expand Down Expand Up @@ -320,7 +338,7 @@ func main() {
if err := igconfig.Config.ReadInConfig(); err != nil {
logger.L().Warning("reading IG config", helpers.Error(err))
}
igK8sClient, err := containercollection.NewK8sClient(cfg.NodeName)
igK8sClient, err := containercollection.NewK8sClient(cfg.NodeName, "", "")
if err != nil {
logger.L().Fatal("error creating IG Kubernetes client", helpers.Error(err))
}
Expand All @@ -339,11 +357,16 @@ func main() {
sbomManager = sbommanager.CreateSbomManagerMock()
}

thirdPartyTracers := containerwatcher.ThirdPartyTracers{
ThirdPartyTracersInitializers: mapset.NewSet[containerwatcher.CustomTracerInitializer](),
ThirdPartyEventReceivers: maps.NewSafeMap[utils.EventType, mapset.Set[containerwatcher.GenericEventReceiver]](),
}

// Create the container handler
mainHandler, err := containerwatcherv2.CreateIGContainerWatcher(cfg, containerProfileManager, k8sClient,
igK8sClient, dnsManagerClient, prometheusExporter, ruleManager,
malwareManager, sbomManager, &ruleBindingNotify, igK8sClient.RuntimeConfig, nil, nil,
processTreeManager, clusterData.ClusterName, objCache, networkStreamClient, containerProcessTree)
malwareManager, sbomManager, &ruleBindingNotify, igK8sClient.RuntimeConfig, nil,
processTreeManager, clusterData.ClusterName, objCache, networkStreamClient, containerProcessTree, thirdPartyTracers)
if err != nil {
logger.L().Ctx(ctx).Fatal("error creating the container watcher", helpers.Error(err))
}
Expand Down
Loading
Loading