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/apps/core/test.om # omega-mv Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance. Brought by drakestapleton Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / apps / core / test.om` 223 lines ยท 5468 bytes Raw Blame History 1 note SPDX-License-Identifier: Apache-2.0 2 note apps/core/test.om: positive & negative control test suite for 3 note aienos.com site/CSP/consent verifier and interplane-forge/hop core validators. 4 note Compose with: 5 note si/directives/om2.om om/tls/sha2.om apps/core/site_forge.om apps/core/test.om 6 7 text t_pass "PASS " 8 text t_fail "FAIL " 9 text t_nl "\n" 10 11 text t_c1 "aienos_csp_header_validation_and_unsafe_controls" 12 text t_c2 "aienos_route_sanitization_and_traversal_controls" 13 text t_c3 "aienos_consent_and_dnt_fail_closed_controls" 14 text t_c4 "forge_git_ref_validation_and_flag_injection_controls" 15 text t_c5 "forge_archive_extension_allowlist_controls" 16 text t_c6 "hop_frame_kind_cap_and_sequence_controls" 17 text t_c7 "app_manifest_digest_determinism_and_sensitivity" 18 text t_done "PASS apps-site-forge-hop all 7 test suites passed\n" 19 20 text t_csp_ok "default-src 'self'; script-src 'self'; style-src 'self'; object-src 'none'" 21 text t_csp_nodef "script-src 'self'; object-src 'none'" 22 text t_csp_ui "default-src 'self'; script-src 'unsafe-inline'" 23 text t_csp_ue "default-src 'self'; script-src 'unsafe-eval'" 24 text t_csp_star "default-src 'self'; img-src *" 25 text t_csp_http "default-src 'self'; img-src http://example.com" 26 27 text t_rt_ok "/docs/omega/index.html" 28 text t_rt_ok2 "/evidence" 29 text t_rt_trav "/docs/../etc/passwd" 30 text t_rt_dbl "/docs//index.html" 31 text t_rt_hid "/.env" 32 text t_rt_pct "/docs/%2e%2e/secret" 33 text t_rt_rel "docs/index.html" 34 35 text t_ref_ok "main" 36 text t_ref_ok2 "releases/v1.0-alpha" 37 text t_ref_dash "--upload-pack=evil" 38 text t_ref_trav "refs/heads/a..b" 39 text t_ref_lock "refs/heads/main.lock" 40 text t_ref_space "bad ref" 41 text t_ref_tilde "HEAD~1" 42 43 text t_ext_tgz ".tar.gz" 44 text t_ext_zip ".zip" 45 text t_ext_rar ".rar" 46 text t_ext_sh ".sh" 47 48 fn report_case name view uchar * ok bool to int 49 if ok 50 w1 = app_write_all int 1 t_pass 51 w2 = app_write_all int 1 name 52 w3 = app_write_all int 1 t_nl 53 if and w1 and w2 w3 54 ret int 0 55 end 56 ret int 1 57 end 58 w4 = app_write_all int 1 t_fail 59 w5 = app_write_all int 1 name 60 w6 = app_write_all int 1 t_nl 61 if and w4 and w5 w6 62 ret int 1 63 end 64 ret int 1 65 end 66 67 fn test_csp to bool 68 if ne app_validate_csp t_csp_ok APP_OK 69 ret false 70 end 71 if ne app_validate_csp t_csp_nodef APP_ERR_CSP_MISSING_DEFAULT 72 ret false 73 end 74 if ne app_validate_csp t_csp_ui APP_ERR_CSP_UNSAFE 75 ret false 76 end 77 if ne app_validate_csp t_csp_ue APP_ERR_CSP_UNSAFE 78 ret false 79 end 80 if ne app_validate_csp t_csp_star APP_ERR_CSP_UNSAFE 81 ret false 82 end 83 if ne app_validate_csp t_csp_http APP_ERR_CSP_UNSAFE 84 ret false 85 end 86 ret true 87 end 88 89 fn test_routes to bool 90 if ne app_validate_route t_rt_ok APP_OK 91 ret false 92 end 93 if ne app_validate_route t_rt_ok2 APP_OK 94 ret false 95 end 96 if ne app_validate_route t_rt_trav APP_ERR_BAD_ROUTE 97 ret false 98 end 99 if ne app_validate_route t_rt_dbl APP_ERR_BAD_ROUTE 100 ret false 101 end 102 if ne app_validate_route t_rt_hid APP_ERR_BAD_ROUTE 103 ret false 104 end 105 if ne app_validate_route t_rt_pct APP_ERR_BAD_ROUTE 106 ret false 107 end 108 if ne app_validate_route t_rt_rel APP_ERR_BAD_ROUTE 109 ret false 110 end 111 ret true 112 end 113 114 fn test_consent to bool 115 if ne app_check_consent false false true APP_OK 116 ret false 117 end 118 if ne app_check_consent true true false APP_OK 119 ret false 120 end 121 note Negative controls: analytics without consent, or analytics with DNT=1 122 if ne app_check_consent true false false APP_ERR_CONSENT_VIOLATION 123 ret false 124 end 125 if ne app_check_consent true true true APP_ERR_CONSENT_VIOLATION 126 ret false 127 end 128 ret true 129 end 130 131 fn test_forge_refs to bool 132 if ne forge_validate_ref t_ref_ok APP_OK 133 ret false 134 end 135 if ne forge_validate_ref t_ref_ok2 APP_OK 136 ret false 137 end 138 if ne forge_validate_ref t_ref_dash APP_ERR_BAD_REF 139 ret false 140 end 141 if ne forge_validate_ref t_ref_trav APP_ERR_BAD_REF 142 ret false 143 end 144 if ne forge_validate_ref t_ref_lock APP_ERR_BAD_REF 145 ret false 146 end 147 if ne forge_validate_ref t_ref_space APP_ERR_BAD_REF 148 ret false 149 end 150 if ne forge_validate_ref t_ref_tilde APP_ERR_BAD_REF 151 ret false 152 end 153 ret true 154 end 155 156 fn test_forge_exts to bool 157 if ne forge_validate_ext t_ext_tgz APP_OK 158 ret false 159 end 160 if ne forge_validate_ext t_ext_zip APP_OK 161 ret false 162 end 163 if ne forge_validate_ext t_ext_rar APP_ERR_BAD_EXT 164 ret false 165 end 166 if ne forge_validate_ext t_ext_sh APP_ERR_BAD_EXT 167 ret false 168 end 169 ret true 170 end 171 172 fn test_hop_frames to bool 173 if ne hop_validate_frame HOP_KIND_DATA ulong 1024 ulong 4096 ulong 1 ulong 2 APP_OK 174 ret false 175 end 176 if ne hop_validate_frame ulong 0 ulong 10 ulong 4096 ulong 1 ulong 2 APP_ERR_FRAME_KIND 177 ret false 178 end 179 if ne hop_validate_frame HOP_KIND_DATA ulong 4097 ulong 4096 ulong 1 ulong 2 APP_ERR_FRAME_CAP 180 ret false 181 end 182 if ne hop_validate_frame HOP_KIND_DATA ulong 10 ulong 4096 ulong 5 ulong 5 APP_ERR_FRAME_SEQ 183 ret false 184 end 185 if ne hop_validate_frame HOP_KIND_DATA ulong 10 ulong 4096 ulong 5 ulong 4 APP_ERR_FRAME_SEQ 186 ret false 187 end 188 ret true 189 end 190 191 fn test_manifest_digest to bool 192 d1 = new uchar 32 0 193 d2 = new uchar 32 0 194 app_manifest_digest t_rt_ok t_csp_ok d1 195 app_manifest_digest t_rt_ok t_csp_ok d2 196 if not app_digest_eq d1 d2 197 ret false 198 end 199 app_manifest_digest t_rt_ok2 t_csp_ok d2 200 if app_digest_eq d1 d2 201 ret false 202 end 203 ret true 204 end 205 206 fn main to int 207 fail = int 0 208 fail = add fail report_case t_c1 test_csp 209 fail = add fail report_case t_c2 test_routes 210 fail = add fail report_case t_c3 test_consent 211 fail = add fail report_case t_c4 test_forge_refs 212 fail = add fail report_case t_c5 test_forge_exts 213 fail = add fail report_case t_c6 test_hop_frames 214 fail = add fail report_case t_c7 test_manifest_digest 215 if ne fail int 0 216 ret int 1 217 end 218 ok = app_write_all int 1 t_done 219 if not ok 220 ret int 1 221 end 222 ret int 0 223 end