interplane.Get Omega
Read in your language

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

branch main Branches Tags History

omega-mv / apps / interplane-forge / quiet / qn3http.om

701 lines · 11012 bytes Raw Blame History
1note quiet/qn3http.om: /notifications, /notifications.json, the patch receipt section and .receipt JSON.
2note qnpage only reads a digest file. qnregen runs from qnpost and from forge-contribute.
3text tqnrel "notifications"
4text tqjv "{\"format\":\"FORGE-EVIDENCE\",\"v\":1,\"verify\":\""
5text tqjv2 "\",\"reason\":\""
6text tqjv3 "\",\"commit\":\""
7text tqjv4 "\",\"tree\":\""
8text tqjv5 "\",\"rc\":"
9text tqjv6 ",\"out\":\""
10text tqjv7 "\",\"agent\":\""
11text tqjv8 "\",\"cmd\":\""
12text tqempty "{\"format\":\"QUIET-DIGEST\",\"v\":1,\"quiet\":true,\"count\":0}\n"
13text tqjd1 "{\"format\":\"QUIET-DIGEST\",\"v\":1,\"quiet\":false,\"count\":"
14text tqjd2 ",\"body\":\""
15text tqnt "Notifications"
16text tqnp "/notifications"
17text tqnj "/notifications.json"
18text tqrsuf ".receipt"
19text tqrevp "rev-parse"
20text tqtree "^{tree}"
21text tqlogin "login"
22text tqjson "application/json"
23text tqpass "PASS"
24text tqref "REFUSED"
25text tqmiss "missing"
26text tqred "redacted"
27text tqpar "parse"
28text tqbind "bind"
29text tqcom "commit"
30text tqtreer "tree"
31text tqnull "null"
32text tqagent "agent"
33text tqrepo "repo"
34text tqdash "-"
35text tqh1 "<section class=\"box\"><h2>Evidence receipt</h2>\n"
36text tqh2 "<p class=\"meta\">verify "
37text tqh3 "</p>\n<p>commit <code>"
38text tqh4 "</code></p>\n<p>tree <code>"
39text tqh5 "</code></p>\n<p>command <code>"
40text tqh6 "</code></p>\n<p>exit <code>"
41text tqh7 "</code> &#183; output sha256 <code>"
42text tqh8 "</code></p>\n<p>agent <code>"
43text tqh9 "</code></p>\n<p><a href=\""
44text tqha "\">machine-checkable receipt</a></p>\n</section>\n"
45text tqhb "<p class=\"muted\">No evidence receipt on this patch. The machine-checkable link still answers, and it refuses.</p>\n<p><a href=\""
46text tqok1 "<b class=\"ok\">"
47text tqbad "<b class=\"bad\">"
48text tqbe "</b>"
49text tqnp1 "<section class=\"box\"><h2>Notifications</h2>\n<p class=\"muted\">Quiet by default. One digest, written when you save a filter or when a patch event arrives. Opening this page does not write a digest.</p>\n"
50text tqnp2 "<pre class=\"hit\">"
51text tqnp3 "</pre>\n"
52text tqnp4 "<p class=\"muted\">No digest file. Nothing is listed.</p>\n"
53text tqfm1 "<form class=\"so-form\" method=\"post\" action=\""
54text tqfm2 "\"><input type=\"hidden\" name=\"csrf\" value=\""
55text tqfm3 "\">\n<label>Agent <input name=\"agent\" maxlength=\"39\" required></label>\n<label>Repo <input name=\"repo\" maxlength=\"39\" required></label>\n<button class=\"so-btn\" type=\"submit\">Save filter</button></form>\n<p class=\"muted\">Use * for any. Put - in either field to go quiet again.</p>\n</section>\n"
56text tqwhy "Set a display name of letters, digits and hyphens before saving a filter."
57text tqbadf "Agent and repo use letters, digits, hyphens, or * . - clears the filter."
58global qnhd uchar 40
59global qndig uchar 8192
60global qndigl ulong 1
61global qnba uchar 40
62global qnbal ulong 1
63global qnbr uchar 40
64global qnbrl ulong 1
65global qnbuf uchar 8192
66global qnbl ulong 1
67global qnbov ulong 1
68fn qnends a ulong n ulong to bool
69if le n add a 8
70ret false
71end
72s = sub n 8
73for i ulong 8
74if ne get frest add s i get tqrsuf i
75ret false
76end
77end
78ret true
79end
80fn qnload to void
81put qnrcl 0 0
82put qnst 0 0
83if eq get gcrn 0 0
84ret
85end
86r = sub get gcrn 0 1
87for i ulong 40
88put qnhd i get gcro add mul r 40 i
89end
90if eq get gcrx r 1
91put qnst 0 1
92ret
93end
94o = get gcrd mul r 2
95n = get gcrd add mul r 2 1
96if gt n 1024
97n = ulong 1024
98end
99for i ulong n bound 1024
100put qnrc i get gcpool add o i
101end
102put qnrcl 0 n
103end
104fn qnheq to bool
105for i ulong 40
106if ne get qncm i get qnhd i
107ret false
108end
109end
110ret true
111end
112fn qngitree to bool
113fkgit
114fka tqrevp
115fkopen
116for i ulong 40
117fkc get qnhd i
118end
119fkt tqtree
120r = fexec 5000000000
121if ne r 0
122ret false
123end
124if lt get fxol 0 40
125ret false
126end
127for i ulong 40
128if ne get fxo i get qntr i
129ret false
130end
131end
132ret true
133end
134fn qncheck to void
135qnload
136if eq get qnst 0 1
137ret
138end
139if not qnparse
140ret
141end
142if not qnbindok
143ret
144end
145if not qnheq
146put qnst 0 4
147ret
148end
149if not qngitree
150put qnst 0 5
151ret
152end
153put qnst 0 6
154end
155fn qnwhy to void
156s = get qnst 0
157if eq s 6
158fput tqpass
159ret
160end
161if eq s 0
162fput tqmiss
163ret
164end
165if eq s 1
166fput tqred
167ret
168end
169if eq s 2
170fput tqpar
171ret
172end
173if eq s 3
174fput tqbind
175ret
176end
177if eq s 4
178fput tqcom
179ret
180end
181fput tqtreer
182end
183fn qnlink to void
184fputb
185fputrepo
186fput tcpats
187fputc 47
188for i ulong get gcrql 0 bound 40
189fescc get gcrq i
190end
191fput tqrsuf
192end
193fn qnshow to void
194qncheck
195fput tqh1
196fput tqh2
197if eq get qnst 0 6
198fput tqok1
199fput tqpass
200fput tqbe
201end
202if ne get qnst 0 6
203fput tqbad
204fput tqref
205fputc 32
206qnwhy
207fput tqbe
208end
209fput tqh3
210if gt get qnst 0 2
211for i ulong 40
212fescc get qncm i
213end
214end
215fput tqh4
216if gt get qnst 0 2
217for i ulong 40
218fescc get qntr i
219end
220end
221fput tqh5
222if gt get qnst 0 2
223for i ulong get qncmdl 0 bound 200
224fescc get qncmd i
225end
226end
227fput tqh6
228if gt get qnst 0 2
229fnum get qnrcn 0
230end
231fput tqh7
232if gt get qnst 0 2
233for i ulong 64
234fescc get qnout64 i
235end
236end
237fput tqh8
238if gt get qnst 0 2
239for i ulong get qnagl 0 bound 40
240fescc get qnag i
241end
242end
243fput tqh9
244qnlink
245fput tqha
246end
247fn qnjesc c uchar to void
248if eq c 34
249fputc 92
250fputc 34
251ret
252end
253if eq c 92
254fputc 92
255fputc 92
256ret
257end
258if or lt c 32 eq c 127
259fputc 63
260ret
261end
262fputc c
263end
264fn qnjson to void
265put fkind 0 1
266fsetct tqjson
267fput tqjv
268if eq get qnst 0 6
269fput tqpass
270end
271if ne get qnst 0 6
272fput tqref
273end
274fput tqjv2
275qnwhy
276fput tqjv3
277if gt get qnst 0 2
278for i ulong 40
279fputc get qncm i
280end
281end
282fput tqjv4
283if gt get qnst 0 2
284for i ulong 40
285fputc get qntr i
286end
287end
288fput tqjv5
289if gt get qnst 0 2
290fnum get qnrcn 0
291end
292if le get qnst 0 2
293fput tqnull
294end
295fput tqjv6
296if gt get qnst 0 2
297for i ulong 64
298fputc get qnout64 i
299end
300end
301fput tqjv7
302if gt get qnst 0 2
303for i ulong get qnagl 0 bound 40
304qnjesc get qnag i
305end
306end
307fput tqjv8
308if gt get qnst 0 2
309for i ulong get qncmdl 0 bound 200
310qnjesc get qncmd i
311end
312end
313fputc 34
314fputc 125
315fputc 10
316end
317fn qnraw to long
318if eq corefs 1 false
319ret 500
320end
321if eq coresolve false
322ret 404
323end
324if eq coload 1 false
325ret 404
326end
327if ne get gcov 0 0
328fincut
329ret 500
330end
331qncheck
332qnjson
333ret 200
334end
335fn qnsess to long
336x = sosess
337ret x
338end
339fn qnpage js ulong to long
340x = sosess
341if eq get fuserl 0 0
342if eq js 1
343put fkind 0 1
344fsetct tqjson
345fput tqempty
346ret 401
347end
348put fkind 0 2
349flocb
350floct tqlogin
351ret 303
352end
353qnsetg
354qnpfx tqod
355for i ulong get fuserl 0 bound 64
356fpc get fuser i
357end
358put qndigl 0 0
359if qnread
360n = get fxol 0
361if gt n 8192
362n = ulong 8192
363end
364for i ulong n bound 8192
365put qndig i get fxo i
366end
367put qndigl 0 n
368end
369if eq js 1
370ret qnjd
371end
372fsetti tqnt
373fput tqnp1
374if eq get qndigl 0 0
375fput tqnp4
376end
377if gt get qndigl 0 0
378fput tqnp2
379for i ulong get qndigl 0 bound 8192
380fescc get qndig i
381end
382fput tqnp3
383end
384fput tqfm1
385fputb
386fput tqnrel
387fput tqfm2
388socsrfout
389fput tqfm3
390ret 200
391end
392fn qnjd to long
393put fkind 0 1
394fsetct tqjson
395if eq get qndigl 0 0
396fput tqempty
397ret 200
398end
399fput tqjd1
400c = qncount
401fnum c
402fput tqjd2
403for i ulong get qndigl 0 bound 8192
404qnjesc get qndig i
405end
406fputc 34
407fputc 125
408fputc 10
409ret 200
410end
411fn qncount to ulong
412n = ulong 0
413head = true
414p = ulong 0
415while lt p get qndigl 0 bound 8192
416c = get qndig p
417if and head and ge c 48 le c 57
418n = add n 1
419end
420head = eq c 10
421p = add p 1
422end
423ret n
424end
425fn qntok1 c uchar to bool
426if and ge c 48 le c 57
427ret true
428end
429if and ge c 97 le c 122
430ret true
431end
432if eq c 45
433ret true
434end
435if eq c 42
436ret true
437end
438ret false
439end
440fn qnokb w ulong i ulong to uchar
441if eq w 1
442ret get qnbr i
443end
444ret get qnba i
445end
446fn qnokg w ulong to bool
447n = get qnbal 0
448if eq w 1
449n = get qnbrl 0
450end
451if or eq n 0 gt n 39
452ret false
453end
454if and eq n 1 eq (qnokb w 0) 45
455ret true
456end
457for i ulong n bound 39
458if not qntok1 (qnokb w i)
459ret false
460end
461end
462ret true
463end
464fn qnfok to bool
465n = get fuserl 0
466if or eq n 0 gt n 39
467ret false
468end
469for i ulong n bound 39
470c = get fuser i
471ok = false
472if and ge c 48 le c 57
473ok = true
474end
475if and ge c 97 le c 122
476ok = true
477end
478if eq c 45
479ok = true
480end
481if not ok
482ret false
483end
484end
485ret true
486end
487fn qnpost to long
488x = sosess
489r = sowpre
490if ne r 0
491ret r
492end
493if not qnfok
494fsetti tqnt
495fput tqwhy
496ret 400
497end
498note fbget gives up to 4096 bytes; qnba and qnbr hold 40 and the copy loops are bounded at 40, so a
499note length outside 0..39 is refused here, before it is stored or copied (41 was trap 4, exit 104).
500note qnokg still checks the bytes.
501al = fbget tqagent
502if lt al 0
503ret 400
504end
505if gt al 39
506fsetti tqnt
507fput tqbadf
508ret 400
509end
510put qnbal 0 ulong al
511for i ulong get qnbal 0 bound 40
512put qnba i get fval i
513end
514rl = fbget tqrepo
515if lt rl 0
516ret 400
517end
518if gt rl 39
519fsetti tqnt
520fput tqbadf
521ret 400
522end
523put qnbrl 0 ulong rl
524for i ulong get qnbrl 0 bound 40
525put qnbr i get fval i
526end
527if not qnokg 0
528fsetti tqnt
529fput tqbadf
530ret 400
531end
532if not qnokg 1
533fsetti tqnt
534fput tqbadf
535ret 400
536end
537qnsetg
538if not qnsubw
539ret 500
540end
541if not qnregen
542ret 500
543end
544put fkind 0 2
545flocb
546floct tqnrel
547ret 303
548end
549fn qnsubw to bool
550qnmk
551qnpfx tqsb
552qnsubrd
553qnsubfit
554if not qndrop
555qnsubadd
556end
557note a full subscription file is refused, never cut: a cut would drop other names' filters
558if eq get qnbov 0 1
559ret false
560end
561ret qnsubsv
562end
563fn qnsubrd to void
564put qnsl 0 0
565if not qnread
566ret
567end
568n = get fxol 0
569if gt n 8192
570n = ulong 8192
571end
572for i ulong n bound 8192
573put qnsub i get fxo i
574end
575put qnsl 0 n
576end
577fn qnsubfit to void
578put qnbl 0 0
579put qnbov 0 0
580p = ulong 0
581while lt p get qnsl 0 bound 8192
582e = qnsube p
583if not qnuserline p e
584qnsubcopy p e
585end
586if lt e get qnsl 0
587p = add e 1
588end
589if ge e get qnsl 0
590p = e
591end
592end
593end
594fn qnsube p ulong to ulong
595e = p
596while lt e get qnsl 0 bound 8192
597if eq get qnsub e 10
598break
599end
600e = add e 1
601end
602ret e
603end
604note qnsubcopy: a line of another name is kept as it is. Its length is at most len qnsub = 8192
605note (qnsubrd), so the bound is 8192; forged writes lines of at most 119 bytes, and a longer line in
606note a hand-edited file used to pass the old bound of 256 (trap 4).
607fn qnsubcopy p ulong e ulong to void
608for i ulong sub e p bound 8192
609qnbbc get qnsub add p i
610end
611if lt e get qnsl 0
612qnbbc 10
613end
614end
615fn qnbbc c uchar to void
616n = get qnbl 0
617if lt n 8191
618put qnbuf n c
619put qnbl 0 add n 1
620end
621if ge n 8191
622put qnbov 0 1
623end
624end
625fn qndrop to bool
626if and eq get qnbal 0 1 eq get qnba 0 45
627ret true
628end
629ret and eq get qnbrl 0 1 eq get qnbr 0 45
630end
631fn qnsubadd to void
632for i ulong get fuserl 0 bound 40
633qnbbc get fuser i
634end
635qnbbc 32
636for i ulong get qnbal 0 bound 40
637qnbbc get qnba i
638end
639qnbbc 32
640for i ulong get qnbrl 0 bound 40
641qnbbc get qnbr i
642end
643qnbbc 10
644end
645fn qnsubsv to bool
646fd = fopen fpth 0 get fpthl 0 524865 384
647if lt fd 0
648ret false
649end
650off = ulong 0
651left = get qnbl 0
652ok = true
653while gt left 0 bound 8192
654k = write int fd qnbuf off left
655if le k 0
656ok = false
657left = ulong 0
658end
659if gt k 0
660off = add off ulong k
661left = sub left ulong k
662end
663end
664x = fsync int fd
665x = fclose int fd
666ret ok
667end
668fn qnuserline p ulong e ulong to bool
669n = get fuserl 0
670if lt sub e p n
671ret false
672end
673for i ulong n bound 40
674if ne get qnsub add p i get fuser i
675ret false
676end
677end
678if eq sub e p n
679ret true
680end
681ret eq get qnsub add p n 32
682end
683fn qnroute to long
684m = get fmeth 0
685if fpeq tqnp
686if eq m 3
687ret qnpost
688end
689if eq m 1
690ret qnpage 0
691end
692ret 405
693end
694if fpeq tqnj
695if eq m 1
696ret qnpage 1
697end
698ret 405
699end
700ret 0
701end