@@ -270,6 +270,66 @@ - (void)testBasic {
270270 }
271271}
272272
273+ - (void )testAuditReturnValue {
274+ using ReturnValue = santa::cel::CELProtoTraits<true >::ReturnValue;
275+ using ExecutableFileT = santa::cel::CELProtoTraits<true >::ExecutableFileT;
276+ using AncestorT = santa::cel::CELProtoTraits<true >::AncestorT;
277+ using FileDescriptorT = santa::cel::CELProtoTraits<true >::FileDescriptorT;
278+
279+ XCTAssertEqual (santa::cel::CELProtoTraits<true >::AUDIT, ::santa::cel::v2::AUDIT);
280+
281+ auto f = std::make_unique<ExecutableFileT>();
282+ f->set_team_id (" EQHXZ8M8AV" );
283+ santa::cel::Activation<true > activation (
284+ std::move (f),
285+ ^std::vector<std::string>() {
286+ return {" hello" , " world" };
287+ },
288+ ^std::map<std::string, std::string>() {
289+ return {};
290+ },
291+ ^uid_t () {
292+ return 0 ;
293+ },
294+ ^std::string () {
295+ return " /" ;
296+ },
297+ ^std::string () {
298+ return " /usr/bin/test" ;
299+ },
300+ ^std::vector<AncestorT>() {
301+ return {};
302+ },
303+ ^std::vector<FileDescriptorT>() {
304+ return {};
305+ });
306+
307+ auto sut = santa::cel::Evaluator<true >::Create ();
308+ XCTAssertTrue (sut.ok ());
309+
310+ {
311+ // Static - AUDIT returned when team_id matches
312+ auto result = sut.value ()->CompileAndEvaluate (
313+ " target.team_id == 'EQHXZ8M8AV' ? AUDIT : ALLOWLIST" , activation);
314+ if (!result.ok ()) {
315+ XCTFail (" Failed to evaluate: %s" , result.status ().message ().data ());
316+ } else {
317+ XCTAssertEqual (result.value ().value , ReturnValue::AUDIT);
318+ XCTAssertEqual (result.value ().cacheable , true );
319+ }
320+ }
321+ {
322+ // Dynamic - AUDIT returned when args non-empty
323+ auto result = sut.value ()->CompileAndEvaluate (" size(args) > 0 ? AUDIT : ALLOWLIST" , activation);
324+ if (!result.ok ()) {
325+ XCTFail (" Failed to evaluate: %s" , result.status ().message ().data ());
326+ } else {
327+ XCTAssertEqual (result.value ().value , ReturnValue::AUDIT);
328+ XCTAssertEqual (result.value ().cacheable , false );
329+ }
330+ }
331+ }
332+
273333- (void )testV2Only {
274334 auto argsFn = ^std::vector<std::string>() {
275335 return {" hello" , " world" };
0 commit comments