omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / aienux / argus / test.om
| 1 | note SPDX-License-Identifier: Apache-2.0 |
| 2 | note aienux/argus/test.om: Comprehensive Pure-Omega test suite for ARGUS Event ABI, |
| 3 | note Class-Gated Admission Ring, Shadow-State Detectors, and Containment Invariants (I1..I5). |
| 4 | note Compose with: si/directives/om2.om aienux/argus/event.om aienux/argus/ring.om aienux/argus/contain.om aienux/argus/test.om om/tls/sha2.om |
| 5 | |
| 6 | text s_pass "PASS " |
| 7 | text s_fail "FAIL " |
| 8 | text s_nl "\n" |
| 9 | text s_t01 "event_wire_roundtrip_and_sha256_chain" |
| 10 | text s_t02 "event_validate_class_floor_and_version" |
| 11 | text s_t03 "event_validate_consumer_flag_and_external_effect" |
| 12 | text s_t04 "event_validate_containment_v12_and_i2" |
| 13 | text s_t05 "creq_152_byte_wire_roundtrip_and_negatives" |
| 14 | text s_t06 "ring_watermarks_and_conservation" |
| 15 | text s_t07 "ring_malformed_push_and_drop_synthesis" |
| 16 | text s_t08 "core_forged_revoked_stale_subject_detectors" |
| 17 | text s_t09 "core_sequence_anomaly_and_authority_replay" |
| 18 | text s_t10 "core_world_provenance_and_telemetry_loss" |
| 19 | text s_t11 "contain_full_lifecycle_confirmed" |
| 20 | text s_t12 "contain_i2_synthetic_and_i3b_rate_limit" |
| 21 | text s_t13 "contain_i5d_unauthorized_execution" |
| 22 | text s_t14 "contain_i1b_scope_exceeded" |
| 23 | text s_t15 "contain_unmatched_echo_and_unconfirmed" |
| 24 | text s_t16 "contain_escalate_then_deny_lifecycle" |
| 25 | text s_sum "ARGUS_TEST_PASS total=16 failed=0\n" |
| 26 | text s_fsum "ARGUS_TEST_FAIL\n" |
| 27 | |
| 28 | fn argus_write_all fd int buf view uchar * to bool |
| 29 | total = len buf |
| 30 | off = ulong 0 |
| 31 | note Each write advances off by at least 1 byte on progress; 4096 covers test output lines. |
| 32 | while lt off total bound 4096 |
| 33 | n = write fd buf off sub total off |
| 34 | if le n 0 |
| 35 | ret false |
| 36 | end |
| 37 | off = add off ulong n |
| 38 | end |
| 39 | ret true |
| 40 | end |
| 41 | |
| 42 | fn report name view uchar * ok bool to uint |
| 43 | if ok |
| 44 | w1 = argus_write_all 1 s_pass |
| 45 | w2 = argus_write_all 1 name |
| 46 | w3 = argus_write_all 1 s_nl |
| 47 | if and w1 and w2 w3 |
| 48 | ret 0 |
| 49 | end |
| 50 | ret 1 |
| 51 | end |
| 52 | w1 = argus_write_all 1 s_fail |
| 53 | w2 = argus_write_all 1 name |
| 54 | w3 = argus_write_all 1 s_nl |
| 55 | if and w1 and w2 w3 |
| 56 | ret 1 |
| 57 | end |
| 58 | ret 1 |
| 59 | end |
| 60 | |
| 61 | fn mk_ev dst edit ArgusEvent cls uchar k ushort oc uchar seq ulong to void |
| 62 | put dst version ARGUS_ABI_VERSION |
| 63 | put dst class_ cls |
| 64 | put dst kind k |
| 65 | put dst effect_class ARGUS_EFFECT_NONE |
| 66 | put dst outcome oc |
| 67 | put dst flags 0 |
| 68 | put dst sequence seq |
| 69 | put dst tick 10 |
| 70 | put dst principal 7 |
| 71 | put dst code 0 |
| 72 | put dst cap_id 1 |
| 73 | put dst object_id 0 |
| 74 | put dst cap_generation 100 |
| 75 | put dst world_generation 0 |
| 76 | put dst resource 42 |
| 77 | end |
| 78 | |
| 79 | fn test_01_chain_part ev view ArgusEvent mach view uchar 32 edig view uchar 32 to bool |
| 80 | d1 = new uchar 32 0 |
| 81 | d2 = new uchar 32 0 |
| 82 | argus_event_digest ev mach edig d1 |
| 83 | ev2 = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 84 | mk_ev ev2 ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK 1 |
| 85 | put ev2 code -5 |
| 86 | argus_event_digest ev2 mach edig d2 |
| 87 | if not argus_eq32 d1 d2 |
| 88 | ret false |
| 89 | end |
| 90 | note 1-bit flip in event changes digest |
| 91 | put ev2 resource 43 |
| 92 | argus_event_digest ev2 mach edig d2 |
| 93 | if argus_eq32 d1 d2 |
| 94 | ret false |
| 95 | end |
| 96 | note Chain extend is deterministic and non-zero |
| 97 | c1 = new uchar 32 0 |
| 98 | c2 = new uchar 32 0 |
| 99 | argus_chain_extend c1 ev mach edig |
| 100 | argus_chain_extend c2 ev mach edig |
| 101 | if not argus_eq32 c1 c2 |
| 102 | ret false |
| 103 | end |
| 104 | zero = new uchar 32 0 |
| 105 | if argus_eq32 c1 zero |
| 106 | ret false |
| 107 | end |
| 108 | ret true |
| 109 | end |
| 110 | |
| 111 | fn test_01_wire_and_chain to bool |
| 112 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 113 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK 1 |
| 114 | put ev code -5 |
| 115 | mach = new uchar 32 0x11 |
| 116 | edig = new uchar 32 0x22 |
| 117 | wire = new uchar 128 0 |
| 118 | if ne argus_event_encode ev mach edig wire ARGUS_OK |
| 119 | ret false |
| 120 | end |
| 121 | ev2 = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 122 | mach2 = new uchar 32 0 |
| 123 | edig2 = new uchar 32 0 |
| 124 | if ne argus_event_decode wire ev2 mach2 edig2 ARGUS_OK |
| 125 | ret false |
| 126 | end |
| 127 | if ne get ev2 kind ARGUS_EV_CAPABILITY_GRANTED |
| 128 | ret false |
| 129 | end |
| 130 | if ne get ev2 code -5 |
| 131 | ret false |
| 132 | end |
| 133 | if ne get ev2 cap_generation 100 |
| 134 | ret false |
| 135 | end |
| 136 | if not argus_eq32 mach mach2 |
| 137 | ret false |
| 138 | end |
| 139 | if not argus_eq32 edig edig2 |
| 140 | ret false |
| 141 | end |
| 142 | ret test_01_chain_part ev mach edig |
| 143 | end |
| 144 | |
| 145 | fn test_02_class_floor_and_version to bool |
| 146 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 147 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK 1 |
| 148 | if ne argus_event_validate ev ARGUS_OK |
| 149 | ret false |
| 150 | end |
| 151 | note Stronger class (CRITICAL for SECURITY kind) accepted |
| 152 | put ev class_ ARGUS_CLASS_CRITICAL |
| 153 | if ne argus_event_validate ev ARGUS_OK |
| 154 | ret false |
| 155 | end |
| 156 | note Weaker class (AUDIT for SECURITY kind) refused |
| 157 | put ev class_ ARGUS_CLASS_AUDIT |
| 158 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 159 | ret false |
| 160 | end |
| 161 | note Wrong version -> ARGUS_ERR_VERSION |
| 162 | put ev class_ ARGUS_CLASS_SECURITY |
| 163 | put ev version 2 |
| 164 | if ne argus_event_validate ev ARGUS_ERR_VERSION |
| 165 | ret false |
| 166 | end |
| 167 | note Sequence 0 and U64_MAX refused |
| 168 | put ev version ARGUS_ABI_VERSION |
| 169 | put ev sequence 0 |
| 170 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 171 | ret false |
| 172 | end |
| 173 | put ev sequence ARGUS_U64_MAX |
| 174 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 175 | ret false |
| 176 | end |
| 177 | note Unknown kind refused |
| 178 | put ev sequence 1 |
| 179 | put ev kind 999 |
| 180 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 181 | ret false |
| 182 | end |
| 183 | ret true |
| 184 | end |
| 185 | |
| 186 | fn test_03_consumer_and_external to bool |
| 187 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 188 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK 1 |
| 189 | note CONSUMER flag on non-consumer kind refused |
| 190 | put ev flags ARGUS_FLAG_CONSUMER |
| 191 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 192 | ret false |
| 193 | end |
| 194 | note TELEMETRY_DROPPED requires CONSUMER flag |
| 195 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_TELEMETRY_DROPPED ARGUS_OUTCOME_ERROR 2 |
| 196 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 197 | ret false |
| 198 | end |
| 199 | put ev flags ARGUS_FLAG_CONSUMER |
| 200 | if ne argus_event_validate ev ARGUS_OK |
| 201 | ret false |
| 202 | end |
| 203 | note EXTERNAL_EFFECT_COMMITTED requires effect_class EXTERNAL |
| 204 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_EXTERNAL_EFFECT_COMMITTED ARGUS_OUTCOME_OK 3 |
| 205 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 206 | ret false |
| 207 | end |
| 208 | put ev effect_class ARGUS_EFFECT_EXTERNAL |
| 209 | if ne argus_event_validate ev ARGUS_OK |
| 210 | ret false |
| 211 | end |
| 212 | note CAPABILITY_USE_SUMMARY requires outcome OK and world_gen (MIN) <= cap_gen (MAX) |
| 213 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USE_SUMMARY ARGUS_OUTCOME_OK 4 |
| 214 | put ev world_generation 101 |
| 215 | put ev cap_generation 100 |
| 216 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 217 | ret false |
| 218 | end |
| 219 | put ev world_generation 90 |
| 220 | if ne argus_event_validate ev ARGUS_OK |
| 221 | ret false |
| 222 | end |
| 223 | put ev outcome ARGUS_OUTCOME_DENIED |
| 224 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 225 | ret false |
| 226 | end |
| 227 | ret true |
| 228 | end |
| 229 | |
| 230 | fn test_04_containment_v12_and_i2 to bool |
| 231 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 232 | note 90 PROPOSED requires CONSUMER flag, request_id != 0, status PROPOSED, outcome OK |
| 233 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_PROPOSED ARGUS_OUTCOME_OK 1 |
| 234 | put ev flags ARGUS_FLAG_CONSUMER |
| 235 | put ev world_generation 1 |
| 236 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_PROPOSED ARGUS_F_REVOKED_CAPABILITY_USED |
| 237 | if ne argus_event_validate ev ARGUS_OK |
| 238 | ret false |
| 239 | end |
| 240 | note request_id == 0 refused |
| 241 | put ev world_generation 0 |
| 242 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 243 | ret false |
| 244 | end |
| 245 | note 92 EXECUTED DONE on REVOKE_CAPABILITY without SYNTHETIC is OK (live executor) |
| 246 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_EXECUTED ARGUS_OUTCOME_OK 2 |
| 247 | put ev world_generation 1 |
| 248 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_DONE ARGUS_F_REVOKED_CAPABILITY_USED |
| 249 | if ne argus_event_validate ev ARGUS_OK |
| 250 | ret false |
| 251 | end |
| 252 | note I2: 92 EXECUTED DONE on FREEZE_PRINCIPAL without SYNTHETIC is REFUSED |
| 253 | put ev object_id argus_contain_pack ARGUS_CONTAIN_FREEZE_PRINCIPAL ARGUS_CSTATUS_DONE ARGUS_F_REVOKED_CAPABILITY_USED |
| 254 | if ne argus_event_validate ev ARGUS_ERR_MALFORMED |
| 255 | ret false |
| 256 | end |
| 257 | note With SYNTHETIC flag it is accepted |
| 258 | put ev flags ARGUS_FLAG_SYNTHETIC |
| 259 | if ne argus_event_validate ev ARGUS_OK |
| 260 | ret false |
| 261 | end |
| 262 | ret true |
| 263 | end |
| 264 | |
| 265 | fn test_05_creq_wire_roundtrip to bool |
| 266 | req = new ArgusContainReq 10 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_CRITICAL ARGUS_F_REVOKED_CAPABILITY_USED 7 3 55 1 9 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 |
| 267 | mach = new uchar 32 0x33 |
| 268 | fdig = new uchar 32 0x44 |
| 269 | tdig = new uchar 32 0x55 |
| 270 | wire = new uchar 152 0 |
| 271 | if ne argus_creq_encode req mach fdig tdig wire ARGUS_OK |
| 272 | ret false |
| 273 | end |
| 274 | req2 = new ArgusContainReq 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 275 | m2 = new uchar 32 0 |
| 276 | f2 = new uchar 32 0 |
| 277 | t2 = new uchar 32 0 |
| 278 | if ne argus_creq_decode wire req2 m2 f2 t2 ARGUS_OK |
| 279 | ret false |
| 280 | end |
| 281 | if ne get req2 request_id 1 |
| 282 | ret false |
| 283 | end |
| 284 | if ne get req2 target_cap_gen 55 |
| 285 | ret false |
| 286 | end |
| 287 | if ne get req2 finding_sequence 9 |
| 288 | ret false |
| 289 | end |
| 290 | note Negative controls: bad version, nonzero reserved, unknown flags, zero request_id |
| 291 | put wire 150 9 |
| 292 | if ne argus_creq_decode wire req2 m2 f2 t2 ARGUS_ERR_VERSION |
| 293 | ret false |
| 294 | end |
| 295 | put wire 150 ARGUS_CONTAIN_REQ_VERSION |
| 296 | put wire 151 1 |
| 297 | if ne argus_creq_decode wire req2 m2 f2 t2 ARGUS_ERR_MALFORMED |
| 298 | ret false |
| 299 | end |
| 300 | put wire 151 0 |
| 301 | put wire 148 0x04 |
| 302 | if ne argus_creq_decode wire req2 m2 f2 t2 ARGUS_ERR_MALFORMED |
| 303 | ret false |
| 304 | end |
| 305 | ret true |
| 306 | end |
| 307 | |
| 308 | fn test_06_ring_watermarks_conservation to bool |
| 309 | note Capacity 16: INFO=8, AUDIT=12, SECURITY=15, CRITICAL=16 |
| 310 | if ne argus_ring_init 16 ARGUS_OK |
| 311 | ret false |
| 312 | end |
| 313 | if ne argus_ring_saturation_point 16 ARGUS_CLASS_INFORMATIONAL 8 |
| 314 | ret false |
| 315 | end |
| 316 | if ne argus_ring_saturation_point 16 ARGUS_CLASS_AUDIT 12 |
| 317 | ret false |
| 318 | end |
| 319 | if ne argus_ring_saturation_point 16 ARGUS_CLASS_SECURITY 15 |
| 320 | ret false |
| 321 | end |
| 322 | if ne argus_ring_saturation_point 16 ARGUS_CLASS_CRITICAL 16 |
| 323 | ret false |
| 324 | end |
| 325 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 326 | mach = new uchar 32 0 |
| 327 | edig = new uchar 32 0 |
| 328 | note Push 12 AUDIT events -> all 12 succeed, 13th is refused FULL |
| 329 | i = ulong 1 |
| 330 | while le i 12 bound 16 |
| 331 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USED ARGUS_OUTCOME_OK i |
| 332 | if ne argus_ring_push ev mach edig ARGUS_OK |
| 333 | ret false |
| 334 | end |
| 335 | i = add i 1 |
| 336 | end |
| 337 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USED ARGUS_OUTCOME_OK 13 |
| 338 | if ne argus_ring_push ev mach edig ARGUS_ERR_FULL |
| 339 | ret false |
| 340 | end |
| 341 | note Push 3 SECURITY events (depth 12->15) succeed, 4th refused FULL |
| 342 | i = ulong 14 |
| 343 | while le i 16 bound 8 |
| 344 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK i |
| 345 | if ne argus_ring_push ev mach edig ARGUS_OK |
| 346 | ret false |
| 347 | end |
| 348 | i = add i 1 |
| 349 | end |
| 350 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK 17 |
| 351 | if ne argus_ring_push ev mach edig ARGUS_ERR_FULL |
| 352 | ret false |
| 353 | end |
| 354 | note Push 1 CRITICAL event (depth 15->16) succeeds, 2nd triggers critical_overflow |
| 355 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CAPABILITY_REVOKED ARGUS_OUTCOME_OK 18 |
| 356 | if ne argus_ring_push ev mach edig ARGUS_OK |
| 357 | ret false |
| 358 | end |
| 359 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CAPABILITY_REVOKED ARGUS_OUTCOME_OK 19 |
| 360 | if ne argus_ring_push ev mach edig ARGUS_ERR_FULL |
| 361 | ret false |
| 362 | end |
| 363 | note Check conservation: 19 attempts = 16 pushed + 0 mal + 0 crit_ref + 1 sec_ref + 1 audit_ref + 0 info_ref + 1 crit_overflow |
| 364 | st = new ArgusRingStats 0 0 0 0 0 0 0 0 0 0 |
| 365 | argus_ring_stats st |
| 366 | if ne get st pushed 16 |
| 367 | ret false |
| 368 | end |
| 369 | if ne get st critical_overflow 1 |
| 370 | ret false |
| 371 | end |
| 372 | if ne get st ref_sec 1 |
| 373 | ret false |
| 374 | end |
| 375 | if ne get st ref_audit 1 |
| 376 | ret false |
| 377 | end |
| 378 | note Pop FIFO check |
| 379 | pop_ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 380 | if ne argus_ring_pop pop_ev mach edig ARGUS_OK |
| 381 | ret false |
| 382 | end |
| 383 | if ne get pop_ev sequence 1 |
| 384 | ret false |
| 385 | end |
| 386 | ret true |
| 387 | end |
| 388 | |
| 389 | fn test_07_ring_malformed_and_drops to bool |
| 390 | if ne argus_ring_init 4 ARGUS_OK |
| 391 | ret false |
| 392 | end |
| 393 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 394 | mach = new uchar 32 0 |
| 395 | edig = new uchar 32 0 |
| 396 | note Malformed: kind 90 CONTAINMENT_PROPOSED refused by ring |
| 397 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_PROPOSED ARGUS_OUTCOME_OK 1 |
| 398 | if ne argus_ring_push ev mach edig ARGUS_ERR_MALFORMED |
| 399 | ret false |
| 400 | end |
| 401 | note Malformed: weakened class (AUDIT on CRITICAL kind) refused |
| 402 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_REVOKED ARGUS_OUTCOME_OK 2 |
| 403 | if ne argus_ring_push ev mach edig ARGUS_ERR_MALFORMED |
| 404 | ret false |
| 405 | end |
| 406 | st = new ArgusRingStats 0 0 0 0 0 0 0 0 0 0 |
| 407 | argus_ring_stats st |
| 408 | if ne get st ref_malformed 2 |
| 409 | ret false |
| 410 | end |
| 411 | note Fill ring to 4 and trigger drops on AUDIT and CRITICAL |
| 412 | i = ulong 1 |
| 413 | while le i 4 bound 8 |
| 414 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CAPABILITY_REVOKED ARGUS_OUTCOME_OK i |
| 415 | if ne argus_ring_push ev mach edig ARGUS_OK |
| 416 | ret false |
| 417 | end |
| 418 | i = add i 1 |
| 419 | end |
| 420 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USED ARGUS_OUTCOME_OK 5 |
| 421 | rc_a = argus_ring_push ev mach edig |
| 422 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CAPABILITY_REVOKED ARGUS_OUTCOME_OK 6 |
| 423 | rc_c = argus_ring_push ev mach edig |
| 424 | if or ne rc_a ARGUS_ERR_FULL ne rc_c ARGUS_ERR_FULL |
| 425 | ret false |
| 426 | end |
| 427 | note Drain drops: CRITICAL MUST come before AUDIT |
| 428 | nseq = new ulong 1 1 |
| 429 | drop1 = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 430 | drop2 = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 431 | if ne argus_ring_drain_one drop1 nseq ARGUS_OK |
| 432 | ret false |
| 433 | end |
| 434 | if ne argus_ring_drain_one drop2 nseq ARGUS_OK |
| 435 | ret false |
| 436 | end |
| 437 | if ne get drop1 object_id uint ARGUS_CLASS_CRITICAL |
| 438 | ret false |
| 439 | end |
| 440 | if ne get drop2 object_id uint ARGUS_CLASS_AUDIT |
| 441 | ret false |
| 442 | end |
| 443 | note Synthesized drop events must pass argus_event_validate! |
| 444 | if ne argus_event_validate drop1 ARGUS_OK |
| 445 | ret false |
| 446 | end |
| 447 | if ne argus_event_validate drop2 ARGUS_OK |
| 448 | ret false |
| 449 | end |
| 450 | note No more drops pending |
| 451 | if ne argus_ring_drain_one drop1 nseq ARGUS_ERR_STATE |
| 452 | ret false |
| 453 | end |
| 454 | ret true |
| 455 | end |
| 456 | |
| 457 | fn test_08_core_cap_detectors to bool |
| 458 | argus_core_init |
| 459 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 460 | f = new ArgusFinding 0 0 0 0 0 0 0 0 0 0 0 |
| 461 | mach = new uchar 32 0 |
| 462 | edig = new uchar 32 0 |
| 463 | note 1. Use of unseen slot -> FORGED_CAPABILITY |
| 464 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USED ARGUS_OUTCOME_OK 1 |
| 465 | put ev cap_id 5 |
| 466 | put ev cap_generation 10 |
| 467 | if ne argus_core_ingest ev mach edig f ARGUS_F_FORGED_CAPABILITY |
| 468 | ret false |
| 469 | end |
| 470 | note 2. Grant slot 5 gen 10 subject 7 -> clean |
| 471 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK 2 |
| 472 | put ev cap_id 5 |
| 473 | put ev cap_generation 10 |
| 474 | put ev principal 7 |
| 475 | if ne argus_core_ingest ev mach edig f ARGUS_F_NONE |
| 476 | ret false |
| 477 | end |
| 478 | note 3. Valid use -> clean |
| 479 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USED ARGUS_OUTCOME_OK 3 |
| 480 | put ev cap_id 5 |
| 481 | put ev cap_generation 10 |
| 482 | put ev principal 7 |
| 483 | if ne argus_core_ingest ev mach edig f ARGUS_F_NONE |
| 484 | ret false |
| 485 | end |
| 486 | note 4. Stale generation use -> STALE_GENERATION |
| 487 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USED ARGUS_OUTCOME_OK 4 |
| 488 | put ev cap_id 5 |
| 489 | put ev cap_generation 9 |
| 490 | put ev principal 7 |
| 491 | if ne argus_core_ingest ev mach edig f ARGUS_F_STALE_GENERATION |
| 492 | ret false |
| 493 | end |
| 494 | note 5. Subject mismatch -> SUBJECT_MISMATCH |
| 495 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USED ARGUS_OUTCOME_OK 5 |
| 496 | put ev cap_id 5 |
| 497 | put ev cap_generation 10 |
| 498 | put ev principal 99 |
| 499 | if ne argus_core_ingest ev mach edig f ARGUS_F_SUBJECT_MISMATCH |
| 500 | ret false |
| 501 | end |
| 502 | note 6. Revoke slot 5 -> clean, then use -> REVOKED_CAPABILITY_USED |
| 503 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CAPABILITY_REVOKED ARGUS_OUTCOME_OK 6 |
| 504 | put ev cap_id 5 |
| 505 | put ev cap_generation 10 |
| 506 | if ne argus_core_ingest ev mach edig f ARGUS_F_NONE |
| 507 | ret false |
| 508 | end |
| 509 | mk_ev ev ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USED ARGUS_OUTCOME_OK 7 |
| 510 | put ev cap_id 5 |
| 511 | put ev cap_generation 10 |
| 512 | put ev principal 7 |
| 513 | if ne argus_core_ingest ev mach edig f ARGUS_F_REVOKED_CAPABILITY_USED |
| 514 | ret false |
| 515 | end |
| 516 | ret true |
| 517 | end |
| 518 | |
| 519 | fn test_09_sequence_and_replay to bool |
| 520 | argus_core_init |
| 521 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 522 | f = new ArgusFinding 0 0 0 0 0 0 0 0 0 0 0 |
| 523 | mach = new uchar 32 0 |
| 524 | edig = new uchar 32 0 |
| 525 | note Revoke unseen slot -> AUTHORITY_REPLAY and NOT applied |
| 526 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CAPABILITY_REVOKED ARGUS_OUTCOME_OK 1 |
| 527 | put ev cap_id 2 |
| 528 | put ev cap_generation 5 |
| 529 | if ne argus_core_ingest ev mach edig f ARGUS_F_AUTHORITY_REPLAY |
| 530 | ret false |
| 531 | end |
| 532 | note Grant slot 2 gen 5 -> clean |
| 533 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK 2 |
| 534 | put ev cap_id 2 |
| 535 | put ev cap_generation 5 |
| 536 | if ne argus_core_ingest ev mach edig f ARGUS_F_NONE |
| 537 | ret false |
| 538 | end |
| 539 | note Re-grant same gen 5 -> AUTHORITY_REPLAY |
| 540 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK 3 |
| 541 | put ev cap_id 2 |
| 542 | put ev cap_generation 5 |
| 543 | if ne argus_core_ingest ev mach edig f ARGUS_F_AUTHORITY_REPLAY |
| 544 | ret false |
| 545 | end |
| 546 | note Replayed sequence 3 -> SEQUENCE_ANOMALY |
| 547 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_CAPABILITY_GRANTED ARGUS_OUTCOME_OK 3 |
| 548 | put ev cap_id 2 |
| 549 | put ev cap_generation 6 |
| 550 | if ne argus_core_ingest ev mach edig f ARGUS_F_SEQUENCE_ANOMALY |
| 551 | ret false |
| 552 | end |
| 553 | if ne argus_core_not_applied 3 |
| 554 | ret false |
| 555 | end |
| 556 | ret true |
| 557 | end |
| 558 | |
| 559 | fn test_10_world_and_telemetry_loss to bool |
| 560 | argus_core_init |
| 561 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 562 | f = new ArgusFinding 0 0 0 0 0 0 0 0 0 0 0 |
| 563 | mach = new uchar 32 0 |
| 564 | edig = new uchar 32 0 |
| 565 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_WORLD_COMMITTED ARGUS_OUTCOME_OK 1 |
| 566 | put ev object_id 1 |
| 567 | put ev world_generation 1 |
| 568 | if ne argus_core_ingest ev mach edig f ARGUS_F_NONE |
| 569 | ret false |
| 570 | end |
| 571 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_WORLD_COMMITTED ARGUS_OUTCOME_OK 2 |
| 572 | put ev object_id 1 |
| 573 | put ev world_generation 2 |
| 574 | if ne argus_core_ingest ev mach edig f ARGUS_F_NONE |
| 575 | ret false |
| 576 | end |
| 577 | note Skipped generation 2 -> 4 raises WORLD_PROVENANCE_INCONSISTENT |
| 578 | mk_ev ev ARGUS_CLASS_SECURITY ARGUS_EV_WORLD_COMMITTED ARGUS_OUTCOME_OK 3 |
| 579 | put ev object_id 1 |
| 580 | put ev world_generation 4 |
| 581 | if ne argus_core_ingest ev mach edig f ARGUS_F_WORLD_PROVENANCE_INCONSISTENT |
| 582 | ret false |
| 583 | end |
| 584 | note TELEMETRY_DROPPED for CRITICAL raises TELEMETRY_LOSS |
| 585 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_TELEMETRY_DROPPED ARGUS_OUTCOME_ERROR 1 |
| 586 | put ev flags ARGUS_FLAG_CONSUMER |
| 587 | put ev object_id uint ARGUS_CLASS_CRITICAL |
| 588 | put ev resource 3 |
| 589 | if ne argus_core_ingest ev mach edig f ARGUS_F_TELEMETRY_LOSS |
| 590 | ret false |
| 591 | end |
| 592 | ret true |
| 593 | end |
| 594 | |
| 595 | fn test_11_contain_confirmed to bool |
| 596 | argus_contain_init |
| 597 | req = new ArgusContainReq 1 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_CRITICAL ARGUS_F_REVOKED_CAPABILITY_USED 7 5 10 0 7 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 |
| 598 | mach = new uchar 32 0 |
| 599 | fdig = new uchar 32 0xaa |
| 600 | tdig = new uchar 32 0 |
| 601 | rdig = new uchar 32 0 |
| 602 | if ne argus_contain_propose req mach fdig tdig rdig ARGUS_OK |
| 603 | ret false |
| 604 | end |
| 605 | rid = get req request_id |
| 606 | note 1. DECIDED GRANT |
| 607 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 608 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_DECIDED ARGUS_OUTCOME_OK 10 |
| 609 | put ev principal 7 |
| 610 | put ev cap_id 5 |
| 611 | put ev cap_generation 10 |
| 612 | put ev world_generation rid |
| 613 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_GRANT ARGUS_F_REVOKED_CAPABILITY_USED |
| 614 | if ne argus_contain_observe ev rdig ARGUS_F_NONE |
| 615 | ret false |
| 616 | end |
| 617 | note 2. Matching kind 4 CAPABILITY_REVOKED on (5, 10) |
| 618 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CAPABILITY_REVOKED ARGUS_OUTCOME_OK 11 |
| 619 | put ev cap_id 5 |
| 620 | put ev cap_generation 10 |
| 621 | if ne argus_contain_observe ev rdig ARGUS_F_NONE |
| 622 | ret false |
| 623 | end |
| 624 | note 3. EXECUTED DONE with resource = 1 -> CONFIRMED |
| 625 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_EXECUTED ARGUS_OUTCOME_OK 12 |
| 626 | put ev principal 7 |
| 627 | put ev cap_id 5 |
| 628 | put ev cap_generation 10 |
| 629 | put ev world_generation rid |
| 630 | put ev resource 1 |
| 631 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_DONE ARGUS_F_REVOKED_CAPABILITY_USED |
| 632 | if ne argus_contain_observe ev rdig ARGUS_F_NONE |
| 633 | ret false |
| 634 | end |
| 635 | h = new ArgusContainHealth 0 0 0 0 0 0 0 0 0 0 |
| 636 | argus_contain_health h |
| 637 | if ne get h proposed 1 |
| 638 | ret false |
| 639 | end |
| 640 | if ne get h granted 1 |
| 641 | ret false |
| 642 | end |
| 643 | if ne get h confirmed 1 |
| 644 | ret false |
| 645 | end |
| 646 | ret true |
| 647 | end |
| 648 | |
| 649 | fn test_12_contain_i2_and_rate_limit to bool |
| 650 | argus_contain_init |
| 651 | mach = new uchar 32 0 |
| 652 | fdig = new uchar 32 0 |
| 653 | tdig = new uchar 32 0 |
| 654 | rdig = new uchar 32 0 |
| 655 | note I2: non-live FREEZE_PRINCIPAL without SYNTHETIC refused |
| 656 | req = new ArgusContainReq 1 ARGUS_CONTAIN_FREEZE_PRINCIPAL ARGUS_SEV_HIGH ARGUS_F_SUBJECT_MISMATCH 7 5 10 0 1 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 |
| 657 | if ne argus_contain_propose req mach fdig tdig rdig ARGUS_ERR_MALFORMED |
| 658 | ret false |
| 659 | end |
| 660 | note I3.b: 16 live proposals succeed, 17th in same window returns ARGUS_ERR_FULL |
| 661 | put req containment ARGUS_CONTAIN_REVOKE_CAPABILITY |
| 662 | i = uint 0 |
| 663 | while lt i ARGUS_CONTAIN_WINDOW_MAX bound 32 |
| 664 | put req target_cap_id add 1 i |
| 665 | if ne argus_contain_propose req mach fdig tdig rdig ARGUS_OK |
| 666 | ret false |
| 667 | end |
| 668 | i = add i 1 |
| 669 | end |
| 670 | put req target_cap_id 50 |
| 671 | if ne argus_contain_propose req mach fdig tdig rdig ARGUS_ERR_FULL |
| 672 | ret false |
| 673 | end |
| 674 | h = new ArgusContainHealth 0 0 0 0 0 0 0 0 0 0 |
| 675 | argus_contain_health h |
| 676 | if ne get h rate_limited 1 |
| 677 | ret false |
| 678 | end |
| 679 | ret true |
| 680 | end |
| 681 | |
| 682 | fn test_13_contain_i5d_unauth_exec to bool |
| 683 | argus_contain_init |
| 684 | req = new ArgusContainReq 1 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_CRITICAL ARGUS_F_FORGED_CAPABILITY 7 6 20 0 1 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 |
| 685 | mach = new uchar 32 0 |
| 686 | fdig = new uchar 32 0 |
| 687 | tdig = new uchar 32 0 |
| 688 | rdig = new uchar 32 0 |
| 689 | if ne argus_contain_propose req mach fdig tdig rdig ARGUS_OK |
| 690 | ret false |
| 691 | end |
| 692 | rid = get req request_id |
| 693 | note EXECUTED DONE before GRANT -> EXECUTION_UNAUTHORIZED |
| 694 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 695 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_EXECUTED ARGUS_OUTCOME_OK 2 |
| 696 | put ev principal 7 |
| 697 | put ev cap_id 6 |
| 698 | put ev cap_generation 20 |
| 699 | put ev world_generation rid |
| 700 | put ev resource 1 |
| 701 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_DONE ARGUS_F_FORGED_CAPABILITY |
| 702 | if ne argus_contain_observe ev rdig ARGUS_F_CONTAINMENT_EXECUTION_UNAUTHORIZED |
| 703 | ret false |
| 704 | end |
| 705 | note kind 4 revoke on target while still PROPOSED -> EXECUTION_UNAUTHORIZED |
| 706 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CAPABILITY_REVOKED ARGUS_OUTCOME_OK 3 |
| 707 | put ev cap_id 6 |
| 708 | put ev cap_generation 20 |
| 709 | if ne argus_contain_observe ev rdig ARGUS_F_CONTAINMENT_EXECUTION_UNAUTHORIZED |
| 710 | ret false |
| 711 | end |
| 712 | ret true |
| 713 | end |
| 714 | |
| 715 | fn test_14_contain_i1b_scope_exceeded to bool |
| 716 | argus_contain_init |
| 717 | req = new ArgusContainReq 1 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_CRITICAL ARGUS_F_FORGED_CAPABILITY 7 8 30 0 1 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 |
| 718 | mach = new uchar 32 0 |
| 719 | fdig = new uchar 32 0 |
| 720 | tdig = new uchar 32 0 |
| 721 | rdig = new uchar 32 0 |
| 722 | if ne argus_contain_propose req mach fdig tdig rdig ARGUS_OK |
| 723 | ret false |
| 724 | end |
| 725 | rid = get req request_id |
| 726 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 727 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_DECIDED ARGUS_OUTCOME_OK 2 |
| 728 | put ev principal 7 |
| 729 | put ev cap_id 8 |
| 730 | put ev cap_generation 30 |
| 731 | put ev world_generation rid |
| 732 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_GRANT ARGUS_F_FORGED_CAPABILITY |
| 733 | if ne argus_contain_observe ev rdig ARGUS_F_NONE |
| 734 | ret false |
| 735 | end |
| 736 | note EXECUTED DONE reporting 2 slots revoked -> SCOPE_EXCEEDED |
| 737 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_EXECUTED ARGUS_OUTCOME_OK 3 |
| 738 | put ev principal 7 |
| 739 | put ev cap_id 8 |
| 740 | put ev cap_generation 30 |
| 741 | put ev world_generation rid |
| 742 | put ev resource 2 |
| 743 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_DONE ARGUS_F_FORGED_CAPABILITY |
| 744 | if ne argus_contain_observe ev rdig ARGUS_F_CONTAINMENT_SCOPE_EXCEEDED |
| 745 | ret false |
| 746 | end |
| 747 | h = new ArgusContainHealth 0 0 0 0 0 0 0 0 0 0 |
| 748 | argus_contain_health h |
| 749 | if ne get h failed_scope 1 |
| 750 | ret false |
| 751 | end |
| 752 | ret true |
| 753 | end |
| 754 | |
| 755 | fn test_15_contain_unmatched_and_unconfirmed to bool |
| 756 | argus_contain_init |
| 757 | req = new ArgusContainReq 1 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_CRITICAL ARGUS_F_FORGED_CAPABILITY 7 9 40 0 1 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 |
| 758 | mach = new uchar 32 0 |
| 759 | fdig = new uchar 32 0 |
| 760 | tdig = new uchar 32 0 |
| 761 | rdig = new uchar 32 0 |
| 762 | if ne argus_contain_propose req mach fdig tdig rdig ARGUS_OK |
| 763 | ret false |
| 764 | end |
| 765 | rid = get req request_id |
| 766 | bad_dig = new uchar 32 0 |
| 767 | for i ulong 32 |
| 768 | put bad_dig i get rdig i |
| 769 | end |
| 770 | put bad_dig 0 xor get bad_dig 0 1 |
| 771 | note Flipped echo digest in DECIDED -> DECISION_UNMATCHED |
| 772 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 773 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_DECIDED ARGUS_OUTCOME_OK 2 |
| 774 | put ev principal 7 |
| 775 | put ev cap_id 9 |
| 776 | put ev cap_generation 40 |
| 777 | put ev world_generation rid |
| 778 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_GRANT ARGUS_F_FORGED_CAPABILITY |
| 779 | if ne argus_contain_observe ev bad_dig ARGUS_F_CONTAINMENT_DECISION_UNMATCHED |
| 780 | ret false |
| 781 | end |
| 782 | note Valid GRANT then DONE without prior kind 4 -> EXECUTION_UNCONFIRMED |
| 783 | if ne argus_contain_observe ev rdig ARGUS_F_NONE |
| 784 | ret false |
| 785 | end |
| 786 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_EXECUTED ARGUS_OUTCOME_OK 3 |
| 787 | put ev principal 7 |
| 788 | put ev cap_id 9 |
| 789 | put ev cap_generation 40 |
| 790 | put ev world_generation rid |
| 791 | put ev resource 1 |
| 792 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_DONE ARGUS_F_FORGED_CAPABILITY |
| 793 | if ne argus_contain_observe ev rdig ARGUS_F_CONTAINMENT_EXECUTION_UNCONFIRMED |
| 794 | ret false |
| 795 | end |
| 796 | ret true |
| 797 | end |
| 798 | |
| 799 | fn test_16_contain_escalate_deny to bool |
| 800 | argus_contain_init |
| 801 | req = new ArgusContainReq 1 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_CRITICAL ARGUS_F_FORGED_CAPABILITY 7 11 50 0 1 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 |
| 802 | mach = new uchar 32 0 |
| 803 | fdig = new uchar 32 0 |
| 804 | tdig = new uchar 32 0 |
| 805 | rdig = new uchar 32 0 |
| 806 | if ne argus_contain_propose req mach fdig tdig rdig ARGUS_OK |
| 807 | ret false |
| 808 | end |
| 809 | rid = get req request_id |
| 810 | ev = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 |
| 811 | note PROPOSED -> ESCALATED -> DENIED |
| 812 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_DECIDED ARGUS_OUTCOME_ERROR 2 |
| 813 | put ev principal 7 |
| 814 | put ev cap_id 11 |
| 815 | put ev cap_generation 50 |
| 816 | put ev world_generation rid |
| 817 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_ESCALATE ARGUS_F_FORGED_CAPABILITY |
| 818 | if ne argus_contain_observe ev rdig ARGUS_F_NONE |
| 819 | ret false |
| 820 | end |
| 821 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_DECIDED ARGUS_OUTCOME_DENIED 3 |
| 822 | put ev principal 7 |
| 823 | put ev cap_id 11 |
| 824 | put ev cap_generation 50 |
| 825 | put ev world_generation rid |
| 826 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_DENY ARGUS_F_FORGED_CAPABILITY |
| 827 | if ne argus_contain_observe ev rdig ARGUS_F_NONE |
| 828 | ret false |
| 829 | end |
| 830 | note Subsequent decision on closed DENIED request -> DECISION_UNMATCHED |
| 831 | mk_ev ev ARGUS_CLASS_CRITICAL ARGUS_EV_CONTAINMENT_DECIDED ARGUS_OUTCOME_OK 4 |
| 832 | put ev principal 7 |
| 833 | put ev cap_id 11 |
| 834 | put ev cap_generation 50 |
| 835 | put ev world_generation rid |
| 836 | put ev object_id argus_contain_pack ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_CSTATUS_GRANT ARGUS_F_FORGED_CAPABILITY |
| 837 | if ne argus_contain_observe ev rdig ARGUS_F_CONTAINMENT_DECISION_UNMATCHED |
| 838 | ret false |
| 839 | end |
| 840 | h = new ArgusContainHealth 0 0 0 0 0 0 0 0 0 0 |
| 841 | argus_contain_health h |
| 842 | if ne get h escalated 1 |
| 843 | ret false |
| 844 | end |
| 845 | if ne get h denied 1 |
| 846 | ret false |
| 847 | end |
| 848 | if ne get h decisions_unmatched 1 |
| 849 | ret false |
| 850 | end |
| 851 | ret true |
| 852 | end |
| 853 | |
| 854 | fn main to int |
| 855 | failed = uint 0 |
| 856 | failed = add failed report s_t01 test_01_wire_and_chain |
| 857 | failed = add failed report s_t02 test_02_class_floor_and_version |
| 858 | failed = add failed report s_t03 test_03_consumer_and_external |
| 859 | failed = add failed report s_t04 test_04_containment_v12_and_i2 |
| 860 | failed = add failed report s_t05 test_05_creq_wire_roundtrip |
| 861 | failed = add failed report s_t06 test_06_ring_watermarks_conservation |
| 862 | failed = add failed report s_t07 test_07_ring_malformed_and_drops |
| 863 | failed = add failed report s_t08 test_08_core_cap_detectors |
| 864 | failed = add failed report s_t09 test_09_sequence_and_replay |
| 865 | failed = add failed report s_t10 test_10_world_and_telemetry_loss |
| 866 | failed = add failed report s_t11 test_11_contain_confirmed |
| 867 | failed = add failed report s_t12 test_12_contain_i2_and_rate_limit |
| 868 | failed = add failed report s_t13 test_13_contain_i5d_unauth_exec |
| 869 | failed = add failed report s_t14 test_14_contain_i1b_scope_exceeded |
| 870 | failed = add failed report s_t15 test_15_contain_unmatched_and_unconfirmed |
| 871 | failed = add failed report s_t16 test_16_contain_escalate_deny |
| 872 | if eq failed 0 |
| 873 | w = argus_write_all 1 s_sum |
| 874 | if w |
| 875 | ret 0 |
| 876 | end |
| 877 | ret 1 |
| 878 | end |
| 879 | w = argus_write_all 1 s_fsum |
| 880 | if w |
| 881 | ret 1 |
| 882 | end |
| 883 | ret 1 |
| 884 | end |