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/event.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 / event.om` 579 lines ยท 18302 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note aienux/argus/event.om: Pure-Omega ARGUS Event ABI v1.2, Canonical Wire Encoding, Validation, 3 note and SHA-256 Chain/Digest Engine. 4 note Converted from upstream aienux native/argus/argus_abi.h and native/argus/argus_event.c. 5 note Compose with: si/directives/om2.om om/tls/sha2.om aienux/argus/event.om ... 6 7 struct ArgusEvent version uchar class_ uchar kind ushort effect_class uchar outcome uchar flags ushort sequence ulong tick ulong principal uint code int cap_id uint object_id uint cap_generation ulong world_generation ulong resource ulong end 8 9 struct ArgusFinding code ushort severity uchar confidence uchar sync_allowed uchar containment uchar detector ushort sequence ulong prior_sequence ulong principal uint cap_id uint cap_generation ulong end 10 11 struct ArgusContainReq incident_id ulong containment uchar severity uchar finding_code ushort principal uint target_cap_id uint target_cap_gen ulong request_id ulong finding_sequence ulong target_object uint target_rights uint flags ushort version uchar reserved uchar end 12 13 struct ArgusRingStats pushed ulong popped ulong critical_overflow ulong depth uint capacity uint ref_malformed ulong ref_crit ulong ref_sec ulong ref_audit ulong ref_info ulong end 14 15 struct ArgusContainHealth proposed ulong granted ulong denied ulong escalated ulong confirmed ulong failed_scope ulong decisions_unmatched ulong executions_unauthorized ulong executions_unconfirmed ulong rate_limited ulong end 16 17 note ABI version and sizes 18 const ARGUS_ABI_VERSION uchar 1 19 const ARGUS_ABI_MINOR uchar 2 20 const ARGUS_EVENT_SIZE ulong 128 21 const ARGUS_FINDING_WIRE_SIZE ulong 104 22 const ARGUS_CONTAIN_REQ_SIZE ulong 152 23 const ARGUS_CONTAIN_REQ_VERSION uchar 2 24 const ARGUS_DIGEST_LEN ulong 32 25 const ARGUS_CAP_MAX uint 256 26 const ARGUS_CAP_NONE uint 0xffffffff 27 const ARGUS_U64_MAX ulong 0xffffffffffffffff 28 29 note Result codes 30 const ARGUS_OK int 0 31 const ARGUS_ERR_ARG int -60 32 const ARGUS_ERR_VERSION int -61 33 const ARGUS_ERR_MALFORMED int -62 34 const ARGUS_ERR_FULL int -63 35 const ARGUS_ERR_SEQUENCE int -64 36 const ARGUS_ERR_STATE int -65 37 const ARGUS_ERR_OVERFLOW int -66 38 39 note Event classes (smaller = stronger) 40 const ARGUS_CLASS_CRITICAL uchar 1 41 const ARGUS_CLASS_SECURITY uchar 2 42 const ARGUS_CLASS_AUDIT uchar 3 43 const ARGUS_CLASS_INFORMATIONAL uchar 4 44 const ARGUS_CLASS_MAX uchar 4 45 46 note Event kinds 47 const ARGUS_EV_NONE ushort 0 48 const ARGUS_EV_CAPABILITY_GRANTED ushort 1 49 const ARGUS_EV_CAPABILITY_USED ushort 2 50 const ARGUS_EV_CAPABILITY_DENIED ushort 3 51 const ARGUS_EV_CAPABILITY_REVOKED ushort 4 52 const ARGUS_EV_CREDENTIAL_LEASE_CREATED ushort 10 53 const ARGUS_EV_CREDENTIAL_LEASE_USED ushort 11 54 const ARGUS_EV_CREDENTIAL_LEASE_REVOKED ushort 12 55 const ARGUS_EV_ARTIFACT_ADMITTED ushort 20 56 const ARGUS_EV_ARTIFACT_REJECTED ushort 21 57 const ARGUS_EV_ARTIFACT_ACTIVATED ushort 22 58 const ARGUS_EV_MACHINE_JOINED ushort 30 59 const ARGUS_EV_MACHINE_TRUST_CHANGED ushort 31 60 const ARGUS_EV_MACHINE_REMOVED ushort 32 61 const ARGUS_EV_PROVIDER_DISCOVERED ushort 40 62 const ARGUS_EV_PROVIDER_CHANGED ushort 41 63 const ARGUS_EV_PROVIDER_QUARANTINED ushort 42 64 const ARGUS_EV_PROVIDER_USED ushort 43 65 const ARGUS_EV_EXTERNAL_EFFECT_REQUESTED ushort 50 66 const ARGUS_EV_EXTERNAL_EFFECT_DENIED ushort 51 67 const ARGUS_EV_EXTERNAL_EFFECT_COMMITTED ushort 52 68 const ARGUS_EV_INTEGRITY_VIOLATION ushort 60 69 const ARGUS_EV_SIGNATURE_FAILURE ushort 61 70 const ARGUS_EV_STALE_GENERATION ushort 62 71 const ARGUS_EV_FORGED_CAPABILITY ushort 63 72 const ARGUS_EV_WORLD_COMMITTED ushort 70 73 const ARGUS_EV_POLICY_CHANGED ushort 71 74 const ARGUS_EV_RUNTIME_BUILD_CHANGED ushort 72 75 const ARGUS_EV_TELEMETRY_DROPPED ushort 80 76 const ARGUS_EV_CAPABILITY_USE_SUMMARY ushort 81 77 const ARGUS_EV_CONTAINMENT_PROPOSED ushort 90 78 const ARGUS_EV_CONTAINMENT_DECIDED ushort 91 79 const ARGUS_EV_CONTAINMENT_EXECUTED ushort 92 80 const ARGUS_EV_AUTHORITY_ESCALATED ushort 93 81 82 note Effect classes 83 const ARGUS_EFFECT_NONE uchar 0 84 const ARGUS_EFFECT_EPHEMERAL uchar 1 85 const ARGUS_EFFECT_EVIDENCE uchar 2 86 const ARGUS_EFFECT_EXTERNAL uchar 3 87 const ARGUS_EFFECT_MAX uchar 3 88 89 note Outcomes 90 const ARGUS_OUTCOME_OK uchar 1 91 const ARGUS_OUTCOME_DENIED uchar 2 92 const ARGUS_OUTCOME_ERROR uchar 3 93 const ARGUS_OUTCOME_MAX uchar 3 94 95 note Flags 96 const ARGUS_FLAG_SYNTHETIC ushort 0x0001 97 const ARGUS_FLAG_CONSUMER ushort 0x0002 98 99 note Severities & confidence 100 const ARGUS_SEV_INFO uchar 1 101 const ARGUS_SEV_LOW uchar 2 102 const ARGUS_SEV_MEDIUM uchar 3 103 const ARGUS_SEV_HIGH uchar 4 104 const ARGUS_SEV_CRITICAL uchar 5 105 const ARGUS_CONF_DETERMINISTIC uchar 1 106 107 note Finding codes 108 const ARGUS_F_NONE ushort 0 109 const ARGUS_F_FORGED_CAPABILITY ushort 1 110 const ARGUS_F_STALE_GENERATION ushort 2 111 const ARGUS_F_REVOKED_CAPABILITY_USED ushort 3 112 const ARGUS_F_ARTIFACT_DIGEST_UNEXPECTED ushort 4 113 const ARGUS_F_SIGNATURE_INVALID ushort 5 114 const ARGUS_F_CREDENTIAL_SCOPE_VIOLATION ushort 6 115 const ARGUS_F_MACHINE_IDENTITY_MISMATCH ushort 7 116 const ARGUS_F_EFFECT_CLASS_UNAUTHORIZED ushort 8 117 const ARGUS_F_WORLD_PROVENANCE_INCONSISTENT ushort 9 118 const ARGUS_F_QUARANTINED_USE ushort 10 119 const ARGUS_F_TELEMETRY_LOSS ushort 11 120 const ARGUS_F_SEQUENCE_ANOMALY ushort 12 121 const ARGUS_F_AUTHORITY_REPLAY ushort 13 122 const ARGUS_F_SUBJECT_MISMATCH ushort 14 123 const ARGUS_F_TRUST_ESCALATION ushort 15 124 const ARGUS_F_MALFORMED_EVENT ushort 16 125 const ARGUS_F_CONTAINMENT_DECISION_UNMATCHED ushort 17 126 const ARGUS_F_CONTAINMENT_EXECUTION_UNAUTHORIZED ushort 18 127 const ARGUS_F_CONTAINMENT_EXECUTION_UNCONFIRMED ushort 19 128 const ARGUS_F_CONTAINMENT_UNANSWERED ushort 20 129 const ARGUS_F_CONTAINMENT_SCOPE_EXCEEDED ushort 21 130 131 note Containment request types 132 const ARGUS_CONTAIN_NONE uchar 0 133 const ARGUS_CONTAIN_REVOKE_CAPABILITY uchar 1 134 const ARGUS_CONTAIN_FREEZE_PRINCIPAL uchar 2 135 const ARGUS_CONTAIN_RESTRICT_PRINCIPAL uchar 3 136 const ARGUS_CONTAIN_QUARANTINE_MACHINE uchar 4 137 const ARGUS_CONTAIN_QUARANTINE_PROVIDER uchar 5 138 const ARGUS_CONTAIN_REVOKE_CREDENTIAL_LEASE uchar 6 139 const ARGUS_CONTAIN_REJECT_ARTIFACT uchar 7 140 const ARGUS_CONTAIN_REQUIRE_REATTESTATION uchar 8 141 const ARGUS_CONTAIN_RAISE_EFFECT_CLASS uchar 9 142 const ARGUS_CONTAIN_PAUSE_EXTERNAL_EFFECTS uchar 10 143 const ARGUS_CONTAIN_MAX uchar 10 144 145 note Containment request flags 146 const ARGUS_CREQ_SYNTHETIC ushort 0x0001 147 const ARGUS_CREQ_SATURATION ushort 0x0002 148 const ARGUS_CREQ_KNOWN ushort 0x0003 149 150 note Containment statuses 151 const ARGUS_CSTATUS_PROPOSED uchar 0 152 const ARGUS_CSTATUS_GRANT uchar 1 153 const ARGUS_CSTATUS_DENY uchar 2 154 const ARGUS_CSTATUS_ESCALATE uchar 3 155 const ARGUS_CSTATUS_DONE uchar 4 156 const ARGUS_CSTATUS_PARTIAL uchar 5 157 const ARGUS_CSTATUS_FAILED uchar 6 158 const ARGUS_CSTATUS_UNAVAILABLE uchar 7 159 const ARGUS_CSTATUS_FAILED_SCOPE uchar 8 160 const ARGUS_CSTATUS_MAX uchar 8 161 162 note ---- Little-endian wire helpers ---- 163 164 fn argus_put16 buf edit uchar * off ulong v ushort to void 165 put buf off uchar and v 0xff 166 put buf add off 1 uchar and shr v 8 0xff 167 end 168 169 fn argus_put32 buf edit uchar * off ulong v uint to void 170 put buf off uchar and v 0xff 171 put buf add off 1 uchar and shr v 8 0xff 172 put buf add off 2 uchar and shr v 16 0xff 173 put buf add off 3 uchar and shr v 24 0xff 174 end 175 176 fn argus_put64 buf edit uchar * off ulong v ulong to void 177 argus_put32 buf off uint and v 0xffffffff 178 argus_put32 buf add off 4 uint and shr v 32 0xffffffff 179 end 180 181 fn argus_get16 buf view uchar * off ulong to ushort 182 b0 = ushort get buf off 183 b1 = shl ushort get buf add off 1 8 184 ret or b0 b1 185 end 186 187 fn argus_get32 buf view uchar * off ulong to uint 188 b0 = uint get buf off 189 b1 = shl uint get buf add off 1 8 190 b2 = shl uint get buf add off 2 16 191 b3 = shl uint get buf add off 3 24 192 ret or or b0 b1 or b2 b3 193 end 194 195 fn argus_get64 buf view uchar * off ulong to ulong 196 lo = ulong argus_get32 buf off 197 hi = shl ulong argus_get32 buf add off 4 32 198 ret or lo hi 199 end 200 201 fn argus_contain_pack typ uchar st uchar fcode ushort to uint 202 ret or or uint typ shl uint st 8 shl uint fcode 16 203 end 204 205 fn argus_contain_type_of obj uint to uchar 206 ret uchar and obj 0xff 207 end 208 209 fn argus_contain_status_of obj uint to uchar 210 ret uchar and shr obj 8 0xff 211 end 212 213 fn argus_contain_code_of obj uint to ushort 214 ret ushort and shr obj 16 0xffff 215 end 216 217 fn argus_stream_of flags ushort to ushort 218 ret shr and flags 0xfffc 2 219 end 220 221 fn argus_eq32 a view uchar 32 b view uchar 32 to bool 222 diff = uchar 0 223 for i ulong 32 224 diff = or diff xor get a i get b i 225 end 226 ret eq diff 0 227 end 228 229 note ---- Event class floor (smaller number = stronger class) ---- 230 231 fn argus_event_min_class kind ushort to uchar 232 if or eq kind ARGUS_EV_INTEGRITY_VIOLATION or eq kind ARGUS_EV_SIGNATURE_FAILURE or eq kind ARGUS_EV_STALE_GENERATION eq kind ARGUS_EV_FORGED_CAPABILITY 233 ret ARGUS_CLASS_CRITICAL 234 end 235 if or eq kind ARGUS_EV_TELEMETRY_DROPPED or eq kind ARGUS_EV_PROVIDER_QUARANTINED or eq kind ARGUS_EV_MACHINE_TRUST_CHANGED eq kind ARGUS_EV_MACHINE_REMOVED 236 ret ARGUS_CLASS_CRITICAL 237 end 238 if or eq kind ARGUS_EV_POLICY_CHANGED or eq kind ARGUS_EV_RUNTIME_BUILD_CHANGED or eq kind ARGUS_EV_CAPABILITY_REVOKED eq kind ARGUS_EV_CREDENTIAL_LEASE_REVOKED 239 ret ARGUS_CLASS_CRITICAL 240 end 241 if or eq kind ARGUS_EV_ARTIFACT_REJECTED or eq kind ARGUS_EV_EXTERNAL_EFFECT_COMMITTED or eq kind ARGUS_EV_CONTAINMENT_PROPOSED eq kind ARGUS_EV_CONTAINMENT_DECIDED 242 ret ARGUS_CLASS_CRITICAL 243 end 244 if or eq kind ARGUS_EV_CONTAINMENT_EXECUTED eq kind ARGUS_EV_AUTHORITY_ESCALATED 245 ret ARGUS_CLASS_CRITICAL 246 end 247 if or eq kind ARGUS_EV_CAPABILITY_GRANTED or eq kind ARGUS_EV_CAPABILITY_DENIED or eq kind ARGUS_EV_CREDENTIAL_LEASE_CREATED eq kind ARGUS_EV_ARTIFACT_ADMITTED 248 ret ARGUS_CLASS_SECURITY 249 end 250 if or eq kind ARGUS_EV_ARTIFACT_ACTIVATED or eq kind ARGUS_EV_MACHINE_JOINED or eq kind ARGUS_EV_PROVIDER_DISCOVERED eq kind ARGUS_EV_PROVIDER_CHANGED 251 ret ARGUS_CLASS_SECURITY 252 end 253 if or eq kind ARGUS_EV_EXTERNAL_EFFECT_REQUESTED or eq kind ARGUS_EV_EXTERNAL_EFFECT_DENIED eq kind ARGUS_EV_WORLD_COMMITTED 254 ret ARGUS_CLASS_SECURITY 255 end 256 if or eq kind ARGUS_EV_CAPABILITY_USED or eq kind ARGUS_EV_CREDENTIAL_LEASE_USED or eq kind ARGUS_EV_PROVIDER_USED eq kind ARGUS_EV_CAPABILITY_USE_SUMMARY 257 ret ARGUS_CLASS_AUDIT 258 end 259 ret 0 260 end 261 262 note ---- Event validation (v1.2) ---- 263 264 fn argus_validate_containment ev view ArgusEvent to int 265 obj = get ev object_id 266 typ = argus_contain_type_of obj 267 st = argus_contain_status_of obj 268 oc = get ev outcome 269 if or lt typ 1 gt typ ARGUS_CONTAIN_MAX 270 ret ARGUS_ERR_MALFORMED 271 end 272 if eq get ev world_generation 0 273 ret ARGUS_ERR_MALFORMED 274 end 275 k = get ev kind 276 if eq k ARGUS_EV_CONTAINMENT_PROPOSED 277 if and eq st ARGUS_CSTATUS_PROPOSED eq oc ARGUS_OUTCOME_OK 278 ret ARGUS_OK 279 end 280 ret ARGUS_ERR_MALFORMED 281 end 282 if eq k ARGUS_EV_CONTAINMENT_DECIDED 283 if eq st ARGUS_CSTATUS_GRANT 284 if eq oc ARGUS_OUTCOME_OK 285 ret ARGUS_OK 286 end 287 ret ARGUS_ERR_MALFORMED 288 end 289 if eq st ARGUS_CSTATUS_DENY 290 if eq oc ARGUS_OUTCOME_DENIED 291 ret ARGUS_OK 292 end 293 ret ARGUS_ERR_MALFORMED 294 end 295 if eq st ARGUS_CSTATUS_ESCALATE 296 if eq oc ARGUS_OUTCOME_ERROR 297 ret ARGUS_OK 298 end 299 ret ARGUS_ERR_MALFORMED 300 end 301 ret ARGUS_ERR_MALFORMED 302 end 303 note ARGUS_EV_CONTAINMENT_EXECUTED 304 if eq st ARGUS_CSTATUS_DONE 305 note I2: only REVOKE_CAPABILITY has a live executor; others require SYNTHETIC flag 306 if ne typ ARGUS_CONTAIN_REVOKE_CAPABILITY 307 if eq and get ev flags ARGUS_FLAG_SYNTHETIC 0 308 ret ARGUS_ERR_MALFORMED 309 end 310 end 311 if eq oc ARGUS_OUTCOME_OK 312 ret ARGUS_OK 313 end 314 ret ARGUS_ERR_MALFORMED 315 end 316 if eq st ARGUS_CSTATUS_PARTIAL 317 if eq oc ARGUS_OUTCOME_OK 318 ret ARGUS_OK 319 end 320 ret ARGUS_ERR_MALFORMED 321 end 322 if eq st ARGUS_CSTATUS_FAILED 323 if or eq oc ARGUS_OUTCOME_DENIED eq oc ARGUS_OUTCOME_ERROR 324 ret ARGUS_OK 325 end 326 ret ARGUS_ERR_MALFORMED 327 end 328 if or eq st ARGUS_CSTATUS_UNAVAILABLE eq st ARGUS_CSTATUS_FAILED_SCOPE 329 if eq oc ARGUS_OUTCOME_ERROR 330 ret ARGUS_OK 331 end 332 ret ARGUS_ERR_MALFORMED 333 end 334 ret ARGUS_ERR_MALFORMED 335 end 336 337 fn argus_event_validate ev view ArgusEvent to int 338 if ne get ev version ARGUS_ABI_VERSION 339 ret ARGUS_ERR_VERSION 340 end 341 cls = get ev class_ 342 if or lt cls ARGUS_CLASS_CRITICAL gt cls ARGUS_CLASS_MAX 343 ret ARGUS_ERR_MALFORMED 344 end 345 k = get ev kind 346 minc = argus_event_min_class k 347 if eq minc 0 348 ret ARGUS_ERR_MALFORMED 349 end 350 if gt cls minc 351 ret ARGUS_ERR_MALFORMED 352 end 353 if gt get ev effect_class ARGUS_EFFECT_MAX 354 ret ARGUS_ERR_MALFORMED 355 end 356 oc = get ev outcome 357 if or lt oc ARGUS_OUTCOME_OK gt oc ARGUS_OUTCOME_MAX 358 ret ARGUS_ERR_MALFORMED 359 end 360 has_cons = ne and get ev flags ARGUS_FLAG_CONSUMER 0 361 want_cons = or eq k ARGUS_EV_TELEMETRY_DROPPED eq k ARGUS_EV_CONTAINMENT_PROPOSED 362 if ne has_cons want_cons 363 ret ARGUS_ERR_MALFORMED 364 end 365 if and ge k ARGUS_EV_CONTAINMENT_PROPOSED le k ARGUS_EV_CONTAINMENT_EXECUTED 366 rc = argus_validate_containment ev 367 if ne rc ARGUS_OK 368 ret rc 369 end 370 end 371 cid = get ev cap_id 372 if and ge cid ARGUS_CAP_MAX ne cid ARGUS_CAP_NONE 373 ret ARGUS_ERR_MALFORMED 374 end 375 if eq k ARGUS_EV_CAPABILITY_USE_SUMMARY 376 if ne oc ARGUS_OUTCOME_OK 377 ret ARGUS_ERR_MALFORMED 378 end 379 if gt get ev world_generation get ev cap_generation 380 ret ARGUS_ERR_MALFORMED 381 end 382 end 383 seq = get ev sequence 384 if or eq seq 0 eq seq ARGUS_U64_MAX 385 ret ARGUS_ERR_MALFORMED 386 end 387 if or eq k ARGUS_EV_EXTERNAL_EFFECT_REQUESTED or eq k ARGUS_EV_EXTERNAL_EFFECT_DENIED eq k ARGUS_EV_EXTERNAL_EFFECT_COMMITTED 388 if ne get ev effect_class ARGUS_EFFECT_EXTERNAL 389 ret ARGUS_ERR_MALFORMED 390 end 391 end 392 ret ARGUS_OK 393 end 394 395 note ---- Canonical 128-byte Event Encode / Decode / SHA-256 Digest & Chain ---- 396 397 fn argus_event_encode ev view ArgusEvent mach view uchar 32 evdig view uchar 32 dst edit uchar 128 to int 398 put dst 0 get ev version 399 put dst 1 get ev class_ 400 argus_put16 dst 2 get ev kind 401 put dst 4 get ev effect_class 402 put dst 5 get ev outcome 403 argus_put16 dst 6 get ev flags 404 argus_put64 dst 8 get ev sequence 405 argus_put64 dst 16 get ev tick 406 argus_put32 dst 24 get ev principal 407 argus_put32 dst 28 bitcast uint get ev code 408 argus_put32 dst 32 get ev cap_id 409 argus_put32 dst 36 get ev object_id 410 argus_put64 dst 40 get ev cap_generation 411 argus_put64 dst 48 get ev world_generation 412 argus_put64 dst 56 get ev resource 413 for i ulong 32 414 put dst add 64 i get mach i 415 put dst add 96 i get evdig i 416 end 417 ret ARGUS_OK 418 end 419 420 fn argus_event_decode_fields raw view uchar 128 dst edit ArgusEvent to void 421 put dst version get raw 0 422 put dst class_ get raw 1 423 put dst kind argus_get16 raw 2 424 put dst effect_class get raw 4 425 put dst outcome get raw 5 426 put dst flags argus_get16 raw 6 427 put dst sequence argus_get64 raw 8 428 put dst tick argus_get64 raw 16 429 put dst principal argus_get32 raw 24 430 put dst code bitcast int argus_get32 raw 28 431 put dst cap_id argus_get32 raw 32 432 put dst object_id argus_get32 raw 36 433 put dst cap_generation argus_get64 raw 40 434 put dst world_generation argus_get64 raw 48 435 put dst resource argus_get64 raw 56 436 end 437 438 fn argus_event_decode raw view uchar 128 dst edit ArgusEvent mach edit uchar 32 evdig edit uchar 32 to int 439 tmp = new ArgusEvent 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 440 argus_event_decode_fields raw tmp 441 rc = argus_event_validate tmp 442 if ne rc ARGUS_OK 443 ret rc 444 end 445 argus_event_decode_fields raw dst 446 for i ulong 32 447 put mach i get raw add 64 i 448 put evdig i get raw add 96 i 449 end 450 ret ARGUS_OK 451 end 452 453 fn argus_event_digest ev view ArgusEvent mach view uchar 32 evdig view uchar 32 dst edit uchar 32 to void 454 wire = new uchar 128 0 455 rc = argus_event_encode ev mach evdig wire 456 n = sha2_digest 256 wire dst 457 if and eq rc ARGUS_OK eq n 32 458 ret 459 end 460 end 461 462 fn argus_chain_extend chain edit uchar 32 ev view ArgusEvent mach view uchar 32 evdig view uchar 32 to void 463 wire = new uchar 128 0 464 rc = argus_event_encode ev mach evdig wire 465 ctx = new ulong 40 0 466 sha256_init ctx 467 sha256_update ctx chain 468 sha256_update ctx wire 469 sha256_final ctx chain 470 if eq rc ARGUS_OK 471 ret 472 end 473 end 474 475 note ---- Canonical 104-byte Finding Digest ---- 476 477 fn argus_finding_digest f view ArgusFinding mach view uchar 32 evdig view uchar 32 dst edit uchar 32 to void 478 wire = new uchar 104 0 479 argus_put16 wire 0 get f code 480 put wire 2 get f severity 481 put wire 3 get f confidence 482 put wire 4 get f sync_allowed 483 put wire 5 get f containment 484 argus_put16 wire 6 get f detector 485 argus_put64 wire 8 get f sequence 486 argus_put64 wire 16 get f prior_sequence 487 argus_put32 wire 24 get f principal 488 argus_put32 wire 28 get f cap_id 489 argus_put64 wire 32 get f cap_generation 490 for i ulong 32 491 put wire add 40 i get mach i 492 put wire add 72 i get evdig i 493 end 494 n = sha2_digest 256 wire dst 495 if eq n 32 496 ret 497 end 498 end 499 500 note ---- Canonical 152-byte ContainmentRequest Encode / Decode / Digest ---- 501 502 fn argus_creq_encode req view ArgusContainReq mach view uchar 32 fdig view uchar 32 tdig view uchar 32 dst edit uchar 152 to int 503 argus_put64 dst 0 get req incident_id 504 put dst 8 get req containment 505 put dst 9 get req severity 506 argus_put16 dst 10 get req finding_code 507 argus_put32 dst 12 get req principal 508 argus_put32 dst 16 get req target_cap_id 509 argus_put64 dst 20 get req target_cap_gen 510 for i ulong 32 511 put dst add 28 i get mach i 512 put dst add 60 i get fdig i 513 put dst add 116 i get tdig i 514 end 515 argus_put64 dst 92 get req request_id 516 argus_put64 dst 100 get req finding_sequence 517 argus_put32 dst 108 get req target_object 518 argus_put32 dst 112 get req target_rights 519 argus_put16 dst 148 get req flags 520 put dst 150 get req version 521 put dst 151 get req reserved 522 ret ARGUS_OK 523 end 524 525 fn argus_creq_decode raw view uchar 152 dst edit ArgusContainReq mach edit uchar 32 fdig edit uchar 32 tdig edit uchar 32 to int 526 if ne get raw 150 ARGUS_CONTAIN_REQ_VERSION 527 ret ARGUS_ERR_VERSION 528 end 529 ct = get raw 8 530 sev = get raw 9 531 resv = get raw 151 532 fl = argus_get16 raw 148 533 rid = argus_get64 raw 92 534 fseq = argus_get64 raw 100 535 if or lt ct 1 gt ct ARGUS_CONTAIN_MAX 536 ret ARGUS_ERR_MALFORMED 537 end 538 if or lt sev ARGUS_SEV_INFO gt sev ARGUS_SEV_CRITICAL 539 ret ARGUS_ERR_MALFORMED 540 end 541 if ne resv 0 542 ret ARGUS_ERR_MALFORMED 543 end 544 if ne and fl xor ARGUS_CREQ_KNOWN 0xffff 0 545 ret ARGUS_ERR_MALFORMED 546 end 547 if or eq rid 0 eq fseq 0 548 ret ARGUS_ERR_MALFORMED 549 end 550 put dst incident_id argus_get64 raw 0 551 put dst containment ct 552 put dst severity sev 553 put dst finding_code argus_get16 raw 10 554 put dst principal argus_get32 raw 12 555 put dst target_cap_id argus_get32 raw 16 556 put dst target_cap_gen argus_get64 raw 20 557 put dst request_id rid 558 put dst finding_sequence fseq 559 put dst target_object argus_get32 raw 108 560 put dst target_rights argus_get32 raw 112 561 put dst flags fl 562 put dst version ARGUS_CONTAIN_REQ_VERSION 563 put dst reserved 0 564 for i ulong 32 565 put mach i get raw add 28 i 566 put fdig i get raw add 60 i 567 put tdig i get raw add 116 i 568 end 569 ret ARGUS_OK 570 end 571 572 fn argus_creq_digest req view ArgusContainReq mach view uchar 32 fdig view uchar 32 tdig view uchar 32 dst edit uchar 32 to void 573 wire = new uchar 152 0 574 rc = argus_creq_encode req mach fdig tdig wire 575 n = sha2_digest 256 wire dst 576 if and eq rc ARGUS_OK eq n 32 577 ret 578 end 579 end