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/aienos.com/blob/main/om/site/csp.om # aienos.com Source of www.aienos.com, served from my own hardware Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienos.com / om / site / csp.om` 264 lines ยท 6996 bytes Raw Blame History 1 note Page-level Content-Security-Policy, as main's components::csp. The site is served by SiteHub on 2 note Drake's own hardware, and every emitted HTML page carries the policy as a meta right after (after a leading 3 note ). The policy is derived from what the page loads: WebAssembly scripts get 4 note 'wasm-unsafe-eval', the blob-worker script gets worker-src blob:, YouTube embeds may be framed. 5 note aien/run.html is the one document whose policy allows inline scripts; it loads only aien-run.js. 6 note sk_all runs last: it reads every written page back, inserts the meta and rewrites the page. 7 text skrunf "aien/run.html" 8 text skrunh "Program runner | AienOS

Aien home Follow me on X

This document runs programs Aien writes, inside a sandboxed frame on aienos.com/aien/.

\n" 9 text skopen "" 11 text skgt ">" 12 text skhead "\n" 26 text SK0002 "site: csp: cannot read the dist tree\n" 27 global skdepth ulong 1 28 29 fn sk_runner to void 30 st_open skrunf 31 sr_raw skrunh 32 sr_close 33 end 34 35 note sk_find: first index of pat in s[from..n), or n. Chunked so no loop passes 65537 times. 36 fn sk_find s view uchar * n ulong pat view uchar * from ulong to ulong 37 if or eq len pat 0 gt len pat n 38 ret n 39 end 40 last = sub n len pat 41 if gt from last 42 ret n 43 end 44 i = from 45 for c ulong 256 46 stop = add i 65536 47 if gt stop add last 1 48 stop = add last 1 49 end 50 while lt i stop bound 65537 51 if eq get s i get pat 0 52 if sr_equal part s i len pat pat 53 ret i 54 end 55 end 56 i = add i 1 57 end 58 if gt i last 59 ret n 60 end 61 end 62 ret n 63 end 64 65 fn sk_loads s view uchar * n ulong pat view uchar * to bool 66 ret lt sk_find s n pat 0 n 67 end 68 69 fn sk_space c uchar to bool 70 if or eq c 32 eq c 9 71 ret true 72 end 73 ret or eq c 10 eq c 13 74 end 75 76 note sk_at: main's insertion_point, past and a leading . 77 fn sk_at s view uchar * n ulong to ulong 78 h = sk_find s n skhead 0 79 if eq h n 80 st_fail SK0001 81 end 82 g = sk_find s n skgt h 83 if eq g n 84 st_fail SK0001 85 end 86 ins = add g 1 87 p = ins 88 while lt p n bound 4096 89 if not sk_space get s p 90 break 91 end 92 p = add p 1 93 end 94 if le add p len skchar n 95 if sr_equal part s p len skchar skchar 96 g = sk_find s n skgt p 97 if eq g n 98 st_fail SK0001 99 end 100 ins = add g 1 101 end 102 end 103 ret ins 104 end 105 106 fn sk_policy s view uchar * n ulong to void 107 if sk_loads s n skrs 108 sr_raw skrunp 109 ret 110 end 111 sr_raw skp0 112 if or or sk_loads s n skhive sk_loads s n skallen sk_loads s n skscene 113 sr_raw skwasm 114 end 115 sr_raw skp1 116 if sk_loads s n skallen 117 sr_raw skblob 118 end 119 if sk_loads s n skyts 120 sr_raw skyt 121 end 122 end 123 124 fn sk_page path view uchar * buf edit uchar * to void 125 fd = fopen path 0 len path 0 0 126 if lt fd 0 127 sr_fail sreop 128 end 129 n = ulong 0 130 while true bound 4096 131 k = read int fd buf n sub len buf n 132 if lt k 0 133 sr_fail srerd 134 end 135 if eq k 0 136 break 137 end 138 n = add n ulong k 139 if eq n len buf 140 sr_fail srebo 141 end 142 end 143 sr_fclose int fd 144 if sk_loads buf n skopen 145 ret 146 end 147 ins = sk_at buf n 148 sr_open path 149 sr_bytes buf 0 ins 150 sr_raw skopen 151 sk_policy buf n 152 sr_raw skq 153 sr_bytes buf ins sub n ins 154 sr_close 155 end 156 157 note sk_entry: one child path; views take two parameter slots, so the path arrives built. 158 fn sk_entry path view uchar * buf edit uchar * to void 159 statbuf = new uchar 128 0 160 r = lstat path 0 len path statbuf 0 len statbuf 161 if lt r 0 162 trap 10 163 end 164 mode = and or uint get statbuf 16 shl uint get statbuf 17 8 61440 165 if eq mode 16384 166 sk_tree path buf 167 else 168 if and eq mode 32768 sx_html path 169 sk_page path buf 170 end 171 end 172 end 173 174 note sk_name: the getdents64 record's name length, or 0 for a name the walk skips. 175 fn sk_name entry view uchar * to ulong 176 if lt len entry 20 177 trap 10 178 end 179 n = ulong 19 180 while lt n len entry bound 4096 181 if eq get entry n 0 182 break 183 end 184 n = add n 1 185 end 186 if eq n len entry 187 trap 10 188 end 189 if sx_private part entry 19 sub n 19 190 ret 0 191 end 192 ret sub n 19 193 end 194 195 note sk_size: the size of the getdents64 record at the start of rest, checked against rest. 196 fn sk_size rest view uchar * to ulong 197 if lt len rest 20 198 trap 10 199 end 200 size = ulong get rest 16 201 size = or size shl ulong get rest 17 8 202 if or lt size 20 gt size len rest 203 trap 10 204 end 205 ret size 206 end 207 208 fn sk_join child edit uchar * path view uchar * name view uchar * to ulong 209 m = st_append child path 0 210 m = st_append child stslash m 211 ret st_append child name m 212 end 213 214 fn sk_record path view uchar * entry view uchar * buf edit uchar * to void 215 child = new uchar 8192 0 216 nl = sk_name entry 217 if gt nl 0 218 m = sk_join child path part entry 19 nl 219 sk_entry part child 0 m buf 220 end 221 end 222 223 note sk_tree: the walk depth lives in skdepth, keeping each call within six parameter slots. 224 fn sk_tree path view uchar * buf edit uchar * to void 225 entries = new uchar 65536 0 226 put skdepth 0 add get skdepth 0 1 227 if gt get skdepth 0 17 228 trap 3 229 end 230 fd = fopen path 0 len path 16384 0 231 if lt fd 0 232 st_fail SK0002 233 end 234 while true bound 65536 235 n = getdnts int fd entries 0 len entries 236 if lt n 0 237 trap 10 238 end 239 if eq n 0 240 break 241 end 242 p = ulong 0 243 while lt p ulong n bound 4096 244 size = sk_size part entries p sub ulong n p 245 sk_record path part entries p size buf 246 p = add p size 247 end 248 end 249 r = fclose int fd 250 if ne r 0 251 trap 10 252 end 253 put skdepth 0 sub get skdepth 0 1 254 end 255 256 fn sk_all to void 257 pathbuf = new uchar 8192 0 258 buf = new uchar `2097152` 0 259 n = get stoutn 0 260 for i ulong n 261 put pathbuf i get stout i 262 end 263 sk_tree part pathbuf 0 n buf 264 end