|
12 | 12 | PROBE_C = ROOT / "user" / "probe.c" |
13 | 13 | TRACER_H = ROOT / "user" / "tracer.h" |
14 | 14 | 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" |
15 | 19 |
|
16 | 20 |
|
17 | 21 | def require(condition: bool, message: str) -> None: |
@@ -160,4 +164,35 @@ def read_source(path: Path) -> str: |
160 | 164 | "tracer.c must skip unloaded optional LSM programs during attach", |
161 | 165 | ) |
162 | 166 |
|
| 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 | + |
163 | 198 | print("[OK]") |
0 commit comments