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 / si / inquisitor / lib.om
| 1 | note si/inquisitor/lib.om: pure-Omega automated code gatekeeper and diff/audit scanner |
| 2 | note Faithful port of spark-inquisitor (DiffAuditor + ConstitutionalChecker) plus |
| 3 | note omega-mv governance rules (protected paths, dirty-tree, NOT_RUN-as-PASS, stubs). |
| 4 | note Composed after si/directives/om2.om; no om2 header and no fn main in this unit. |
| 5 | |
| 6 | const SEV_PASS ulong 0 |
| 7 | const SEV_WARN ulong 1 |
| 8 | const SEV_BLOCK ulong 2 |
| 9 | |
| 10 | const RULE_SECRET ulong 0 |
| 11 | const RULE_ENV_FILE ulong 1 |
| 12 | const RULE_PROTECTED_PATH ulong 2 |
| 13 | const RULE_DIRTY_TREE ulong 3 |
| 14 | const RULE_FALSE_PASS ulong 4 |
| 15 | const RULE_TELEMETRY ulong 5 |
| 16 | const RULE_STUB_HARD ulong 6 |
| 17 | const RULE_TODO_WARN ulong 7 |
| 18 | const RULE_UNSLOP_WARN ulong 8 |
| 19 | |
| 20 | const SUB_AWS_KEY ulong 1 |
| 21 | const SUB_GH_PAT ulong 2 |
| 22 | const SUB_PRIV_KEY ulong 3 |
| 23 | const SUB_SECRET_ASSIGN ulong 4 |
| 24 | const SUB_ENV_FILE ulong 5 |
| 25 | const SUB_PATH_EVIDENCE ulong 6 |
| 26 | const SUB_PATH_AIEN ulong 7 |
| 27 | const SUB_PATH_GATES ulong 8 |
| 28 | const SUB_PATH_CI ulong 9 |
| 29 | const SUB_DIRTY_TREE ulong 10 |
| 30 | const SUB_FALSE_PASS_INLINE ulong 11 |
| 31 | const SUB_FALSE_PASS_RECORD ulong 12 |
| 32 | const SUB_TELEM_VENDOR ulong 13 |
| 33 | const SUB_TELEM_RAW ulong 14 |
| 34 | const SUB_STUB_HARD ulong 15 |
| 35 | const SUB_TODO_WARN ulong 16 |
| 36 | const SUB_UNSLOP_DASH ulong 17 |
| 37 | const SUB_UNSLOP_BUZZ ulong 18 |
| 38 | const SUB_PATH_AIEN_TEST ulong 19 |
| 39 | |
| 40 | const INQ_MAX_IN ulong 131072 |
| 41 | const INQ_MAX_OUT ulong 32768 |
| 42 | const INQ_MAX_FIND ulong 128 |
| 43 | |
| 44 | global inq_in uchar 131072 |
| 45 | global inq_in_len ulong 1 |
| 46 | global inq_out uchar 32768 |
| 47 | global inq_out_len ulong 1 |
| 48 | global inq_pbuf uchar 131072 |
| 49 | global inq_pbuf_off ulong 1 |
| 50 | global inq_pbuf_len ulong 1 |
| 51 | global inq_a_buf uchar 131072 |
| 52 | global inq_a_len ulong 1 |
| 53 | global inq_b_buf uchar 131072 |
| 54 | global inq_b_len ulong 1 |
| 55 | global inq_is_md ulong 1 |
| 56 | global inq_tmp_off ulong 1 |
| 57 | global inq_tmp_len ulong 1 |
| 58 | global inq_num_val ulong 1 |
| 59 | global inq_num_pos ulong 1 |
| 60 | global inq_num_ok ulong 1 |
| 61 | |
| 62 | global inq_verdict ulong 1 |
| 63 | global inq_blocks ulong 1 |
| 64 | global inq_warns ulong 1 |
| 65 | global inq_files ulong 1 |
| 66 | global inq_lines ulong 1 |
| 67 | global inq_added ulong 1 |
| 68 | global inq_rcnt ulong 16 |
| 69 | |
| 70 | global inq_find_cnt ulong 1 |
| 71 | global inq_find_rule ulong 128 |
| 72 | global inq_find_sev ulong 128 |
| 73 | global inq_find_line ulong 128 |
| 74 | global inq_find_sub ulong 128 |
| 75 | |
| 76 | global inq_in_bin ulong 1 |
| 77 | global inq_in_hunk ulong 1 |
| 78 | global inq_hunk_has_cnt ulong 1 |
| 79 | global inq_hunk_old ulong 1 |
| 80 | global inq_hunk_new ulong 1 |
| 81 | global inq_expect_plus ulong 1 |
| 82 | global inq_has_git_hdr ulong 1 |
| 83 | global inq_in_git_body ulong 1 |
| 84 | global inq_skip_file ulong 1 |
| 85 | global inq_diff_checked ulong 1 |
| 86 | global inq_seen_notrun ulong 1 |
| 87 | global inq_seen_pass ulong 1 |
| 88 | global inq_rec_flagged ulong 1 |
| 89 | global inq_hash ulong 1 |
| 90 | |
| 91 | text inq_hex "0123456789abcdef" |
| 92 | |
| 93 | note Diff header prefixes |
| 94 | text p_diff_git "diff --git " |
| 95 | text p_plus3 "+++ " |
| 96 | text p_minus3 "--- " |
| 97 | text p_hunk "@@ " |
| 98 | text p_hunk3 "@@@ " |
| 99 | text p_bin_files "Binary files " |
| 100 | text p_git_bin "GIT binary patch" |
| 101 | text p_file_rec "FILE: " |
| 102 | text p_dev_null "/dev/null" |
| 103 | text p_b_slash "b/" |
| 104 | text p_a_slash "a/" |
| 105 | text p_sp_b_slash " b/" |
| 106 | text p_sp_qb_slash " \"b/" |
| 107 | text p_sp_and_sp " and " |
| 108 | text p_sp_and_b " and b/" |
| 109 | text p_sp_and_qb " and \"b/" |
| 110 | text p_sp_and_dev " and /dev/null" |
| 111 | text p_sp_differ " differ" |
| 112 | text p_colon_sp ": " |
| 113 | text p_ren_from "rename from " |
| 114 | text p_ren_to "rename to " |
| 115 | text p_cpy_from "copy from " |
| 116 | text p_cpy_to "copy to " |
| 117 | text p_hdr_idx "index " |
| 118 | text p_hdr_omode "old mode " |
| 119 | text p_hdr_nmode "new mode " |
| 120 | text p_hdr_nfmode "new file mode " |
| 121 | text p_hdr_dfmode "deleted file mode " |
| 122 | text p_hdr_sim "similarity index " |
| 123 | text p_hdr_dis "dissimilarity index " |
| 124 | |
| 125 | note Self-exclusion paths for non-secret rule literals (DRA-440: never exempt from secrets scanning) |
| 126 | text p_self_inq "spark-inquisitor" |
| 127 | text p_self_con "constitution.rs" |
| 128 | |
| 129 | note Protected path patterns |
| 130 | text p_env ".env" |
| 131 | text p_env_dot ".env." |
| 132 | text p_evid_pre "evidence/" |
| 133 | text p_evid_mid "/evidence/" |
| 134 | text p_aien_pre ".aien/" |
| 135 | text p_aien_mid "/.aien/" |
| 136 | text p_gates_pre "tests/gates/" |
| 137 | text p_gates_mid "/tests/gates/" |
| 138 | text p_ghwf_pre ".github/workflows/" |
| 139 | text p_ghwf_mid "/.github/workflows/" |
| 140 | text p_fgjo_pre ".forgejo/" |
| 141 | text p_fgjo_mid "/.forgejo/" |
| 142 | text p_aient_pre "tools/aien-test/" |
| 143 | text p_aient_mid "/tools/aien-test/" |
| 144 | text p_ext_md ".md" |
| 145 | |
| 146 | note Secret patterns |
| 147 | text p_akia "AKIA" |
| 148 | text p_ghp "ghp_" |
| 149 | text p_gh_fine "github_pat_" |
| 150 | text p_pem_beg "-----BEGIN " |
| 151 | text p_pem_end "PRIVATE KEY-----" |
| 152 | text p_pem_rsa "BEGIN RSA PRIVATE KEY" |
| 153 | text p_sec_k1 "SECRET_KEY=" |
| 154 | text p_sec_k2 "API_KEY=" |
| 155 | text p_sec_k3 "PRIVATE_KEY=" |
| 156 | text p_sec_k4 "ACCESS_TOKEN=" |
| 157 | text p_redacted "redacted" |
| 158 | text p_vault "vault" |
| 159 | |
| 160 | note Dirty-tree patterns |
| 161 | text p_dt1 "dirty_tree: true" |
| 162 | text p_dt2 "dirty_tree=true" |
| 163 | text p_dt3 "dirty_tree=1" |
| 164 | text p_dt4 "dirty_tree: 1" |
| 165 | text p_dt5 "git_status: dirty" |
| 166 | text p_dt6 "worktree: dirty" |
| 167 | text p_dt7 "tree_state: dirty" |
| 168 | text p_dt8 "dirty-tree: true" |
| 169 | text p_dt9 "status: m " |
| 170 | text p_dt10 "status: ?? " |
| 171 | |
| 172 | note False-PASS (NOT_RUN / SKIPPED labelled PASS) patterns |
| 173 | text p_pass_w "pass" |
| 174 | text p_not_run "not_run" |
| 175 | text p_skipped "skipped" |
| 176 | text p_blk_hw "blocked_hardware" |
| 177 | text p_blk_op "blocked_operator" |
| 178 | text p_miss_impl "missing_implementation" |
| 179 | text p_zero_tests "0 tests run" |
| 180 | text p_gs_notrun "gate_state: not_run" |
| 181 | text p_tr_zero "tests_run: 0" |
| 182 | text p_ex_zero "executed: 0" |
| 183 | text p_ts_skip "test_status: skipped" |
| 184 | text p_ts_notrun "test_status: not_run" |
| 185 | text p_st_notrun "state: not_run" |
| 186 | text p_v_pass "verdict: pass" |
| 187 | text p_c_pass "claim: pass" |
| 188 | text p_s_pass "status: pass" |
| 189 | text p_r_pass "reported: pass" |
| 190 | text p_rec_sep "---" |
| 191 | |
| 192 | note Telemetry patterns (upstream audit.rs) |
| 193 | text p_tel1 "google-analytics" |
| 194 | text p_tel2 "segment.io" |
| 195 | text p_tel3 "mixpanel" |
| 196 | text p_tel4 "sentry.io" |
| 197 | text p_tel5 "datadog" |
| 198 | text p_tel6 "tracking_id" |
| 199 | text p_tel7 "analytics.js" |
| 200 | text p_tel8 "amplitude.com" |
| 201 | text p_tel9 "hotjar" |
| 202 | text p_tel10 "clarity.ms" |
| 203 | text p_tel11 "send_telemetry" |
| 204 | text p_tel12 "report_telemetry" |
| 205 | text p_tel13 "collect_telemetry" |
| 206 | text p_tel_raw "telemetry" |
| 207 | text p_tel_ok1 "gpu-telemetry" |
| 208 | text p_tel_ok2 "zero telemetry" |
| 209 | text p_tel_ok3 "zero-telemetry" |
| 210 | text p_tel_ok4 "no telemetry" |
| 211 | text p_tel_ok5 "no-telemetry" |
| 212 | text p_tel_ok6 "anti-telemetry" |
| 213 | text p_tel_ok7 "block telemetry" |
| 214 | text p_tel_ok8 "telemetryforbidden" |
| 215 | text p_tel_ok9 "forbid" |
| 216 | text p_tel_ok10 "reject" |
| 217 | |
| 218 | note Stub and TODO markers |
| 219 | text p_stub1 "unimplemented!(" |
| 220 | text p_stub2 "todo!(" |
| 221 | text p_stub3 "stub_only" |
| 222 | text p_stub4 "not_implemented" |
| 223 | text p_stub5 "panic!(\"not implemented" |
| 224 | text p_todo1 "todo:" |
| 225 | text p_todo2 "todo(" |
| 226 | text p_todo3 "fixme:" |
| 227 | text p_todo4 "fixme " |
| 228 | text p_todo5 "placeholder" |
| 229 | |
| 230 | note Unslop buzzword patterns (upstream constitution.rs) |
| 231 | text p_bz1 "delve" |
| 232 | text p_bz2 "tapestry" |
| 233 | text p_bz3 "testament" |
| 234 | text p_bz4 "crucial" |
| 235 | text p_bz5 "pivotal" |
| 236 | text p_bz6 "game-changer" |
| 237 | text p_bz7 "game changer" |
| 238 | text p_bz8 "elevate" |
| 239 | text p_bz8_ok1 "--elevate" |
| 240 | text p_bz8_ok2 "elevate_" |
| 241 | text p_bz9 "unleash" |
| 242 | text p_bz9_ok1 "--unleash" |
| 243 | text p_bz9_ok2 "unleash_" |
| 244 | |
| 245 | note Receipt JSON strings |
| 246 | text j_head "{\"verdict\":\"" |
| 247 | text j_pass "PASS" |
| 248 | text j_warn "WARN" |
| 249 | text j_block "BLOCK" |
| 250 | text j_sev "\",\"severity\":" |
| 251 | text j_blk ",\"blocks\":" |
| 252 | text j_wrn ",\"warns\":" |
| 253 | text j_fil ",\"files\":" |
| 254 | text j_lin ",\"lines\":" |
| 255 | text j_add ",\"added\":" |
| 256 | text j_r_sec ",\"rules\":{\"secret\":" |
| 257 | text j_r_env ",\"env_file\":" |
| 258 | text j_r_pth ",\"protected_path\":" |
| 259 | text j_r_dty ",\"dirty_tree\":" |
| 260 | text j_r_fps ",\"false_pass\":" |
| 261 | text j_r_tel ",\"telemetry\":" |
| 262 | text j_r_stb ",\"stub\":" |
| 263 | text j_r_tdo ",\"todo\":" |
| 264 | text j_r_uns ",\"unslop\":" |
| 265 | text j_fp "},\"fingerprint\":\"" |
| 266 | text j_fnd "\",\"findings\":[" |
| 267 | text j_f_open "{\"rule\":\"" |
| 268 | text j_f_sev "\",\"severity\":\"" |
| 269 | text j_f_line "\",\"line\":" |
| 270 | text j_f_det ",\"detail\":\"" |
| 271 | text j_f_close "\"}" |
| 272 | text j_comma "," |
| 273 | text j_tail "]}\n" |
| 274 | |
| 275 | note Rule name strings |
| 276 | text rn_secret "secret" |
| 277 | text rn_env "env_file" |
| 278 | text rn_path "protected_path" |
| 279 | text rn_dirty "dirty_tree" |
| 280 | text rn_fpass "false_pass" |
| 281 | text rn_telem "telemetry" |
| 282 | text rn_stub "stub" |
| 283 | text rn_todo "todo" |
| 284 | text rn_unslop "unslop" |
| 285 | text rn_unk "unknown" |
| 286 | |
| 287 | note Sub-reason detail strings |
| 288 | text sd_aws "aws_access_key" |
| 289 | text sd_gh "github_pat" |
| 290 | text sd_pem "private_key_pem" |
| 291 | text sd_assign "plaintext_secret_assign" |
| 292 | text sd_env "plaintext_env_file" |
| 293 | text sd_evid "protected_evidence_path" |
| 294 | text sd_aien "protected_aien_path" |
| 295 | text sd_gates "protected_gates_path" |
| 296 | text sd_ci "protected_ci_workflow_path" |
| 297 | text sd_aient "protected_aien_test_path" |
| 298 | text sd_dirty "dirty_worktree_flag" |
| 299 | text sd_fpi "not_run_or_skipped_labelled_pass" |
| 300 | text sd_fpr "audit_record_pass_with_zero_or_not_run" |
| 301 | text sd_tv "telemetry_tracker_hook" |
| 302 | text sd_tr "telemetry_source_indicator" |
| 303 | text sd_stub "unimplemented_or_stub_marker" |
| 304 | text sd_todo "todo_or_fixme_marker" |
| 305 | text sd_dash "unicode_em_or_en_dash" |
| 306 | text sd_buzz "ai_slop_buzzword" |
| 307 | text sd_other "policy_violation" |
| 308 | |
| 309 | fn inq_to_lower c uchar to uchar |
| 310 | if and ge c 65 le c 90 |
| 311 | ret add c 32 |
| 312 | end |
| 313 | ret c |
| 314 | end |
| 315 | |
| 316 | fn inq_is_alnum c uchar to bool |
| 317 | if and ge c 48 le c 57 |
| 318 | ret true |
| 319 | end |
| 320 | if and ge c 65 le c 90 |
| 321 | ret true |
| 322 | end |
| 323 | if and ge c 97 le c 122 |
| 324 | ret true |
| 325 | end |
| 326 | ret false |
| 327 | end |
| 328 | |
| 329 | fn inq_is_upper_alnum c uchar to bool |
| 330 | if and ge c 48 le c 57 |
| 331 | ret true |
| 332 | end |
| 333 | if and ge c 65 le c 90 |
| 334 | ret true |
| 335 | end |
| 336 | ret false |
| 337 | end |
| 338 | |
| 339 | fn inq_is_word c uchar to bool |
| 340 | if eq c 95 |
| 341 | ret true |
| 342 | end |
| 343 | ret inq_is_alnum c |
| 344 | end |
| 345 | |
| 346 | fn inq_fnv_step h ulong b uchar to ulong |
| 347 | x = xor h ulong b |
| 348 | ret mul x ulong 0x100000001b3 |
| 349 | end |
| 350 | |
| 351 | fn inq_reset to void |
| 352 | put inq_pbuf_off 0 0 |
| 353 | put inq_pbuf_len 0 0 |
| 354 | put inq_a_len 0 0 |
| 355 | put inq_b_len 0 0 |
| 356 | put inq_is_md 0 0 |
| 357 | put inq_tmp_off 0 0 |
| 358 | put inq_tmp_len 0 0 |
| 359 | put inq_out_len 0 0 |
| 360 | put inq_verdict 0 SEV_PASS |
| 361 | put inq_blocks 0 0 |
| 362 | put inq_warns 0 0 |
| 363 | put inq_files 0 0 |
| 364 | put inq_lines 0 0 |
| 365 | put inq_added 0 0 |
| 366 | put inq_find_cnt 0 0 |
| 367 | put inq_in_bin 0 0 |
| 368 | put inq_in_hunk 0 0 |
| 369 | put inq_hunk_has_cnt 0 0 |
| 370 | put inq_hunk_old 0 0 |
| 371 | put inq_hunk_new 0 0 |
| 372 | put inq_expect_plus 0 0 |
| 373 | put inq_has_git_hdr 0 0 |
| 374 | put inq_in_git_body 0 0 |
| 375 | put inq_skip_file 0 0 |
| 376 | put inq_diff_checked 0 0 |
| 377 | put inq_seen_notrun 0 0 |
| 378 | put inq_seen_pass 0 0 |
| 379 | put inq_rec_flagged 0 0 |
| 380 | put inq_hash 0 ulong 0xcbf29ce484222325 |
| 381 | for i ulong 16 |
| 382 | put inq_rcnt i 0 |
| 383 | end |
| 384 | end |
| 385 | |
| 386 | fn inq_load_text s view uchar * to ulong |
| 387 | n = len s |
| 388 | if gt n INQ_MAX_IN |
| 389 | n = INQ_MAX_IN |
| 390 | end |
| 391 | for i ulong n bound 131072 |
| 392 | put inq_in i get s i |
| 393 | end |
| 394 | put inq_in_len 0 n |
| 395 | ret n |
| 396 | end |
| 397 | |
| 398 | fn inq_record rule ulong sev ulong line_no ulong sub_id ulong to void |
| 399 | cur_v = get inq_verdict 0 |
| 400 | if gt sev cur_v |
| 401 | put inq_verdict 0 sev |
| 402 | end |
| 403 | if eq sev SEV_BLOCK |
| 404 | put inq_blocks 0 add get inq_blocks 0 1 |
| 405 | else |
| 406 | if eq sev SEV_WARN |
| 407 | put inq_warns 0 add get inq_warns 0 1 |
| 408 | end |
| 409 | end |
| 410 | if lt rule 16 |
| 411 | put inq_rcnt rule add get inq_rcnt rule 1 |
| 412 | end |
| 413 | fc = get inq_find_cnt 0 |
| 414 | if lt fc INQ_MAX_FIND |
| 415 | put inq_find_rule fc rule |
| 416 | put inq_find_sev fc sev |
| 417 | put inq_find_line fc line_no |
| 418 | put inq_find_sub fc sub_id |
| 419 | put inq_find_cnt 0 add fc 1 |
| 420 | end |
| 421 | end |
| 422 | |
| 423 | fn inq_starts_cs off ulong nlen ulong pat view uchar * to bool |
| 424 | pl = len pat |
| 425 | if lt nlen pl |
| 426 | ret false |
| 427 | end |
| 428 | for i ulong pl bound 128 |
| 429 | if ne get inq_in add off i get pat i |
| 430 | ret false |
| 431 | end |
| 432 | end |
| 433 | ret true |
| 434 | end |
| 435 | |
| 436 | fn inq_match_cs pos ulong pat view uchar * to bool |
| 437 | pl = len pat |
| 438 | for j ulong pl bound 128 |
| 439 | if ne get inq_in add pos j get pat j |
| 440 | ret false |
| 441 | end |
| 442 | end |
| 443 | ret true |
| 444 | end |
| 445 | |
| 446 | fn inq_match_ci pos ulong pat view uchar * to bool |
| 447 | pl = len pat |
| 448 | for j ulong pl bound 128 |
| 449 | c1 = inq_to_lower get inq_in add pos j |
| 450 | c2 = inq_to_lower get pat j |
| 451 | if ne c1 c2 |
| 452 | ret false |
| 453 | end |
| 454 | end |
| 455 | ret true |
| 456 | end |
| 457 | |
| 458 | fn inq_contains_cs off ulong nlen ulong pat view uchar * to bool |
| 459 | pl = len pat |
| 460 | if or eq pl 0 lt nlen pl |
| 461 | ret false |
| 462 | end |
| 463 | lim = add sub nlen pl 1 |
| 464 | for i ulong lim bound 131072 |
| 465 | if inq_match_cs add off i pat |
| 466 | ret true |
| 467 | end |
| 468 | end |
| 469 | ret false |
| 470 | end |
| 471 | |
| 472 | fn inq_contains_ci off ulong nlen ulong pat view uchar * to bool |
| 473 | pl = len pat |
| 474 | if or eq pl 0 lt nlen pl |
| 475 | ret false |
| 476 | end |
| 477 | lim = add sub nlen pl 1 |
| 478 | for i ulong lim bound 131072 |
| 479 | if inq_match_ci add off i pat |
| 480 | ret true |
| 481 | end |
| 482 | end |
| 483 | ret false |
| 484 | end |
| 485 | |
| 486 | fn inq_word_ok off ulong nlen ulong i ulong pl ulong to bool |
| 487 | if gt i 0 |
| 488 | if inq_is_word get inq_in sub add off i 1 |
| 489 | ret false |
| 490 | end |
| 491 | end |
| 492 | end_idx = add i pl |
| 493 | if lt end_idx nlen |
| 494 | if inq_is_word get inq_in add off end_idx |
| 495 | ret false |
| 496 | end |
| 497 | end |
| 498 | ret true |
| 499 | end |
| 500 | |
| 501 | fn inq_contains_word_ci off ulong nlen ulong pat view uchar * to bool |
| 502 | pl = len pat |
| 503 | if or eq pl 0 lt nlen pl |
| 504 | ret false |
| 505 | end |
| 506 | lim = add sub nlen pl 1 |
| 507 | for i ulong lim bound 131072 |
| 508 | if inq_word_ok off nlen i pl |
| 509 | if inq_match_ci add off i pat |
| 510 | ret true |
| 511 | end |
| 512 | end |
| 513 | end |
| 514 | ret false |
| 515 | end |
| 516 | |
| 517 | fn inq_find_substr_cs off ulong nlen ulong pat view uchar * to ulong |
| 518 | pl = len pat |
| 519 | if or eq pl 0 lt nlen pl |
| 520 | ret nlen |
| 521 | end |
| 522 | lim = add sub nlen pl 1 |
| 523 | for i ulong lim bound 131072 |
| 524 | if inq_match_cs add off i pat |
| 525 | ret i |
| 526 | end |
| 527 | end |
| 528 | ret nlen |
| 529 | end |
| 530 | |
| 531 | fn inq_find_substr_last_cs off ulong nlen ulong pat view uchar * to ulong |
| 532 | pl = len pat |
| 533 | if or eq pl 0 lt nlen pl |
| 534 | ret nlen |
| 535 | end |
| 536 | found = nlen |
| 537 | lim = add sub nlen pl 1 |
| 538 | for i ulong lim bound 131072 |
| 539 | if inq_match_cs add off i pat |
| 540 | found = i |
| 541 | end |
| 542 | end |
| 543 | ret found |
| 544 | end |
| 545 | |
| 546 | fn inq_find_quote_end pos ulong end_p ulong to ulong |
| 547 | p = add pos 1 |
| 548 | while lt p end_p bound 131072 |
| 549 | c = get inq_in p |
| 550 | if eq c 92 |
| 551 | if lt add p 1 end_p |
| 552 | p = add p 2 |
| 553 | else |
| 554 | p = end_p |
| 555 | end |
| 556 | else |
| 557 | if eq c 34 |
| 558 | ret add p 1 |
| 559 | end |
| 560 | p = add p 1 |
| 561 | end |
| 562 | end |
| 563 | ret end_p |
| 564 | end |
| 565 | |
| 566 | fn inq_slice_eq_pat off ulong nlen ulong pat view uchar * to bool |
| 567 | if ne nlen len pat |
| 568 | ret false |
| 569 | end |
| 570 | for i ulong nlen bound 128 |
| 571 | if ne get inq_in add off i get pat i |
| 572 | ret false |
| 573 | end |
| 574 | end |
| 575 | ret true |
| 576 | end |
| 577 | |
| 578 | fn inq_slice_eq_in off1 ulong len1 ulong off2 ulong len2 ulong to bool |
| 579 | if ne len1 len2 |
| 580 | ret false |
| 581 | end |
| 582 | for i ulong len1 bound 131072 |
| 583 | if ne get inq_in add off1 i get inq_in add off2 i |
| 584 | ret false |
| 585 | end |
| 586 | end |
| 587 | ret true |
| 588 | end |
| 589 | |
| 590 | fn inq_pb_eq_pat off ulong nlen ulong pat view uchar * to bool |
| 591 | if ne nlen len pat |
| 592 | ret false |
| 593 | end |
| 594 | for i ulong nlen bound 128 |
| 595 | if ne get inq_pbuf add off i get pat i |
| 596 | ret false |
| 597 | end |
| 598 | end |
| 599 | ret true |
| 600 | end |
| 601 | |
| 602 | fn inq_pb_match_ci pos ulong pat view uchar * to bool |
| 603 | pl = len pat |
| 604 | for j ulong pl bound 128 |
| 605 | c1 = inq_to_lower get inq_pbuf add pos j |
| 606 | c2 = inq_to_lower get pat j |
| 607 | if ne c1 c2 |
| 608 | ret false |
| 609 | end |
| 610 | end |
| 611 | ret true |
| 612 | end |
| 613 | |
| 614 | fn inq_pb_starts_ci off ulong nlen ulong pat view uchar * to bool |
| 615 | pl = len pat |
| 616 | if lt nlen pl |
| 617 | ret false |
| 618 | end |
| 619 | for i ulong pl bound 128 |
| 620 | if ne inq_to_lower get inq_pbuf add off i inq_to_lower get pat i |
| 621 | ret false |
| 622 | end |
| 623 | end |
| 624 | ret true |
| 625 | end |
| 626 | |
| 627 | fn inq_pb_ends_ci off ulong nlen ulong pat view uchar * to bool |
| 628 | pl = len pat |
| 629 | if lt nlen pl |
| 630 | ret false |
| 631 | end |
| 632 | base = add off sub nlen pl |
| 633 | for i ulong pl bound 128 |
| 634 | if ne inq_to_lower get inq_pbuf add base i inq_to_lower get pat i |
| 635 | ret false |
| 636 | end |
| 637 | end |
| 638 | ret true |
| 639 | end |
| 640 | |
| 641 | fn inq_pb_contains_ci off ulong nlen ulong pat view uchar * to bool |
| 642 | pl = len pat |
| 643 | if or eq pl 0 lt nlen pl |
| 644 | ret false |
| 645 | end |
| 646 | lim = add sub nlen pl 1 |
| 647 | for i ulong lim bound 131072 |
| 648 | if inq_pb_match_ci add off i pat |
| 649 | ret true |
| 650 | end |
| 651 | end |
| 652 | ret false |
| 653 | end |
| 654 | |
| 655 | fn inq_pb_is_env off ulong nlen ulong to bool |
| 656 | if lt nlen 4 |
| 657 | ret false |
| 658 | end |
| 659 | base = ulong 0 |
| 660 | for i ulong nlen bound 131072 |
| 661 | if eq get inq_pbuf add off i 47 |
| 662 | base = add i 1 |
| 663 | end |
| 664 | end |
| 665 | blen = sub nlen base |
| 666 | if lt blen 4 |
| 667 | ret false |
| 668 | end |
| 669 | p0 = add off base |
| 670 | if ne get inq_pbuf p0 46 |
| 671 | ret false |
| 672 | end |
| 673 | if ne inq_to_lower get inq_pbuf add p0 1 101 |
| 674 | ret false |
| 675 | end |
| 676 | if ne inq_to_lower get inq_pbuf add p0 2 110 |
| 677 | ret false |
| 678 | end |
| 679 | if ne inq_to_lower get inq_pbuf add p0 3 118 |
| 680 | ret false |
| 681 | end |
| 682 | if eq blen 4 |
| 683 | ret true |
| 684 | end |
| 685 | if eq get inq_pbuf add p0 4 46 |
| 686 | ret true |
| 687 | end |
| 688 | ret false |
| 689 | end |
| 690 | |
| 691 | fn inq_pb_eq_a to bool |
| 692 | off = get inq_pbuf_off 0 |
| 693 | nlen = get inq_pbuf_len 0 |
| 694 | if ne nlen get inq_a_len 0 |
| 695 | ret false |
| 696 | end |
| 697 | for i ulong nlen bound 131072 |
| 698 | if ne get inq_pbuf add off i get inq_a_buf i |
| 699 | ret false |
| 700 | end |
| 701 | end |
| 702 | ret true |
| 703 | end |
| 704 | |
| 705 | fn inq_pb_eq_b to bool |
| 706 | off = get inq_pbuf_off 0 |
| 707 | nlen = get inq_pbuf_len 0 |
| 708 | if ne nlen get inq_b_len 0 |
| 709 | ret false |
| 710 | end |
| 711 | for i ulong nlen bound 131072 |
| 712 | if ne get inq_pbuf add off i get inq_b_buf i |
| 713 | ret false |
| 714 | end |
| 715 | end |
| 716 | ret true |
| 717 | end |
| 718 | |
| 719 | fn inq_pb_save_a to void |
| 720 | off = get inq_pbuf_off 0 |
| 721 | nlen = get inq_pbuf_len 0 |
| 722 | for i ulong nlen bound 131072 |
| 723 | put inq_a_buf i get inq_pbuf add off i |
| 724 | end |
| 725 | put inq_a_len 0 nlen |
| 726 | end |
| 727 | |
| 728 | fn inq_clear_active_path to void |
| 729 | put inq_b_len 0 0 |
| 730 | put inq_skip_file 0 0 |
| 731 | put inq_is_md 0 0 |
| 732 | end |
| 733 | |
| 734 | fn inq_pb_set_active to void |
| 735 | off = get inq_pbuf_off 0 |
| 736 | nlen = get inq_pbuf_len 0 |
| 737 | for i ulong nlen bound 131072 |
| 738 | put inq_b_buf i get inq_pbuf add off i |
| 739 | end |
| 740 | put inq_b_len 0 nlen |
| 741 | if or inq_pb_contains_ci off nlen p_self_inq inq_pb_contains_ci off nlen p_self_con |
| 742 | put inq_skip_file 0 1 |
| 743 | else |
| 744 | put inq_skip_file 0 0 |
| 745 | end |
| 746 | if inq_pb_ends_ci off nlen p_ext_md |
| 747 | put inq_is_md 0 1 |
| 748 | else |
| 749 | put inq_is_md 0 0 |
| 750 | end |
| 751 | end |
| 752 | |
| 753 | fn inq_is_ws_char c uchar to bool |
| 754 | if or eq c 32 or eq c 9 eq c 13 |
| 755 | ret true |
| 756 | end |
| 757 | ret false |
| 758 | end |
| 759 | |
| 760 | fn inq_trim_ws off ulong nlen ulong to void |
| 761 | s = off |
| 762 | e = add off nlen |
| 763 | while lt s e bound 131072 |
| 764 | if inq_is_ws_char get inq_in s |
| 765 | s = add s 1 |
| 766 | else |
| 767 | break |
| 768 | end |
| 769 | end |
| 770 | while gt e s bound 131072 |
| 771 | if inq_is_ws_char get inq_in sub e 1 |
| 772 | e = sub e 1 |
| 773 | else |
| 774 | break |
| 775 | end |
| 776 | end |
| 777 | put inq_tmp_off 0 s |
| 778 | put inq_tmp_len 0 sub e s |
| 779 | end |
| 780 | |
| 781 | fn inq_is_octal c uchar to bool |
| 782 | ret and ge c 48 le c 55 |
| 783 | end |
| 784 | |
| 785 | fn inq_decode_cesc c uchar to uchar |
| 786 | if eq c 116 |
| 787 | ret 9 |
| 788 | end |
| 789 | if eq c 110 |
| 790 | ret 10 |
| 791 | end |
| 792 | if eq c 114 |
| 793 | ret 13 |
| 794 | end |
| 795 | if eq c 98 |
| 796 | ret 8 |
| 797 | end |
| 798 | if eq c 102 |
| 799 | ret 12 |
| 800 | end |
| 801 | if eq c 97 |
| 802 | ret 7 |
| 803 | end |
| 804 | if eq c 118 |
| 805 | ret 11 |
| 806 | end |
| 807 | ret c |
| 808 | end |
| 809 | |
| 810 | fn inq_oct3 a uchar b uchar c uchar to uchar |
| 811 | v1 = mul sub ulong a 48 64 |
| 812 | v2 = mul sub ulong b 48 8 |
| 813 | v3 = sub ulong c 48 |
| 814 | ret uchar and add v1 add v2 v3 255 |
| 815 | end |
| 816 | |
| 817 | fn inq_unesc_to_pbuf s ulong e ulong to ulong |
| 818 | p = s |
| 819 | w = ulong 0 |
| 820 | while lt p e bound 131072 |
| 821 | c = get inq_in p |
| 822 | if eq c 92 |
| 823 | if lt add p 1 e |
| 824 | n1 = get inq_in add p 1 |
| 825 | oct_done = false |
| 826 | if inq_is_octal n1 |
| 827 | if le add p 4 e |
| 828 | n2 = get inq_in add p 2 |
| 829 | n3 = get inq_in add p 3 |
| 830 | if and inq_is_octal n2 inq_is_octal n3 |
| 831 | put inq_pbuf w inq_oct3 n1 n2 n3 |
| 832 | w = add w 1 |
| 833 | p = add p 4 |
| 834 | oct_done = true |
| 835 | end |
| 836 | end |
| 837 | end |
| 838 | if not oct_done |
| 839 | put inq_pbuf w inq_decode_cesc n1 |
| 840 | w = add w 1 |
| 841 | p = add p 2 |
| 842 | end |
| 843 | else |
| 844 | put inq_pbuf w c |
| 845 | w = add w 1 |
| 846 | p = add p 1 |
| 847 | end |
| 848 | else |
| 849 | put inq_pbuf w c |
| 850 | w = add w 1 |
| 851 | p = add p 1 |
| 852 | end |
| 853 | end |
| 854 | ret w |
| 855 | end |
| 856 | |
| 857 | fn inq_norm_to_pbuf off ulong nlen ulong to void |
| 858 | inq_trim_ws off nlen |
| 859 | s = get inq_tmp_off 0 |
| 860 | e = add s get inq_tmp_len 0 |
| 861 | w = ulong 0 |
| 862 | quoted = false |
| 863 | if ge sub e s 2 |
| 864 | if and eq get inq_in s 34 eq get inq_in sub e 1 34 |
| 865 | w = inq_unesc_to_pbuf add s 1 sub e 1 |
| 866 | quoted = true |
| 867 | else |
| 868 | if and eq get inq_in s 39 eq get inq_in sub e 1 39 |
| 869 | s = add s 1 |
| 870 | e = sub e 1 |
| 871 | end |
| 872 | end |
| 873 | end |
| 874 | if not quoted |
| 875 | w = sub e s |
| 876 | for i ulong w bound 131072 |
| 877 | put inq_pbuf i get inq_in add s i |
| 878 | end |
| 879 | end |
| 880 | ns = ulong 0 |
| 881 | if ge sub w ns 2 |
| 882 | c0 = get inq_pbuf ns |
| 883 | c1 = get inq_pbuf add ns 1 |
| 884 | if and eq c1 47 or eq c0 97 eq c0 98 |
| 885 | ns = add ns 2 |
| 886 | end |
| 887 | end |
| 888 | while ge sub w ns 2 bound 65536 |
| 889 | c0 = get inq_pbuf ns |
| 890 | c1 = get inq_pbuf add ns 1 |
| 891 | if and eq c0 46 eq c1 47 |
| 892 | ns = add ns 2 |
| 893 | else |
| 894 | break |
| 895 | end |
| 896 | end |
| 897 | put inq_pbuf_off 0 ns |
| 898 | put inq_pbuf_len 0 sub w ns |
| 899 | end |
| 900 | |
| 901 | fn inq_pb_check_path line_no ulong to void |
| 902 | off = get inq_pbuf_off 0 |
| 903 | nlen = get inq_pbuf_len 0 |
| 904 | if eq nlen 0 |
| 905 | ret |
| 906 | end |
| 907 | if inq_pb_eq_pat off nlen p_dev_null |
| 908 | ret |
| 909 | end |
| 910 | if inq_pb_is_env off nlen |
| 911 | inq_record RULE_ENV_FILE SEV_BLOCK line_no SUB_ENV_FILE |
| 912 | end |
| 913 | if or inq_pb_starts_ci off nlen p_evid_pre inq_pb_contains_ci off nlen p_evid_mid |
| 914 | inq_record RULE_PROTECTED_PATH SEV_BLOCK line_no SUB_PATH_EVIDENCE |
| 915 | end |
| 916 | if or inq_pb_starts_ci off nlen p_aien_pre inq_pb_contains_ci off nlen p_aien_mid |
| 917 | inq_record RULE_PROTECTED_PATH SEV_BLOCK line_no SUB_PATH_AIEN |
| 918 | end |
| 919 | if or inq_pb_starts_ci off nlen p_gates_pre inq_pb_contains_ci off nlen p_gates_mid |
| 920 | inq_record RULE_PROTECTED_PATH SEV_BLOCK line_no SUB_PATH_GATES |
| 921 | end |
| 922 | if or inq_pb_starts_ci off nlen p_ghwf_pre inq_pb_contains_ci off nlen p_ghwf_mid |
| 923 | inq_record RULE_PROTECTED_PATH SEV_BLOCK line_no SUB_PATH_CI |
| 924 | else |
| 925 | if or inq_pb_starts_ci off nlen p_fgjo_pre inq_pb_contains_ci off nlen p_fgjo_mid |
| 926 | inq_record RULE_PROTECTED_PATH SEV_BLOCK line_no SUB_PATH_CI |
| 927 | end |
| 928 | end |
| 929 | if or inq_pb_starts_ci off nlen p_aient_pre inq_pb_contains_ci off nlen p_aient_mid |
| 930 | inq_record RULE_PROTECTED_PATH SEV_BLOCK line_no SUB_PATH_AIEN_TEST |
| 931 | end |
| 932 | end |
| 933 | |
| 934 | fn inq_diff_git_exact_mid pos ulong end_p ulong to ulong |
| 935 | rem_l = sub end_p pos |
| 936 | if lt rem_l 5 |
| 937 | ret end_p |
| 938 | end |
| 939 | if ne rem rem_l 2 1 |
| 940 | ret end_p |
| 941 | end |
| 942 | k = div sub rem_l 5 2 |
| 943 | if or ne get inq_in pos 97 ne get inq_in add pos 1 47 |
| 944 | ret end_p |
| 945 | end |
| 946 | m = add pos add 2 k |
| 947 | if not inq_match_cs m p_sp_b_slash |
| 948 | ret end_p |
| 949 | end |
| 950 | if inq_slice_eq_in add pos 2 k add m 3 k |
| 951 | ret add m 1 |
| 952 | end |
| 953 | ret end_p |
| 954 | end |
| 955 | |
| 956 | fn inq_diff_git_find_t2 pos ulong end_p ulong to ulong |
| 957 | if eq get inq_in pos 34 |
| 958 | qe = inq_find_quote_end pos end_p |
| 959 | while lt qe end_p bound 131072 |
| 960 | if eq get inq_in qe 32 |
| 961 | qe = add qe 1 |
| 962 | else |
| 963 | break |
| 964 | end |
| 965 | end |
| 966 | ret qe |
| 967 | end |
| 968 | mid = inq_diff_git_exact_mid pos end_p |
| 969 | if lt mid end_p |
| 970 | ret mid |
| 971 | end |
| 972 | rem_l = sub end_p pos |
| 973 | idx = inq_find_substr_cs pos rem_l p_sp_qb_slash |
| 974 | if lt idx rem_l |
| 975 | ret add pos add idx 1 |
| 976 | end |
| 977 | idx = inq_find_substr_last_cs pos rem_l p_sp_b_slash |
| 978 | if lt idx rem_l |
| 979 | ret add pos add idx 1 |
| 980 | end |
| 981 | p = pos |
| 982 | while lt p end_p bound 131072 |
| 983 | if ne get inq_in p 32 |
| 984 | p = add p 1 |
| 985 | else |
| 986 | break |
| 987 | end |
| 988 | end |
| 989 | while lt p end_p bound 131072 |
| 990 | if eq get inq_in p 32 |
| 991 | p = add p 1 |
| 992 | else |
| 993 | break |
| 994 | end |
| 995 | end |
| 996 | ret p |
| 997 | end |
| 998 | |
| 999 | fn inq_diff_git_check_alt pos ulong end_p ulong t2_s ulong line_no ulong to void |
| 1000 | if eq get inq_in pos 34 |
| 1001 | ret |
| 1002 | end |
| 1003 | rem_l = sub end_p pos |
| 1004 | idx1 = inq_find_substr_cs pos rem_l p_sp_b_slash |
| 1005 | if ge idx1 rem_l |
| 1006 | ret |
| 1007 | end |
| 1008 | alt_t2 = add pos add idx1 1 |
| 1009 | if eq alt_t2 t2_s |
| 1010 | ret |
| 1011 | end |
| 1012 | inq_norm_to_pbuf pos idx1 |
| 1013 | inq_pb_check_path line_no |
| 1014 | inq_norm_to_pbuf alt_t2 sub end_p alt_t2 |
| 1015 | inq_pb_check_path line_no |
| 1016 | end |
| 1017 | |
| 1018 | fn inq_parse_diff_git off ulong nlen ulong line_no ulong to void |
| 1019 | put inq_in_bin 0 0 |
| 1020 | put inq_in_hunk 0 0 |
| 1021 | put inq_hunk_has_cnt 0 0 |
| 1022 | put inq_hunk_old 0 0 |
| 1023 | put inq_hunk_new 0 0 |
| 1024 | put inq_expect_plus 0 1 |
| 1025 | put inq_has_git_hdr 0 1 |
| 1026 | put inq_in_git_body 0 0 |
| 1027 | put inq_diff_checked 0 0 |
| 1028 | put inq_a_len 0 0 |
| 1029 | inq_clear_active_path |
| 1030 | put inq_files 0 add get inq_files 0 1 |
| 1031 | pos = add off 11 |
| 1032 | end_p = add off nlen |
| 1033 | while lt pos end_p bound 131072 |
| 1034 | if eq get inq_in pos 32 |
| 1035 | pos = add pos 1 |
| 1036 | else |
| 1037 | break |
| 1038 | end |
| 1039 | end |
| 1040 | if ge pos end_p |
| 1041 | ret |
| 1042 | end |
| 1043 | t2_s = inq_diff_git_find_t2 pos end_p |
| 1044 | if lt t2_s end_p |
| 1045 | t1_e = t2_s |
| 1046 | while gt t1_e pos bound 131072 |
| 1047 | if eq get inq_in sub t1_e 1 32 |
| 1048 | t1_e = sub t1_e 1 |
| 1049 | else |
| 1050 | break |
| 1051 | end |
| 1052 | end |
| 1053 | inq_norm_to_pbuf pos sub t1_e pos |
| 1054 | inq_pb_save_a |
| 1055 | inq_norm_to_pbuf t2_s sub end_p t2_s |
| 1056 | same_ab = inq_pb_eq_a |
| 1057 | inq_pb_set_active |
| 1058 | inq_pb_check_path line_no |
| 1059 | if not same_ab |
| 1060 | inq_norm_to_pbuf pos sub t1_e pos |
| 1061 | inq_pb_check_path line_no |
| 1062 | inq_diff_git_check_alt pos end_p t2_s line_no |
| 1063 | end |
| 1064 | put inq_diff_checked 0 1 |
| 1065 | else |
| 1066 | inq_norm_to_pbuf pos sub end_p pos |
| 1067 | inq_pb_save_a |
| 1068 | inq_pb_set_active |
| 1069 | inq_pb_check_path line_no |
| 1070 | end |
| 1071 | end |
| 1072 | |
| 1073 | fn inq_strip_tab_len pos ulong rem_l ulong to ulong |
| 1074 | tab_i = ulong 0 |
| 1075 | while lt tab_i rem_l bound 131072 |
| 1076 | if eq get inq_in add pos tab_i 9 |
| 1077 | ret tab_i |
| 1078 | end |
| 1079 | tab_i = add tab_i 1 |
| 1080 | end |
| 1081 | ret rem_l |
| 1082 | end |
| 1083 | |
| 1084 | fn inq_is_quoted_in s ulong tl ulong to bool |
| 1085 | if lt tl 2 |
| 1086 | ret false |
| 1087 | end |
| 1088 | if ne get inq_in s 34 |
| 1089 | ret false |
| 1090 | end |
| 1091 | last = sub add s tl 1 |
| 1092 | ret eq get inq_in last 34 |
| 1093 | end |
| 1094 | |
| 1095 | fn inq_is_plain_path_in s ulong tl ulong to bool |
| 1096 | has_sep = false |
| 1097 | for i ulong tl bound 131072 |
| 1098 | c = get inq_in add s i |
| 1099 | if or eq c 32 or eq c 58 eq c 61 |
| 1100 | ret false |
| 1101 | end |
| 1102 | if or eq c 40 or eq c 41 eq c 33 |
| 1103 | ret false |
| 1104 | end |
| 1105 | if or eq c 47 eq c 46 |
| 1106 | has_sep = true |
| 1107 | end |
| 1108 | end |
| 1109 | ret has_sep |
| 1110 | end |
| 1111 | |
| 1112 | fn inq_is_hdr_path off ulong nlen ulong allow_a bool to bool |
| 1113 | rem_l = inq_strip_tab_len off nlen |
| 1114 | has_tab = lt rem_l nlen |
| 1115 | inq_trim_ws off rem_l |
| 1116 | s = get inq_tmp_off 0 |
| 1117 | tl = get inq_tmp_len 0 |
| 1118 | if eq tl 0 |
| 1119 | ret false |
| 1120 | end |
| 1121 | if inq_slice_eq_pat s tl p_dev_null |
| 1122 | ret true |
| 1123 | end |
| 1124 | if inq_is_quoted_in s tl |
| 1125 | ret true |
| 1126 | end |
| 1127 | if ge tl 2 |
| 1128 | if eq get inq_in add s 1 47 |
| 1129 | c0 = get inq_in s |
| 1130 | if eq c0 98 |
| 1131 | ret true |
| 1132 | end |
| 1133 | if and allow_a eq c0 97 |
| 1134 | ret true |
| 1135 | end |
| 1136 | end |
| 1137 | end |
| 1138 | if has_tab |
| 1139 | if inq_contains_cs s tl p_colon_sp |
| 1140 | ret false |
| 1141 | end |
| 1142 | ret true |
| 1143 | end |
| 1144 | ret inq_is_plain_path_in s tl |
| 1145 | end |
| 1146 | |
| 1147 | fn inq_has_ab_prefix s ulong tl ulong allow_a bool to bool |
| 1148 | if ge tl 2 |
| 1149 | if eq get inq_in add s 1 47 |
| 1150 | c0 = get inq_in s |
| 1151 | if eq c0 98 |
| 1152 | ret true |
| 1153 | end |
| 1154 | if and allow_a eq c0 97 |
| 1155 | ret true |
| 1156 | end |
| 1157 | end |
| 1158 | end |
| 1159 | if ge tl 4 |
| 1160 | if inq_is_quoted_in s tl |
| 1161 | if eq get inq_in add s 2 47 |
| 1162 | c1 = get inq_in add s 1 |
| 1163 | if eq c1 98 |
| 1164 | ret true |
| 1165 | end |
| 1166 | if and allow_a eq c1 97 |
| 1167 | ret true |
| 1168 | end |
| 1169 | end |
| 1170 | end |
| 1171 | end |
| 1172 | ret false |
| 1173 | end |
| 1174 | |
| 1175 | fn inq_is_git_path off ulong nlen ulong allow_a bool to bool |
| 1176 | rem_l = inq_strip_tab_len off nlen |
| 1177 | has_tab = lt rem_l nlen |
| 1178 | inq_trim_ws off rem_l |
| 1179 | s = get inq_tmp_off 0 |
| 1180 | tl = get inq_tmp_len 0 |
| 1181 | if eq tl 0 |
| 1182 | ret false |
| 1183 | end |
| 1184 | if inq_slice_eq_pat s tl p_dev_null |
| 1185 | ret true |
| 1186 | end |
| 1187 | if inq_has_ab_prefix s tl allow_a |
| 1188 | ret true |
| 1189 | end |
| 1190 | if has_tab |
| 1191 | if not inq_contains_cs s tl p_colon_sp |
| 1192 | ret true |
| 1193 | end |
| 1194 | end |
| 1195 | ret false |
| 1196 | end |
| 1197 | |
| 1198 | fn inq_plus_header_allowed off ulong nlen ulong to bool |
| 1199 | ep = get inq_expect_plus 0 |
| 1200 | if eq ep 0 |
| 1201 | ret false |
| 1202 | end |
| 1203 | pos = add off 4 |
| 1204 | rem_l = sub nlen 4 |
| 1205 | if eq ep 2 |
| 1206 | ret inq_is_hdr_path pos rem_l false |
| 1207 | end |
| 1208 | ret inq_is_git_path pos rem_l false |
| 1209 | end |
| 1210 | |
| 1211 | fn inq_minus_is_git_path off ulong nlen ulong to bool |
| 1212 | ret inq_is_git_path add off 4 sub nlen 4 true |
| 1213 | end |
| 1214 | |
| 1215 | fn inq_parse_minus_header off ulong nlen ulong line_no ulong exp_mode ulong to void |
| 1216 | put inq_in_bin 0 0 |
| 1217 | put inq_expect_plus 0 exp_mode |
| 1218 | pos = add off 4 |
| 1219 | rem_l = inq_strip_tab_len pos sub nlen 4 |
| 1220 | inq_norm_to_pbuf pos rem_l |
| 1221 | npl = get inq_pbuf_len 0 |
| 1222 | if or eq npl 0 inq_pb_eq_pat get inq_pbuf_off 0 npl p_dev_null |
| 1223 | ret |
| 1224 | end |
| 1225 | already = false |
| 1226 | if eq get inq_diff_checked 0 1 |
| 1227 | if inq_pb_eq_a |
| 1228 | already = true |
| 1229 | end |
| 1230 | end |
| 1231 | if not already |
| 1232 | inq_clear_active_path |
| 1233 | inq_pb_check_path line_no |
| 1234 | end |
| 1235 | end |
| 1236 | |
| 1237 | fn inq_parse_plus_header off ulong nlen ulong line_no ulong to void |
| 1238 | put inq_in_bin 0 0 |
| 1239 | put inq_expect_plus 0 0 |
| 1240 | if eq get inq_has_git_hdr 0 1 |
| 1241 | put inq_in_git_body 0 1 |
| 1242 | end |
| 1243 | pos = add off 4 |
| 1244 | rem_l = inq_strip_tab_len pos sub nlen 4 |
| 1245 | inq_norm_to_pbuf pos rem_l |
| 1246 | npl = get inq_pbuf_len 0 |
| 1247 | if or eq npl 0 inq_pb_eq_pat get inq_pbuf_off 0 npl p_dev_null |
| 1248 | inq_clear_active_path |
| 1249 | put inq_diff_checked 0 0 |
| 1250 | ret |
| 1251 | end |
| 1252 | already = false |
| 1253 | if eq get inq_diff_checked 0 1 |
| 1254 | if inq_pb_eq_b |
| 1255 | already = true |
| 1256 | end |
| 1257 | end |
| 1258 | inq_pb_set_active |
| 1259 | put inq_diff_checked 0 0 |
| 1260 | if not already |
| 1261 | put inq_files 0 add get inq_files 0 1 |
| 1262 | inq_pb_check_path line_no |
| 1263 | end |
| 1264 | end |
| 1265 | |
| 1266 | fn inq_bin_check_split s ulong sp ulong e ulong line_no ulong primary bool to void |
| 1267 | inq_norm_to_pbuf s sp |
| 1268 | a_ok = and gt get inq_pbuf_len 0 0 not inq_pb_eq_pat get inq_pbuf_off 0 get inq_pbuf_len 0 p_dev_null |
| 1269 | inq_pb_save_a |
| 1270 | dst_s = add s add sp 5 |
| 1271 | inq_norm_to_pbuf dst_s sub e dst_s |
| 1272 | b_ok = and gt get inq_pbuf_len 0 0 not inq_pb_eq_pat get inq_pbuf_off 0 get inq_pbuf_len 0 p_dev_null |
| 1273 | same_ab = and a_ok and b_ok inq_pb_eq_a |
| 1274 | if primary |
| 1275 | if or a_ok b_ok |
| 1276 | put inq_files 0 add get inq_files 0 1 |
| 1277 | end |
| 1278 | if b_ok |
| 1279 | inq_pb_set_active |
| 1280 | else |
| 1281 | if a_ok |
| 1282 | inq_norm_to_pbuf s sp |
| 1283 | inq_pb_set_active |
| 1284 | inq_norm_to_pbuf dst_s sub e dst_s |
| 1285 | end |
| 1286 | end |
| 1287 | end |
| 1288 | if b_ok |
| 1289 | inq_pb_check_path line_no |
| 1290 | end |
| 1291 | if and a_ok not same_ab |
| 1292 | inq_norm_to_pbuf s sp |
| 1293 | inq_pb_check_path line_no |
| 1294 | end |
| 1295 | end |
| 1296 | |
| 1297 | fn inq_bin_exact_mid s ulong e ulong to ulong |
| 1298 | rem_l = sub e s |
| 1299 | if lt rem_l 9 |
| 1300 | ret rem_l |
| 1301 | end |
| 1302 | if ne rem rem_l 2 1 |
| 1303 | ret rem_l |
| 1304 | end |
| 1305 | k = div sub rem_l 9 2 |
| 1306 | if or ne get inq_in s 97 ne get inq_in add s 1 47 |
| 1307 | ret rem_l |
| 1308 | end |
| 1309 | m = add s add 2 k |
| 1310 | if not inq_match_cs m p_sp_and_b |
| 1311 | ret rem_l |
| 1312 | end |
| 1313 | if inq_slice_eq_in add s 2 k add m 7 k |
| 1314 | ret add 2 k |
| 1315 | end |
| 1316 | ret rem_l |
| 1317 | end |
| 1318 | |
| 1319 | fn inq_parse_bin_files off ulong nlen ulong line_no ulong to void |
| 1320 | note Format: "Binary files <src> and <dst> differ" |
| 1321 | put inq_in_bin 0 0 |
| 1322 | put inq_in_hunk 0 0 |
| 1323 | put inq_hunk_has_cnt 0 0 |
| 1324 | put inq_hunk_old 0 0 |
| 1325 | put inq_hunk_new 0 0 |
| 1326 | put inq_expect_plus 0 0 |
| 1327 | put inq_has_git_hdr 0 0 |
| 1328 | put inq_in_git_body 0 0 |
| 1329 | put inq_diff_checked 0 0 |
| 1330 | inq_clear_active_path |
| 1331 | s = add off 13 |
| 1332 | e = add off nlen |
| 1333 | while lt s e bound 131072 |
| 1334 | if eq get inq_in s 32 |
| 1335 | s = add s 1 |
| 1336 | else |
| 1337 | break |
| 1338 | end |
| 1339 | end |
| 1340 | while gt e s bound 131072 |
| 1341 | c = get inq_in sub e 1 |
| 1342 | if or eq c 32 eq c 13 |
| 1343 | e = sub e 1 |
| 1344 | else |
| 1345 | break |
| 1346 | end |
| 1347 | end |
| 1348 | if ge sub e s 7 |
| 1349 | if inq_match_cs sub e 7 p_sp_differ |
| 1350 | e = sub e 7 |
| 1351 | end |
| 1352 | end |
| 1353 | rem_l = sub e s |
| 1354 | if eq rem_l 0 |
| 1355 | ret |
| 1356 | end |
| 1357 | if eq get inq_in s 34 |
| 1358 | qe = inq_find_quote_end s e |
| 1359 | if le add qe 5 e |
| 1360 | if inq_match_cs qe p_sp_and_sp |
| 1361 | inq_bin_check_split s sub qe s e line_no true |
| 1362 | ret |
| 1363 | end |
| 1364 | end |
| 1365 | end |
| 1366 | mid = inq_bin_exact_mid s e |
| 1367 | if lt mid rem_l |
| 1368 | inq_bin_check_split s mid e line_no true |
| 1369 | ret |
| 1370 | end |
| 1371 | if ge rem_l 14 |
| 1372 | if inq_match_cs sub e 14 p_sp_and_dev |
| 1373 | inq_bin_check_split s sub rem_l 14 e line_no true |
| 1374 | ret |
| 1375 | end |
| 1376 | end |
| 1377 | sp_qb = inq_find_substr_cs s rem_l p_sp_and_qb |
| 1378 | if lt sp_qb rem_l |
| 1379 | inq_bin_check_split s sp_qb e line_no true |
| 1380 | ret |
| 1381 | end |
| 1382 | sp_b1 = inq_find_substr_cs s rem_l p_sp_and_b |
| 1383 | if lt sp_b1 rem_l |
| 1384 | sp_b2 = inq_find_substr_last_cs s rem_l p_sp_and_b |
| 1385 | inq_bin_check_split s sp_b2 e line_no true |
| 1386 | if ne sp_b1 sp_b2 |
| 1387 | inq_bin_check_split s sp_b1 e line_no false |
| 1388 | end |
| 1389 | ret |
| 1390 | end |
| 1391 | sp1 = inq_find_substr_cs s rem_l p_sp_and_sp |
| 1392 | if lt sp1 rem_l |
| 1393 | sp2 = inq_find_substr_last_cs s rem_l p_sp_and_sp |
| 1394 | inq_bin_check_split s sp2 e line_no true |
| 1395 | if ne sp1 sp2 |
| 1396 | inq_bin_check_split s sp1 e line_no false |
| 1397 | end |
| 1398 | end |
| 1399 | end |
| 1400 | |
| 1401 | fn inq_read_u64_at pos ulong end_p ulong to void |
| 1402 | digits = ulong 0 |
| 1403 | val = ulong 0 |
| 1404 | p = pos |
| 1405 | while lt p end_p bound 131072 |
| 1406 | c = get inq_in p |
| 1407 | if and ge c 48 le c 57 |
| 1408 | digits = add digits 1 |
| 1409 | if le digits 9 |
| 1410 | val = add mul val 10 ulong sub c 48 |
| 1411 | end |
| 1412 | p = add p 1 |
| 1413 | else |
| 1414 | break |
| 1415 | end |
| 1416 | end |
| 1417 | put inq_num_pos 0 p |
| 1418 | put inq_num_val 0 val |
| 1419 | if and gt digits 0 le digits 9 |
| 1420 | put inq_num_ok 0 1 |
| 1421 | else |
| 1422 | put inq_num_ok 0 0 |
| 1423 | end |
| 1424 | end |
| 1425 | |
| 1426 | fn inq_parse_hunk_hdr off ulong nlen ulong to void |
| 1427 | put inq_in_bin 0 0 |
| 1428 | put inq_expect_plus 0 0 |
| 1429 | if eq get inq_has_git_hdr 0 1 |
| 1430 | put inq_in_git_body 0 1 |
| 1431 | end |
| 1432 | put inq_in_hunk 0 1 |
| 1433 | put inq_hunk_has_cnt 0 0 |
| 1434 | put inq_hunk_old 0 0 |
| 1435 | put inq_hunk_new 0 0 |
| 1436 | p = add off 3 |
| 1437 | end_p = add off nlen |
| 1438 | while lt p end_p bound 131072 |
| 1439 | if eq get inq_in p 32 |
| 1440 | p = add p 1 |
| 1441 | else |
| 1442 | break |
| 1443 | end |
| 1444 | end |
| 1445 | if ge p end_p |
| 1446 | ret |
| 1447 | end |
| 1448 | if ne get inq_in p 45 |
| 1449 | ret |
| 1450 | end |
| 1451 | p = add p 1 |
| 1452 | inq_read_u64_at p end_p |
| 1453 | if eq get inq_num_ok 0 0 |
| 1454 | ret |
| 1455 | end |
| 1456 | p = get inq_num_pos 0 |
| 1457 | old_c = ulong 1 |
| 1458 | if lt p end_p |
| 1459 | if eq get inq_in p 44 |
| 1460 | p = add p 1 |
| 1461 | inq_read_u64_at p end_p |
| 1462 | if eq get inq_num_ok 0 0 |
| 1463 | ret |
| 1464 | end |
| 1465 | old_c = get inq_num_val 0 |
| 1466 | p = get inq_num_pos 0 |
| 1467 | end |
| 1468 | end |
| 1469 | if ge p end_p |
| 1470 | ret |
| 1471 | end |
| 1472 | if ne get inq_in p 32 |
| 1473 | ret |
| 1474 | end |
| 1475 | while lt p end_p bound 131072 |
| 1476 | if eq get inq_in p 32 |
| 1477 | p = add p 1 |
| 1478 | else |
| 1479 | break |
| 1480 | end |
| 1481 | end |
| 1482 | if ge p end_p |
| 1483 | ret |
| 1484 | end |
| 1485 | if ne get inq_in p 43 |
| 1486 | ret |
| 1487 | end |
| 1488 | p = add p 1 |
| 1489 | inq_read_u64_at p end_p |
| 1490 | if eq get inq_num_ok 0 0 |
| 1491 | ret |
| 1492 | end |
| 1493 | p = get inq_num_pos 0 |
| 1494 | new_c = ulong 1 |
| 1495 | if lt p end_p |
| 1496 | if eq get inq_in p 44 |
| 1497 | p = add p 1 |
| 1498 | inq_read_u64_at p end_p |
| 1499 | if eq get inq_num_ok 0 0 |
| 1500 | ret |
| 1501 | end |
| 1502 | new_c = get inq_num_val 0 |
| 1503 | p = get inq_num_pos 0 |
| 1504 | end |
| 1505 | end |
| 1506 | if ge p end_p |
| 1507 | ret |
| 1508 | end |
| 1509 | if ne get inq_in p 32 |
| 1510 | ret |
| 1511 | end |
| 1512 | while lt p end_p bound 131072 |
| 1513 | if eq get inq_in p 32 |
| 1514 | p = add p 1 |
| 1515 | else |
| 1516 | break |
| 1517 | end |
| 1518 | end |
| 1519 | if lt sub end_p p 2 |
| 1520 | ret |
| 1521 | end |
| 1522 | if or ne get inq_in p 64 ne get inq_in add p 1 64 |
| 1523 | ret |
| 1524 | end |
| 1525 | if and eq old_c 0 eq new_c 0 |
| 1526 | ret |
| 1527 | end |
| 1528 | put inq_hunk_old 0 old_c |
| 1529 | put inq_hunk_new 0 new_c |
| 1530 | put inq_hunk_has_cnt 0 1 |
| 1531 | end |
| 1532 | |
| 1533 | fn inq_hunk_step kind ulong to void |
| 1534 | if eq get inq_in_hunk 0 0 |
| 1535 | ret |
| 1536 | end |
| 1537 | if eq get inq_hunk_has_cnt 0 0 |
| 1538 | ret |
| 1539 | end |
| 1540 | old_r = get inq_hunk_old 0 |
| 1541 | new_r = get inq_hunk_new 0 |
| 1542 | if or eq kind 0 eq kind 45 |
| 1543 | if gt old_r 0 |
| 1544 | old_r = sub old_r 1 |
| 1545 | put inq_hunk_old 0 old_r |
| 1546 | end |
| 1547 | end |
| 1548 | if or eq kind 0 eq kind 43 |
| 1549 | if gt new_r 0 |
| 1550 | new_r = sub new_r 1 |
| 1551 | put inq_hunk_new 0 new_r |
| 1552 | end |
| 1553 | end |
| 1554 | if and eq old_r 0 eq new_r 0 |
| 1555 | put inq_in_hunk 0 0 |
| 1556 | put inq_hunk_has_cnt 0 0 |
| 1557 | end |
| 1558 | end |
| 1559 | |
| 1560 | fn inq_try_git_path_hdr off ulong nlen ulong line_no ulong to bool |
| 1561 | if inq_starts_cs off nlen p_ren_from |
| 1562 | inq_norm_to_pbuf add off 12 sub nlen 12 |
| 1563 | inq_pb_check_path line_no |
| 1564 | ret true |
| 1565 | end |
| 1566 | if inq_starts_cs off nlen p_ren_to |
| 1567 | inq_norm_to_pbuf add off 10 sub nlen 10 |
| 1568 | inq_pb_set_active |
| 1569 | inq_pb_check_path line_no |
| 1570 | ret true |
| 1571 | end |
| 1572 | if inq_starts_cs off nlen p_cpy_from |
| 1573 | inq_norm_to_pbuf add off 10 sub nlen 10 |
| 1574 | inq_pb_check_path line_no |
| 1575 | ret true |
| 1576 | end |
| 1577 | if inq_starts_cs off nlen p_cpy_to |
| 1578 | inq_norm_to_pbuf add off 8 sub nlen 8 |
| 1579 | inq_pb_set_active |
| 1580 | inq_pb_check_path line_no |
| 1581 | ret true |
| 1582 | end |
| 1583 | ret false |
| 1584 | end |
| 1585 | |
| 1586 | fn inq_try_git_meta_hdr off ulong nlen ulong to bool |
| 1587 | if or inq_starts_cs off nlen p_hdr_idx inq_starts_cs off nlen p_hdr_omode |
| 1588 | ret true |
| 1589 | end |
| 1590 | if or inq_starts_cs off nlen p_hdr_nmode inq_starts_cs off nlen p_hdr_nfmode |
| 1591 | ret true |
| 1592 | end |
| 1593 | if or inq_starts_cs off nlen p_hdr_dfmode inq_starts_cs off nlen p_hdr_sim |
| 1594 | ret true |
| 1595 | end |
| 1596 | if inq_starts_cs off nlen p_hdr_dis |
| 1597 | ret true |
| 1598 | end |
| 1599 | ret false |
| 1600 | end |
| 1601 | |
| 1602 | fn inq_has_aws_key off ulong nlen ulong to bool |
| 1603 | if lt nlen 20 |
| 1604 | ret false |
| 1605 | end |
| 1606 | lim = add sub nlen 20 1 |
| 1607 | for i ulong lim bound 131072 |
| 1608 | if inq_starts_cs add off i sub nlen i p_akia |
| 1609 | ok = true |
| 1610 | if gt i 0 |
| 1611 | if inq_is_word get inq_in sub add off i 1 |
| 1612 | ok = false |
| 1613 | end |
| 1614 | end |
| 1615 | if ok |
| 1616 | end_i = add i 20 |
| 1617 | if lt end_i nlen |
| 1618 | if inq_is_word get inq_in add off end_i |
| 1619 | ok = false |
| 1620 | end |
| 1621 | end |
| 1622 | end |
| 1623 | if ok |
| 1624 | base = add off add i 4 |
| 1625 | for k ulong 16 |
| 1626 | if not inq_is_upper_alnum get inq_in add base k |
| 1627 | ok = false |
| 1628 | break |
| 1629 | end |
| 1630 | end |
| 1631 | if ok |
| 1632 | ret true |
| 1633 | end |
| 1634 | end |
| 1635 | end |
| 1636 | end |
| 1637 | ret false |
| 1638 | end |
| 1639 | |
| 1640 | fn inq_has_ghp_token off ulong nlen ulong to bool |
| 1641 | if lt nlen 40 |
| 1642 | ret false |
| 1643 | end |
| 1644 | lim = add sub nlen 40 1 |
| 1645 | for i ulong lim bound 131072 |
| 1646 | if inq_starts_cs add off i sub nlen i p_ghp |
| 1647 | ok = true |
| 1648 | if gt i 0 |
| 1649 | if inq_is_word get inq_in sub add off i 1 |
| 1650 | ok = false |
| 1651 | end |
| 1652 | end |
| 1653 | if ok |
| 1654 | run_n = ulong 0 |
| 1655 | idx = add i 4 |
| 1656 | while and lt idx nlen lt run_n 36 bound 36 |
| 1657 | if inq_is_alnum get inq_in add off idx |
| 1658 | run_n = add run_n 1 |
| 1659 | idx = add idx 1 |
| 1660 | else |
| 1661 | break |
| 1662 | end |
| 1663 | end |
| 1664 | if ge run_n 36 |
| 1665 | ret true |
| 1666 | end |
| 1667 | end |
| 1668 | end |
| 1669 | end |
| 1670 | ret false |
| 1671 | end |
| 1672 | |
| 1673 | fn inq_has_gh_fine_pat off ulong nlen ulong to bool |
| 1674 | if lt nlen 61 |
| 1675 | ret false |
| 1676 | end |
| 1677 | if not inq_contains_cs off nlen p_gh_fine |
| 1678 | ret false |
| 1679 | end |
| 1680 | lim = add sub nlen 61 1 |
| 1681 | for i ulong lim bound 131072 |
| 1682 | if inq_starts_cs add off i sub nlen i p_gh_fine |
| 1683 | ok = true |
| 1684 | if gt i 0 |
| 1685 | if inq_is_word get inq_in sub add off i 1 |
| 1686 | ok = false |
| 1687 | end |
| 1688 | end |
| 1689 | if ok |
| 1690 | run_n = ulong 0 |
| 1691 | idx = add i 11 |
| 1692 | while and lt idx nlen lt run_n 50 bound 50 |
| 1693 | if inq_is_word get inq_in add off idx |
| 1694 | run_n = add run_n 1 |
| 1695 | idx = add idx 1 |
| 1696 | else |
| 1697 | break |
| 1698 | end |
| 1699 | end |
| 1700 | if ge run_n 50 |
| 1701 | ret true |
| 1702 | end |
| 1703 | end |
| 1704 | end |
| 1705 | end |
| 1706 | ret false |
| 1707 | end |
| 1708 | |
| 1709 | fn inq_check_secrets off ulong nlen ulong line_no ulong to void |
| 1710 | if inq_has_aws_key off nlen |
| 1711 | inq_record RULE_SECRET SEV_BLOCK line_no SUB_AWS_KEY |
| 1712 | end |
| 1713 | if or inq_has_ghp_token off nlen inq_has_gh_fine_pat off nlen |
| 1714 | inq_record RULE_SECRET SEV_BLOCK line_no SUB_GH_PAT |
| 1715 | end |
| 1716 | if inq_contains_cs off nlen p_pem_rsa |
| 1717 | inq_record RULE_SECRET SEV_BLOCK line_no SUB_PRIV_KEY |
| 1718 | else |
| 1719 | if and inq_contains_cs off nlen p_pem_beg inq_contains_cs off nlen p_pem_end |
| 1720 | inq_record RULE_SECRET SEV_BLOCK line_no SUB_PRIV_KEY |
| 1721 | end |
| 1722 | end |
| 1723 | if not or inq_contains_ci off nlen p_redacted inq_contains_ci off nlen p_vault |
| 1724 | has_asgn = or inq_contains_cs off nlen p_sec_k1 inq_contains_cs off nlen p_sec_k2 |
| 1725 | has_asgn = or has_asgn or inq_contains_cs off nlen p_sec_k3 inq_contains_cs off nlen p_sec_k4 |
| 1726 | if has_asgn |
| 1727 | inq_record RULE_SECRET SEV_BLOCK line_no SUB_SECRET_ASSIGN |
| 1728 | end |
| 1729 | end |
| 1730 | end |
| 1731 | |
| 1732 | fn inq_has_tel_vendor off ulong nlen ulong to bool |
| 1733 | if inq_contains_ci off nlen p_tel1 |
| 1734 | ret true |
| 1735 | end |
| 1736 | if inq_contains_ci off nlen p_tel2 |
| 1737 | ret true |
| 1738 | end |
| 1739 | if inq_contains_ci off nlen p_tel3 |
| 1740 | ret true |
| 1741 | end |
| 1742 | if inq_contains_ci off nlen p_tel4 |
| 1743 | ret true |
| 1744 | end |
| 1745 | if inq_contains_ci off nlen p_tel5 |
| 1746 | ret true |
| 1747 | end |
| 1748 | if inq_contains_ci off nlen p_tel6 |
| 1749 | ret true |
| 1750 | end |
| 1751 | if inq_contains_ci off nlen p_tel7 |
| 1752 | ret true |
| 1753 | end |
| 1754 | if inq_contains_ci off nlen p_tel8 |
| 1755 | ret true |
| 1756 | end |
| 1757 | if inq_contains_ci off nlen p_tel9 |
| 1758 | ret true |
| 1759 | end |
| 1760 | if inq_contains_ci off nlen p_tel10 |
| 1761 | ret true |
| 1762 | end |
| 1763 | if inq_contains_ci off nlen p_tel11 |
| 1764 | ret true |
| 1765 | end |
| 1766 | if inq_contains_ci off nlen p_tel12 |
| 1767 | ret true |
| 1768 | end |
| 1769 | if inq_contains_ci off nlen p_tel13 |
| 1770 | ret true |
| 1771 | end |
| 1772 | ret false |
| 1773 | end |
| 1774 | |
| 1775 | fn inq_tel_is_negated off ulong nlen ulong to bool |
| 1776 | if inq_contains_ci off nlen p_tel_ok1 |
| 1777 | ret true |
| 1778 | end |
| 1779 | if inq_contains_ci off nlen p_tel_ok2 |
| 1780 | ret true |
| 1781 | end |
| 1782 | if inq_contains_ci off nlen p_tel_ok3 |
| 1783 | ret true |
| 1784 | end |
| 1785 | if inq_contains_ci off nlen p_tel_ok4 |
| 1786 | ret true |
| 1787 | end |
| 1788 | if inq_contains_ci off nlen p_tel_ok5 |
| 1789 | ret true |
| 1790 | end |
| 1791 | if inq_contains_ci off nlen p_tel_ok6 |
| 1792 | ret true |
| 1793 | end |
| 1794 | if inq_contains_ci off nlen p_tel_ok7 |
| 1795 | ret true |
| 1796 | end |
| 1797 | if inq_contains_ci off nlen p_tel_ok8 |
| 1798 | ret true |
| 1799 | end |
| 1800 | if inq_contains_ci off nlen p_tel_ok9 |
| 1801 | ret true |
| 1802 | end |
| 1803 | if inq_contains_ci off nlen p_tel_ok10 |
| 1804 | ret true |
| 1805 | end |
| 1806 | ret false |
| 1807 | end |
| 1808 | |
| 1809 | fn inq_check_telemetry off ulong nlen ulong line_no ulong to void |
| 1810 | if inq_has_tel_vendor off nlen |
| 1811 | inq_record RULE_TELEMETRY SEV_BLOCK line_no SUB_TELEM_VENDOR |
| 1812 | ret |
| 1813 | end |
| 1814 | if eq get inq_is_md 0 0 |
| 1815 | if inq_contains_ci off nlen p_tel_raw |
| 1816 | if not inq_tel_is_negated off nlen |
| 1817 | inq_record RULE_TELEMETRY SEV_BLOCK line_no SUB_TELEM_RAW |
| 1818 | end |
| 1819 | end |
| 1820 | end |
| 1821 | end |
| 1822 | |
| 1823 | fn inq_check_stubs off ulong nlen ulong line_no ulong to void |
| 1824 | hard = or inq_contains_ci off nlen p_stub1 inq_contains_ci off nlen p_stub2 |
| 1825 | hard = or hard or inq_contains_ci off nlen p_stub3 inq_contains_ci off nlen p_stub4 |
| 1826 | hard = or hard inq_contains_ci off nlen p_stub5 |
| 1827 | if hard |
| 1828 | inq_record RULE_STUB_HARD SEV_BLOCK line_no SUB_STUB_HARD |
| 1829 | ret |
| 1830 | end |
| 1831 | soft = or inq_contains_ci off nlen p_todo1 inq_contains_ci off nlen p_todo2 |
| 1832 | soft = or soft or inq_contains_ci off nlen p_todo3 inq_contains_ci off nlen p_todo4 |
| 1833 | soft = or soft inq_contains_word_ci off nlen p_todo5 |
| 1834 | if soft |
| 1835 | inq_record RULE_TODO_WARN SEV_WARN line_no SUB_TODO_WARN |
| 1836 | end |
| 1837 | end |
| 1838 | |
| 1839 | fn inq_has_utf8_dash off ulong nlen ulong to bool |
| 1840 | if lt nlen 3 |
| 1841 | ret false |
| 1842 | end |
| 1843 | lim = sub nlen 2 |
| 1844 | for i ulong lim bound 131072 |
| 1845 | b0 = get inq_in add off i |
| 1846 | if eq b0 226 |
| 1847 | b1 = get inq_in add off add i 1 |
| 1848 | if eq b1 128 |
| 1849 | b2 = get inq_in add off add i 2 |
| 1850 | if or eq b2 148 eq b2 147 |
| 1851 | ret true |
| 1852 | end |
| 1853 | end |
| 1854 | end |
| 1855 | end |
| 1856 | ret false |
| 1857 | end |
| 1858 | |
| 1859 | fn inq_check_unslop off ulong nlen ulong line_no ulong to void |
| 1860 | if inq_has_utf8_dash off nlen |
| 1861 | inq_record RULE_UNSLOP_WARN SEV_WARN line_no SUB_UNSLOP_DASH |
| 1862 | end |
| 1863 | bz = or inq_contains_word_ci off nlen p_bz1 inq_contains_word_ci off nlen p_bz2 |
| 1864 | bz = or bz or inq_contains_word_ci off nlen p_bz3 inq_contains_word_ci off nlen p_bz4 |
| 1865 | bz = or bz or inq_contains_word_ci off nlen p_bz5 inq_contains_ci off nlen p_bz6 |
| 1866 | bz = or bz inq_contains_ci off nlen p_bz7 |
| 1867 | if not bz |
| 1868 | if inq_contains_word_ci off nlen p_bz8 |
| 1869 | if not or inq_contains_ci off nlen p_bz8_ok1 inq_contains_ci off nlen p_bz8_ok2 |
| 1870 | bz = true |
| 1871 | end |
| 1872 | end |
| 1873 | end |
| 1874 | if not bz |
| 1875 | if inq_contains_word_ci off nlen p_bz9 |
| 1876 | if not or inq_contains_ci off nlen p_bz9_ok1 inq_contains_ci off nlen p_bz9_ok2 |
| 1877 | bz = true |
| 1878 | end |
| 1879 | end |
| 1880 | end |
| 1881 | if bz |
| 1882 | inq_record RULE_UNSLOP_WARN SEV_WARN line_no SUB_UNSLOP_BUZZ |
| 1883 | end |
| 1884 | end |
| 1885 | |
| 1886 | fn inq_check_dirty_line off ulong nlen ulong line_no ulong to void |
| 1887 | hit = or inq_contains_ci off nlen p_dt1 inq_contains_ci off nlen p_dt2 |
| 1888 | hit = or hit or inq_contains_ci off nlen p_dt3 inq_contains_ci off nlen p_dt4 |
| 1889 | hit = or hit or inq_contains_ci off nlen p_dt5 inq_contains_ci off nlen p_dt6 |
| 1890 | hit = or hit or inq_contains_ci off nlen p_dt7 inq_contains_ci off nlen p_dt8 |
| 1891 | hit = or hit or inq_contains_ci off nlen p_dt9 inq_contains_ci off nlen p_dt10 |
| 1892 | if hit |
| 1893 | inq_record RULE_DIRTY_TREE SEV_BLOCK line_no SUB_DIRTY_TREE |
| 1894 | end |
| 1895 | end |
| 1896 | |
| 1897 | fn inq_check_false_pass off ulong nlen ulong line_no ulong to void |
| 1898 | has_nr = or inq_contains_ci off nlen p_not_run inq_contains_ci off nlen p_skipped |
| 1899 | has_nr = or has_nr or inq_contains_ci off nlen p_blk_hw inq_contains_ci off nlen p_blk_op |
| 1900 | has_nr = or has_nr or inq_contains_ci off nlen p_miss_impl inq_contains_ci off nlen p_zero_tests |
| 1901 | if and has_nr inq_contains_word_ci off nlen p_pass_w |
| 1902 | inq_record RULE_FALSE_PASS SEV_BLOCK line_no SUB_FALSE_PASS_INLINE |
| 1903 | put inq_rec_flagged 0 1 |
| 1904 | ret |
| 1905 | end |
| 1906 | rec_nr = or inq_contains_ci off nlen p_gs_notrun inq_contains_ci off nlen p_tr_zero |
| 1907 | rec_nr = or rec_nr or inq_contains_ci off nlen p_ex_zero inq_contains_ci off nlen p_ts_skip |
| 1908 | rec_nr = or rec_nr or inq_contains_ci off nlen p_ts_notrun inq_contains_ci off nlen p_st_notrun |
| 1909 | if rec_nr |
| 1910 | put inq_seen_notrun 0 1 |
| 1911 | end |
| 1912 | rec_p = or inq_contains_ci off nlen p_v_pass inq_contains_ci off nlen p_c_pass |
| 1913 | rec_p = or rec_p or inq_contains_ci off nlen p_s_pass inq_contains_ci off nlen p_r_pass |
| 1914 | if rec_p |
| 1915 | put inq_seen_pass 0 1 |
| 1916 | end |
| 1917 | if eq get inq_seen_notrun 0 1 |
| 1918 | if eq get inq_seen_pass 0 1 |
| 1919 | if eq get inq_rec_flagged 0 0 |
| 1920 | inq_record RULE_FALSE_PASS SEV_BLOCK line_no SUB_FALSE_PASS_RECORD |
| 1921 | put inq_rec_flagged 0 1 |
| 1922 | end |
| 1923 | end |
| 1924 | end |
| 1925 | end |
| 1926 | |
| 1927 | fn inq_scan_line off ulong nlen ulong line_no ulong to void |
| 1928 | if eq nlen 0 |
| 1929 | put inq_seen_notrun 0 0 |
| 1930 | put inq_seen_pass 0 0 |
| 1931 | put inq_rec_flagged 0 0 |
| 1932 | put inq_expect_plus 0 0 |
| 1933 | if eq get inq_in_hunk 0 1 |
| 1934 | inq_hunk_step 0 |
| 1935 | end |
| 1936 | ret |
| 1937 | end |
| 1938 | if and eq nlen 3 inq_starts_cs off nlen p_rec_sep |
| 1939 | put inq_seen_notrun 0 0 |
| 1940 | put inq_seen_pass 0 0 |
| 1941 | put inq_rec_flagged 0 0 |
| 1942 | put inq_expect_plus 0 0 |
| 1943 | if eq get inq_in_hunk 0 1 |
| 1944 | inq_hunk_step 45 |
| 1945 | end |
| 1946 | ret |
| 1947 | end |
| 1948 | if inq_starts_cs off nlen p_diff_git |
| 1949 | put inq_seen_notrun 0 0 |
| 1950 | put inq_seen_pass 0 0 |
| 1951 | put inq_rec_flagged 0 0 |
| 1952 | inq_parse_diff_git off nlen line_no |
| 1953 | ret |
| 1954 | end |
| 1955 | if inq_starts_cs off nlen p_file_rec |
| 1956 | put inq_in_bin 0 0 |
| 1957 | put inq_in_hunk 0 0 |
| 1958 | put inq_hunk_has_cnt 0 0 |
| 1959 | put inq_expect_plus 0 0 |
| 1960 | put inq_has_git_hdr 0 0 |
| 1961 | put inq_in_git_body 0 0 |
| 1962 | put inq_diff_checked 0 0 |
| 1963 | put inq_files 0 add get inq_files 0 1 |
| 1964 | inq_norm_to_pbuf add off 6 sub nlen 6 |
| 1965 | inq_pb_set_active |
| 1966 | inq_pb_check_path line_no |
| 1967 | ret |
| 1968 | end |
| 1969 | if inq_starts_cs off nlen p_bin_files |
| 1970 | inq_parse_bin_files off nlen line_no |
| 1971 | ret |
| 1972 | end |
| 1973 | if inq_starts_cs off nlen p_git_bin |
| 1974 | put inq_in_bin 0 1 |
| 1975 | put inq_in_hunk 0 0 |
| 1976 | put inq_hunk_has_cnt 0 0 |
| 1977 | put inq_expect_plus 0 0 |
| 1978 | put inq_has_git_hdr 0 0 |
| 1979 | put inq_in_git_body 0 0 |
| 1980 | put inq_diff_checked 0 0 |
| 1981 | ret |
| 1982 | end |
| 1983 | if eq get inq_in_hunk 0 0 |
| 1984 | if inq_starts_cs off nlen p_plus3 |
| 1985 | if inq_plus_header_allowed off nlen |
| 1986 | inq_check_secrets off nlen line_no |
| 1987 | inq_parse_plus_header off nlen line_no |
| 1988 | ret |
| 1989 | end |
| 1990 | end |
| 1991 | if or eq get inq_expect_plus 0 2 eq get inq_expect_plus 0 3 |
| 1992 | put inq_expect_plus 0 0 |
| 1993 | end |
| 1994 | if eq get inq_in_git_body 0 0 |
| 1995 | if inq_starts_cs off nlen p_minus3 |
| 1996 | if inq_is_hdr_path add off 4 sub nlen 4 true |
| 1997 | inq_parse_minus_header off nlen line_no 2 |
| 1998 | ret |
| 1999 | end |
| 2000 | end |
| 2001 | else |
| 2002 | if inq_starts_cs off nlen p_minus3 |
| 2003 | if inq_minus_is_git_path off nlen |
| 2004 | put inq_diff_checked 0 0 |
| 2005 | inq_parse_minus_header off nlen line_no 3 |
| 2006 | ret |
| 2007 | end |
| 2008 | end |
| 2009 | end |
| 2010 | if eq get inq_in_bin 0 0 |
| 2011 | if inq_try_git_path_hdr off nlen line_no |
| 2012 | ret |
| 2013 | end |
| 2014 | if eq get inq_in_git_body 0 0 |
| 2015 | if inq_try_git_meta_hdr off nlen |
| 2016 | ret |
| 2017 | end |
| 2018 | end |
| 2019 | end |
| 2020 | end |
| 2021 | if inq_starts_cs off nlen p_hunk |
| 2022 | inq_parse_hunk_hdr off nlen |
| 2023 | ret |
| 2024 | end |
| 2025 | if inq_starts_cs off nlen p_hunk3 |
| 2026 | put inq_in_bin 0 0 |
| 2027 | put inq_expect_plus 0 0 |
| 2028 | if eq get inq_has_git_hdr 0 1 |
| 2029 | put inq_in_git_body 0 1 |
| 2030 | end |
| 2031 | put inq_in_hunk 0 1 |
| 2032 | put inq_hunk_has_cnt 0 0 |
| 2033 | ret |
| 2034 | end |
| 2035 | if eq get inq_in_bin 0 1 |
| 2036 | ret |
| 2037 | end |
| 2038 | put inq_expect_plus 0 0 |
| 2039 | if eq get inq_has_git_hdr 0 1 |
| 2040 | put inq_in_git_body 0 1 |
| 2041 | end |
| 2042 | first_c = get inq_in off |
| 2043 | if eq get inq_in_hunk 0 1 |
| 2044 | if eq first_c 43 |
| 2045 | inq_hunk_step 43 |
| 2046 | else |
| 2047 | if eq first_c 45 |
| 2048 | inq_hunk_step 45 |
| 2049 | else |
| 2050 | if eq first_c 32 |
| 2051 | inq_hunk_step 0 |
| 2052 | end |
| 2053 | end |
| 2054 | end |
| 2055 | end |
| 2056 | if eq get inq_skip_file 0 1 |
| 2057 | note DRA-440: secrets scanning must never self-exempt spark-inquisitor or constitution.rs |
| 2058 | if eq first_c 43 |
| 2059 | put inq_added 0 add get inq_added 0 1 |
| 2060 | inq_check_secrets off nlen line_no |
| 2061 | end |
| 2062 | ret |
| 2063 | end |
| 2064 | |
| 2065 | note Check dirty-tree and false-PASS metadata on both audit lines and added diff lines |
| 2066 | if ne first_c 45 |
| 2067 | inq_check_dirty_line off nlen line_no |
| 2068 | inq_check_false_pass off nlen line_no |
| 2069 | end |
| 2070 | |
| 2071 | note Added diff lines (+) run full content policy checks |
| 2072 | if eq first_c 43 |
| 2073 | put inq_added 0 add get inq_added 0 1 |
| 2074 | inq_check_secrets off nlen line_no |
| 2075 | inq_check_telemetry off nlen line_no |
| 2076 | inq_check_stubs off nlen line_no |
| 2077 | inq_check_unslop off nlen line_no |
| 2078 | end |
| 2079 | end |
| 2080 | |
| 2081 | fn inq_scan_input to ulong |
| 2082 | inq_reset |
| 2083 | total = get inq_in_len 0 |
| 2084 | h = get inq_hash 0 |
| 2085 | for k ulong total bound 131072 |
| 2086 | h = inq_fnv_step h get inq_in k |
| 2087 | end |
| 2088 | put inq_hash 0 h |
| 2089 | pos = ulong 0 |
| 2090 | line_no = ulong 0 |
| 2091 | while lt pos total bound 131072 |
| 2092 | ls = pos |
| 2093 | while lt pos total bound 131072 |
| 2094 | if eq get inq_in pos 10 |
| 2095 | break |
| 2096 | end |
| 2097 | pos = add pos 1 |
| 2098 | end |
| 2099 | le_pos = pos |
| 2100 | if gt le_pos ls |
| 2101 | if eq get inq_in sub le_pos 1 13 |
| 2102 | le_pos = sub le_pos 1 |
| 2103 | end |
| 2104 | end |
| 2105 | line_no = add line_no 1 |
| 2106 | inq_scan_line ls sub le_pos ls line_no |
| 2107 | if lt pos total |
| 2108 | pos = add pos 1 |
| 2109 | end |
| 2110 | end |
| 2111 | put inq_lines 0 line_no |
| 2112 | note Mix verdict and counts into deterministic receipt fingerprint |
| 2113 | h = inq_fnv_step get inq_hash 0 uchar and get inq_verdict 0 255 |
| 2114 | h = inq_fnv_step h uchar and get inq_blocks 0 255 |
| 2115 | h = inq_fnv_step h uchar and get inq_warns 0 255 |
| 2116 | put inq_hash 0 h |
| 2117 | ret get inq_verdict 0 |
| 2118 | end |
| 2119 | |
| 2120 | fn inq_out_byte b uchar to void |
| 2121 | p = get inq_out_len 0 |
| 2122 | if lt p INQ_MAX_OUT |
| 2123 | put inq_out p b |
| 2124 | put inq_out_len 0 add p 1 |
| 2125 | end |
| 2126 | end |
| 2127 | |
| 2128 | fn inq_out_str s view uchar * to void |
| 2129 | n = len s |
| 2130 | for i ulong n bound 4096 |
| 2131 | inq_out_byte get s i |
| 2132 | end |
| 2133 | end |
| 2134 | |
| 2135 | fn inq_out_u64 v ulong to void |
| 2136 | if eq v 0 |
| 2137 | inq_out_byte 48 |
| 2138 | ret |
| 2139 | end |
| 2140 | buf = new uchar 24 0 |
| 2141 | k = ulong 0 |
| 2142 | x = v |
| 2143 | while gt x 0 bound 24 |
| 2144 | d = rem x 10 |
| 2145 | put buf k uchar add 48 d |
| 2146 | x = div x 10 |
| 2147 | k = add k 1 |
| 2148 | end |
| 2149 | while gt k 0 bound 24 |
| 2150 | k = sub k 1 |
| 2151 | inq_out_byte get buf k |
| 2152 | end |
| 2153 | end |
| 2154 | |
| 2155 | fn inq_out_hex64 v ulong to void |
| 2156 | for i ulong 16 |
| 2157 | sh = mul sub 15 i 4 |
| 2158 | nib = and shr v sh 15 |
| 2159 | inq_out_byte get inq_hex nib |
| 2160 | end |
| 2161 | end |
| 2162 | |
| 2163 | fn inq_out_sev sev ulong to void |
| 2164 | if eq sev SEV_PASS |
| 2165 | inq_out_str j_pass |
| 2166 | ret |
| 2167 | end |
| 2168 | if eq sev SEV_WARN |
| 2169 | inq_out_str j_warn |
| 2170 | ret |
| 2171 | end |
| 2172 | inq_out_str j_block |
| 2173 | end |
| 2174 | |
| 2175 | fn inq_out_rule_name r ulong to void |
| 2176 | if eq r RULE_SECRET |
| 2177 | inq_out_str rn_secret |
| 2178 | ret |
| 2179 | end |
| 2180 | if eq r RULE_ENV_FILE |
| 2181 | inq_out_str rn_env |
| 2182 | ret |
| 2183 | end |
| 2184 | if eq r RULE_PROTECTED_PATH |
| 2185 | inq_out_str rn_path |
| 2186 | ret |
| 2187 | end |
| 2188 | if eq r RULE_DIRTY_TREE |
| 2189 | inq_out_str rn_dirty |
| 2190 | ret |
| 2191 | end |
| 2192 | if eq r RULE_FALSE_PASS |
| 2193 | inq_out_str rn_fpass |
| 2194 | ret |
| 2195 | end |
| 2196 | if eq r RULE_TELEMETRY |
| 2197 | inq_out_str rn_telem |
| 2198 | ret |
| 2199 | end |
| 2200 | if eq r RULE_STUB_HARD |
| 2201 | inq_out_str rn_stub |
| 2202 | ret |
| 2203 | end |
| 2204 | if eq r RULE_TODO_WARN |
| 2205 | inq_out_str rn_todo |
| 2206 | ret |
| 2207 | end |
| 2208 | if eq r RULE_UNSLOP_WARN |
| 2209 | inq_out_str rn_unslop |
| 2210 | ret |
| 2211 | end |
| 2212 | inq_out_str rn_unk |
| 2213 | end |
| 2214 | |
| 2215 | fn inq_out_sub_detail s ulong to void |
| 2216 | if eq s SUB_AWS_KEY |
| 2217 | inq_out_str sd_aws |
| 2218 | ret |
| 2219 | end |
| 2220 | if eq s SUB_GH_PAT |
| 2221 | inq_out_str sd_gh |
| 2222 | ret |
| 2223 | end |
| 2224 | if eq s SUB_PRIV_KEY |
| 2225 | inq_out_str sd_pem |
| 2226 | ret |
| 2227 | end |
| 2228 | if eq s SUB_SECRET_ASSIGN |
| 2229 | inq_out_str sd_assign |
| 2230 | ret |
| 2231 | end |
| 2232 | if eq s SUB_ENV_FILE |
| 2233 | inq_out_str sd_env |
| 2234 | ret |
| 2235 | end |
| 2236 | if eq s SUB_PATH_EVIDENCE |
| 2237 | inq_out_str sd_evid |
| 2238 | ret |
| 2239 | end |
| 2240 | if eq s SUB_PATH_AIEN |
| 2241 | inq_out_str sd_aien |
| 2242 | ret |
| 2243 | end |
| 2244 | if eq s SUB_PATH_GATES |
| 2245 | inq_out_str sd_gates |
| 2246 | ret |
| 2247 | end |
| 2248 | if eq s SUB_PATH_CI |
| 2249 | inq_out_str sd_ci |
| 2250 | ret |
| 2251 | end |
| 2252 | if eq s SUB_PATH_AIEN_TEST |
| 2253 | inq_out_str sd_aient |
| 2254 | ret |
| 2255 | end |
| 2256 | if eq s SUB_DIRTY_TREE |
| 2257 | inq_out_str sd_dirty |
| 2258 | ret |
| 2259 | end |
| 2260 | if eq s SUB_FALSE_PASS_INLINE |
| 2261 | inq_out_str sd_fpi |
| 2262 | ret |
| 2263 | end |
| 2264 | if eq s SUB_FALSE_PASS_RECORD |
| 2265 | inq_out_str sd_fpr |
| 2266 | ret |
| 2267 | end |
| 2268 | if eq s SUB_TELEM_VENDOR |
| 2269 | inq_out_str sd_tv |
| 2270 | ret |
| 2271 | end |
| 2272 | if eq s SUB_TELEM_RAW |
| 2273 | inq_out_str sd_tr |
| 2274 | ret |
| 2275 | end |
| 2276 | if eq s SUB_STUB_HARD |
| 2277 | inq_out_str sd_stub |
| 2278 | ret |
| 2279 | end |
| 2280 | if eq s SUB_TODO_WARN |
| 2281 | inq_out_str sd_todo |
| 2282 | ret |
| 2283 | end |
| 2284 | if eq s SUB_UNSLOP_DASH |
| 2285 | inq_out_str sd_dash |
| 2286 | ret |
| 2287 | end |
| 2288 | if eq s SUB_UNSLOP_BUZZ |
| 2289 | inq_out_str sd_buzz |
| 2290 | ret |
| 2291 | end |
| 2292 | inq_out_str sd_other |
| 2293 | end |
| 2294 | |
| 2295 | fn inq_format_receipt to ulong |
| 2296 | put inq_out_len 0 0 |
| 2297 | inq_out_str j_head |
| 2298 | inq_out_sev get inq_verdict 0 |
| 2299 | inq_out_str j_sev |
| 2300 | inq_out_u64 get inq_verdict 0 |
| 2301 | inq_out_str j_blk |
| 2302 | inq_out_u64 get inq_blocks 0 |
| 2303 | inq_out_str j_wrn |
| 2304 | inq_out_u64 get inq_warns 0 |
| 2305 | inq_out_str j_fil |
| 2306 | inq_out_u64 get inq_files 0 |
| 2307 | inq_out_str j_lin |
| 2308 | inq_out_u64 get inq_lines 0 |
| 2309 | inq_out_str j_add |
| 2310 | inq_out_u64 get inq_added 0 |
| 2311 | inq_out_str j_r_sec |
| 2312 | inq_out_u64 get inq_rcnt RULE_SECRET |
| 2313 | inq_out_str j_r_env |
| 2314 | inq_out_u64 get inq_rcnt RULE_ENV_FILE |
| 2315 | inq_out_str j_r_pth |
| 2316 | inq_out_u64 get inq_rcnt RULE_PROTECTED_PATH |
| 2317 | inq_out_str j_r_dty |
| 2318 | inq_out_u64 get inq_rcnt RULE_DIRTY_TREE |
| 2319 | inq_out_str j_r_fps |
| 2320 | inq_out_u64 get inq_rcnt RULE_FALSE_PASS |
| 2321 | inq_out_str j_r_tel |
| 2322 | inq_out_u64 get inq_rcnt RULE_TELEMETRY |
| 2323 | inq_out_str j_r_stb |
| 2324 | inq_out_u64 get inq_rcnt RULE_STUB_HARD |
| 2325 | inq_out_str j_r_tdo |
| 2326 | inq_out_u64 get inq_rcnt RULE_TODO_WARN |
| 2327 | inq_out_str j_r_uns |
| 2328 | inq_out_u64 get inq_rcnt RULE_UNSLOP_WARN |
| 2329 | inq_out_str j_fp |
| 2330 | inq_out_hex64 get inq_hash 0 |
| 2331 | inq_out_str j_fnd |
| 2332 | fc = get inq_find_cnt 0 |
| 2333 | for i ulong fc bound 128 |
| 2334 | if gt i 0 |
| 2335 | inq_out_str j_comma |
| 2336 | end |
| 2337 | inq_out_str j_f_open |
| 2338 | inq_out_rule_name get inq_find_rule i |
| 2339 | inq_out_str j_f_sev |
| 2340 | inq_out_sev get inq_find_sev i |
| 2341 | inq_out_str j_f_line |
| 2342 | inq_out_u64 get inq_find_line i |
| 2343 | inq_out_str j_f_det |
| 2344 | inq_out_sub_detail get inq_find_sub i |
| 2345 | inq_out_str j_f_close |
| 2346 | end |
| 2347 | inq_out_str j_tail |
| 2348 | ret get inq_out_len 0 |
| 2349 | end |
| 2350 | |
| 2351 | fn inq_write_all fd int total ulong to bool |
| 2352 | sent = ulong 0 |
| 2353 | while lt sent total bound 32768 |
| 2354 | k = write fd inq_out sent sub total sent |
| 2355 | if le k 0 |
| 2356 | ret false |
| 2357 | end |
| 2358 | sent = add sent ulong k |
| 2359 | end |
| 2360 | ret true |
| 2361 | end |