def test_procfs_other_process(bpf_program: BPFProgram, caplog, setup_testdir): sleep_path = which('sleep') Commands.add_profile(OPEN_PATH, False) Commands.add_fs_rule(OPEN_PATH, '/tmp/bpfbox/a', FS_ACCESS.READ, BPFBOX_ACTION.TAINT) Commands.add_fs_rule(OPEN_PATH, '/proc', FS_ACCESS.EXEC) Commands.add_procfs_rule(OPEN_PATH, sleep_path, FS_ACCESS.READ | FS_ACCESS.EXEC) subprocess.check_call([OPEN_PATH, 'proc-self']) sleep_pid = subprocess.Popen([sleep_path, '10']).pid subprocess.check_call([OPEN_PATH, 'proc-other', str(sleep_pid)])
def __call__(self, profile: str) -> int: return Commands.add_procfs_rule(profile, self.other_exe, self.access, self.action)