Skip to content

Commit 5525f70

Browse files
test(ebpf): assert ai agent exec enforcement contract
1 parent 50f9bb2 commit 5525f70

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

agent/src/ebpf/test/test_ai_agent_source_contracts.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
PROBE_C = ROOT / "user" / "probe.c"
1313
TRACER_H = ROOT / "user" / "tracer.h"
1414
TRACER_C = ROOT / "user" / "tracer.c"
15+
WORKSPACE_ROOT = ROOT.parents[3]
16+
ENTERPRISE_AGENT = WORKSPACE_ROOT / "deepflow-core" / "agent"
17+
ENTERPRISE_BPF = ENTERPRISE_AGENT / "src" / "ebpf" / "user" / "extended" / "bpf"
18+
ENTERPRISE_SUPPORT = ENTERPRISE_AGENT / "scripts" / "support_extended_observability"
1519

1620

1721
def require(condition: bool, message: str) -> None:
@@ -160,4 +164,35 @@ def read_source(path: Path) -> str:
160164
"tracer.c must skip unloaded optional LSM programs during attach",
161165
)
162166

167+
if ENTERPRISE_AGENT.exists():
168+
exec_enforce_bpf = ENTERPRISE_BPF / "ai_agent_exec_enforce.bpf.c"
169+
require(
170+
exec_enforce_bpf.exists(),
171+
f"missing enterprise AI Agent exec enforcement BPF: {exec_enforce_bpf}",
172+
)
173+
exec_enforce_text = read_source(exec_enforce_bpf)
174+
support_text = read_source(ENTERPRISE_SUPPORT)
175+
176+
require(
177+
'SEC("lsm/bprm_check_security")' in exec_enforce_text,
178+
"AI Agent exec enforcement must attach to lsm/bprm_check_security",
179+
)
180+
require(
181+
"is_ai_agent_process" in exec_enforce_text
182+
or "ai_agent_pids" in exec_enforce_text,
183+
"AI Agent exec enforcement must scope matching to AI Agent processes",
184+
)
185+
require(
186+
"DATA_SOURCE_PROC_BLOCK_EVENT" in exec_enforce_text,
187+
"AI Agent exec enforcement must emit proc block events",
188+
)
189+
require(
190+
"ai_agent_submit_event" in exec_enforce_text,
191+
"AI Agent exec enforcement must submit events through the AI Agent pipeline",
192+
)
193+
require(
194+
"ai_agent_exec_enforce.bpf.c" in support_text,
195+
"support_extended_observability must include ai_agent_exec_enforce.bpf.c",
196+
)
197+
163198
print("[OK]")

0 commit comments

Comments
 (0)