Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/aienux/argus/bridge_test.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / aienux / argus / bridge_test.om` 271 lines ยท 6644 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note aienux/argus/bridge_test.om: Behavioral self-test for Pure-Omega ARGUS-AEGIS Bridge. 3 note Compose with: si/directives/om2.om aienux/argus/event.om aienux/argus/contain.om aienux/argus/bridge.om aienux/argus/bridge_test.om om/tls/sha2.om 4 5 text s_pass "PASS " 6 text s_fail "FAIL " 7 text s_nl "\n" 8 text s_t1 "bridge_init_attach_and_observer_mint" 9 text s_t2 "bridge_submit_grant_execute_confirm_lifecycle" 10 text s_t3 "bridge_submit_protected_subject_denied" 11 text s_t4 "bridge_submit_non_revoke_escalates_and_zero_mach_fallback" 12 text s_t5 "bridge_budget_exhaustion_escalates" 13 text s_t6 "bridge_findings_queue_fifo_and_unattached_refusal" 14 text s_sum "ARGUS_BRIDGE_TEST_PASS total=6 failed=0\n" 15 text s_fsum "ARGUS_BRIDGE_TEST_FAIL\n" 16 17 fn brt_write_all fd int buf view uchar * to bool 18 total = len buf 19 off = ulong 0 20 while lt off total bound 4096 21 n = write fd buf off sub total off 22 if le n 0 23 ret false 24 end 25 off = add off ulong n 26 end 27 ret true 28 end 29 30 fn brt_report name view uchar * ok bool to uint 31 if ok 32 w1 = brt_write_all 1 s_pass 33 w2 = brt_write_all 1 name 34 w3 = brt_write_all 1 s_nl 35 if and w1 and w2 w3 36 ret 0 37 end 38 ret 1 39 end 40 w1 = brt_write_all 1 s_fail 41 w2 = brt_write_all 1 name 42 w3 = brt_write_all 1 s_nl 43 if and w1 and w2 w3 44 ret 1 45 end 46 ret 1 47 end 48 49 fn brt_setup mach edit uchar 32 to void 50 for i ulong 32 51 put mach i uchar add 10 i 52 end 53 argus_core_init 54 argus_contain_init 55 rc1 = argus_bridge_init mach 56 rc2 = argus_bridge_attach_gate 57 argus_bridge_set_clock 100 58 if or ne rc1 ARGUS_OK ne rc2 ARGUS_OK 59 trap 8 60 end 61 end 62 63 fn test_1_observer_mint to bool 64 mach = new uchar 32 0 65 brt_setup mach 66 argus_bridge_observer BRIDGE_OBS_MINT 5 1 77 3 999 67 if ne argus_bridge_error ARGUS_OK 68 ret false 69 end 70 if ne get argus_sh_state 5 ARGUS_SH_LIVE 71 ret false 72 end 73 if ne get argus_sh_subj 5 77 74 ret false 75 end 76 if ne argus_bridge_finding_count 0 77 ret false 78 end 79 ret true 80 end 81 82 fn test_2_grant_execute_confirm to bool 83 mach = new uchar 32 0 84 brt_setup mach 85 argus_bridge_observer BRIDGE_OBS_MINT 3 10 55 1 500 86 fdig = new uchar 32 1 87 tdig = new uchar 32 2 88 dig = new uchar 32 0 89 req = new ArgusContainReq 1 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_CRITICAL ARGUS_F_REVOKED_CAPABILITY_USED 55 3 10 0 1 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 90 prc = argus_contain_propose req mach fdig tdig dig 91 if ne prc ARGUS_OK 92 ret false 93 end 94 src = argus_bridge_submit req mach fdig tdig 95 if ne src ARGUS_OK 96 ret false 97 end 98 if ne argus_bridge_last_decision ARGUS_CSTATUS_GRANT 99 ret false 100 end 101 if ne argus_bridge_last_exec_status ARGUS_CSTATUS_DONE 102 ret false 103 end 104 if ne get argus_sh_state 3 ARGUS_SH_REVOKED 105 ret false 106 end 107 h = new ArgusContainHealth 0 0 0 0 0 0 0 0 0 0 108 argus_contain_health h 109 if ne get h confirmed 1 110 ret false 111 end 112 if ne argus_bridge_finding_count 0 113 ret false 114 end 115 ret true 116 end 117 118 fn test_3_protected_denied to bool 119 mach = new uchar 32 0 120 brt_setup mach 121 argus_bridge_observer BRIDGE_OBS_MINT 4 20 BRIDGE_SUBJ_AEGIS 1 600 122 fdig = new uchar 32 3 123 tdig = new uchar 32 4 124 dig = new uchar 32 0 125 req = new ArgusContainReq 2 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_HIGH ARGUS_F_FORGED_CAPABILITY BRIDGE_SUBJ_AEGIS 4 20 0 2 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 126 prc = argus_contain_propose req mach fdig tdig dig 127 if ne prc ARGUS_OK 128 ret false 129 end 130 src = argus_bridge_submit req mach fdig tdig 131 if ne src ARGUS_OK 132 ret false 133 end 134 if ne argus_bridge_last_decision ARGUS_CSTATUS_DENY 135 ret false 136 end 137 if ne argus_bridge_last_why BRIDGE_WHY_PROTECTED 138 ret false 139 end 140 if ne get argus_sh_state 4 ARGUS_SH_LIVE 141 ret false 142 end 143 h = new ArgusContainHealth 0 0 0 0 0 0 0 0 0 0 144 argus_contain_health h 145 if ne get h denied 1 146 ret false 147 end 148 ret true 149 end 150 151 fn test_4_non_revoke_escalate_zero_mach to bool 152 mach = new uchar 32 0 153 brt_setup mach 154 zmach = new uchar 32 0 155 fdig = new uchar 32 5 156 tdig = new uchar 32 9 157 dig = new uchar 32 0 158 req = new ArgusContainReq 3 ARGUS_CONTAIN_FREEZE_PRINCIPAL ARGUS_SEV_HIGH ARGUS_F_FORGED_CAPABILITY 88 ARGUS_CAP_NONE 0 0 3 0 0 ARGUS_CREQ_SYNTHETIC ARGUS_CONTAIN_REQ_VERSION 0 159 prc = argus_contain_propose req zmach fdig tdig dig 160 if ne prc ARGUS_OK 161 ret false 162 end 163 src = argus_bridge_submit req zmach fdig tdig 164 if ne src ARGUS_OK 165 ret false 166 end 167 if ne argus_bridge_last_decision ARGUS_CSTATUS_ESCALATE 168 ret false 169 end 170 if ne argus_bridge_last_why BRIDGE_WHY_NO_EXECUTOR 171 ret false 172 end 173 h = new ArgusContainHealth 0 0 0 0 0 0 0 0 0 0 174 argus_contain_health h 175 if ne get h escalated 1 176 ret false 177 end 178 ret true 179 end 180 181 fn test_5_budget_exhaustion to bool 182 mach = new uchar 32 0 183 brt_setup mach 184 fdig = new uchar 32 6 185 tdig = new uchar 32 7 186 dig = new uchar 32 0 187 req = new ArgusContainReq 1 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_CRITICAL ARGUS_F_REVOKED_CAPABILITY_USED 90 10 1 0 1 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 188 i = uint 0 189 while lt i 9 bound 10 190 cid = add i 10 191 argus_bridge_observer BRIDGE_OBS_MINT cid 1 90 1 100 192 put req incident_id ulong add i 1 193 put req target_cap_id cid 194 put req request_id 0 195 put req finding_sequence ulong add i 1 196 prc = argus_contain_propose req mach fdig tdig dig 197 if ne prc ARGUS_OK 198 ret false 199 end 200 src = argus_bridge_submit req mach fdig tdig 201 if ne src ARGUS_OK 202 ret false 203 end 204 if lt i 8 205 if ne argus_bridge_last_decision ARGUS_CSTATUS_GRANT 206 ret false 207 end 208 else 209 if ne argus_bridge_last_decision ARGUS_CSTATUS_ESCALATE 210 ret false 211 end 212 if ne argus_bridge_last_why BRIDGE_WHY_BUDGET 213 ret false 214 end 215 end 216 i = add i 1 217 end 218 ret true 219 end 220 221 fn test_6_findings_fifo_and_unattached to bool 222 mach = new uchar 32 0 223 brt_setup mach 224 ev = new ArgusEvent ARGUS_ABI_VERSION ARGUS_CLASS_AUDIT ARGUS_EV_CAPABILITY_USED ARGUS_EFFECT_NONE ARGUS_OUTCOME_OK 0 1 10 44 0 99 0 1 0 123 225 evdig = new uchar 32 0 226 irc = argus_bridge_ingest ev mach evdig 227 if ne irc ARGUS_OK 228 ret false 229 end 230 if ne argus_bridge_finding_count 1 231 ret false 232 end 233 f = new ArgusFinding 0 0 0 0 0 0 0 0 0 0 0 234 got = argus_bridge_take_finding f 235 if not got 236 ret false 237 end 238 if ne get f code ARGUS_F_FORGED_CAPABILITY 239 ret false 240 end 241 if ne argus_bridge_finding_count 0 242 ret false 243 end 244 argus_bridge_destroy 245 tdig = new uchar 32 0 246 req = new ArgusContainReq 9 ARGUS_CONTAIN_REVOKE_CAPABILITY ARGUS_SEV_HIGH ARGUS_F_FORGED_CAPABILITY 55 1 1 1 1 0 0 0 ARGUS_CONTAIN_REQ_VERSION 0 247 src = argus_bridge_submit req mach evdig tdig 248 if ne src ARGUS_ERR_ARG 249 ret false 250 end 251 ret true 252 end 253 254 fn main to int 255 fails = uint 0 256 fails = add fails brt_report s_t1 test_1_observer_mint 257 fails = add fails brt_report s_t2 test_2_grant_execute_confirm 258 fails = add fails brt_report s_t3 test_3_protected_denied 259 fails = add fails brt_report s_t4 test_4_non_revoke_escalate_zero_mach 260 fails = add fails brt_report s_t5 test_5_budget_exhaustion 261 fails = add fails brt_report s_t6 test_6_findings_fifo_and_unattached 262 if eq fails 0 263 ok = brt_write_all 1 s_sum 264 if ok 265 ret 0 266 end 267 ret 1 268 end 269 ok = brt_write_all 1 s_fsum 270 ret 1 271 end