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 / seed / qualification / security673 / branch-mutate.om

184 lines · 4474 bytes Raw Blame History
1note Exact-source qualification transform: argv1 picks one exact-once substitution in stdin, written to stdout.
2note Mode0 renames the real main and appends a probe main that calls the real bdisp and emit. Mode1 weakens
3note the forward limit by two instructions; mode2 makes close_range unavailable; mode3 admits 21-digit numbers;
4note mode4 and mode5 bypass the exec filter and fence words; mode6 weakens the backward limit by two; mode7
5note removes the range test (alignment kept). Modes compose: mode7 then mode0 probes the range-free encoder.
6note No transformed artifact is a production compiler.
7global src uchar 1048576
8global used ulong 1
9global rlen ulong 1
10global mode uchar 8
11global needle uchar 64
12global repl uchar 64
13text entry "fn main to int"
14text renamed "fn prev to int"
15text fwd "gt diff sub span 4"
16text fwdweak "gt diff add span 4"
17text bwd "lt diff sub ulong 0 span"
18text bwdweak "lt diff sub ulong 0 add span 8"
19text range "if and gt diff sub span 4 lt diff sub ulong 0 span"
20text norange "if false"
21text seal "hsys 436"
22text noseal "hsys 999"
23text digits "if gt ndig 20"
24text longer "if gt ndig 21"
25text filter "hsys 277"
26text fence "hsys 446"
27text bypass "hsys 172"
28text probe "\nfn main to int\nn = read 0 msg 0 1\nif ne n 1\nret 90\nend\nm = get msg 0\nif ge m 18\nret 90\nend\nif ge m 16\na_init\nput oc 0 8388604\nif eq m 17\nput oc 0 134217728\nend\nemit 0\nif eq m 17\nret 81\nend\nret 0\nend\na = ulong 0\nt = ulong 0\ne = ulong 0\nwd = ulong 19\nif ne and m 4 0\nwd = ulong 26\nend\nif eq m 0\nt = ulong 1048572\ne = ulong 262143\nend\nif eq m 1\na = ulong 1048576\ne = ulong 262144\nend\nif eq m 2\na = ulong 1024\ne = ulong 524032\nend\nif eq m 3\na = ulong 1028\ne = ulong 524031\nend\nif eq m 4\nt = ulong 134217724\ne = ulong 33554431\nend\nif eq m 5\na = ulong 134217728\ne = ulong 33554432\nend\nif eq m 6\na = ulong 1024\ne = ulong 67108608\nend\nif eq m 7\na = ulong 1028\ne = ulong 67108607\nend\nif eq m 8\nt = ulong 1048576\nend\nif eq m 9\na = ulong 1048580\nend\nif eq m 10\nt = ulong 2\nend\nif eq m 11\na = ulong 2\nend\nif eq m 12\nt = ulong 134217728\nend\nif eq m 13\na = ulong 134217732\nend\nif eq m 14\nt = ulong 2\nend\nif eq m 15\na = ulong 2\nend\nv = bdisp a t wd\nif ge m 8\nret 81\nend\nif ne v e\nret 82\nend\nret 0\nend\n"
29fn matches i ulong to bool
30for j ulong get used 0
31if ne get src add i j get needle j
32ret false
33end
34end
35ret true
36end
37fn srcout p ulong n ulong to void
38while lt p n
39r = write 1 src p sub n p
40if le r 0
41exit 94
42end
43p = add p ulong r
44end
45end
46fn replout to void
47p = ulong 0
48while lt p get rlen 0
49r = write 1 repl p sub get rlen 0 p
50if le r 0
51exit 94
52end
53p = add p ulong r
54end
55end
56fn probeout to void
57p = ulong 0
58while lt p len probe
59r = write 1 probe p sub len probe p
60if le r 0
61exit 94
62end
63p = add p ulong r
64end
65end
66fn main to int
67if ne argcnt 2
68ret 90
69end
70r = argread 1 mode 0 len mode
71if ne r 1
72ret 90
73end
74m = get mode 0
75if or lt m 48 gt m 55
76ret 90
77end
78if eq m 48
79put used 0 len entry
80put rlen 0 len renamed
81for i ulong len entry
82put needle i get entry i
83put repl i get renamed i
84end
85end
86if eq m 49
87put used 0 len fwd
88put rlen 0 len fwdweak
89for i ulong len fwd
90put needle i get fwd i
91end
92for i ulong len fwdweak
93put repl i get fwdweak i
94end
95end
96if eq m 50
97put used 0 len seal
98put rlen 0 len noseal
99for i ulong len seal
100put needle i get seal i
101put repl i get noseal i
102end
103end
104if eq m 51
105put used 0 len digits
106put rlen 0 len longer
107for i ulong len digits
108put needle i get digits i
109put repl i get longer i
110end
111end
112if eq m 52
113put used 0 len filter
114put rlen 0 len bypass
115for i ulong len filter
116put needle i get filter i
117put repl i get bypass i
118end
119end
120if eq m 53
121put used 0 len fence
122put rlen 0 len bypass
123for i ulong len fence
124put needle i get fence i
125put repl i get bypass i
126end
127end
128if eq m 54
129put used 0 len bwd
130put rlen 0 len bwdweak
131for i ulong len bwd
132put needle i get bwd i
133end
134for i ulong len bwdweak
135put repl i get bwdweak i
136end
137end
138if eq m 55
139put used 0 len range
140put rlen 0 len norange
141for i ulong len range
142put needle i get range i
143end
144for i ulong len norange
145put repl i get norange i
146end
147end
148n = ulong 0
149go = true
150while go
151if eq n len src
152ret 91
153end
154r = read 0 src n sub len src n
155if lt r 0
156ret 92
157end
158if eq r 0
159go = false
160else
161n = add n ulong r
162end
163end
164found = ulong 0
165at = ulong 0
166for i ulong n
167if le get used 0 sub n i
168if matches i
169found = add found 1
170at = i
171end
172end
173end
174if ne found 1
175ret 93
176end
177srcout 0 at
178replout
179srcout add at get used 0 n
180if eq m 48
181probeout
182end
183ret 0
184end