leptris 1.9.428.0-arm-linux → 1.9.430.0-arm-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Rakefile +1 -1
- data/lib/leptris/version.rb +1 -1
- data/lib/leptris/xml/native.so +0 -0
- data/lib/leptris/xml/native_3_3.so +0 -0
- data/lib/libleptris.so +0 -0
- data/vendor-src/README.md +1 -1
- data/vendor-src/libleptris/CHANGELOG.md +18 -0
- data/vendor-src/libleptris/CMakeLists.txt +1 -1
- data/vendor-src/libleptris/src/CMakeLists.txt +0 -2
- data/vendor-src/libleptris/src/leptris/rng/validate.c +375 -60
- data/vendor-src/libleptris/test/fuzz/corpus/html_reconstruction_nest_min.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/corpus/html_tree_amplification_timeout.bin +0 -0
- data/vendor-src/libleptris/test/fuzz/generators/gen_html_seeds.py +101 -0
- data/vendor-src/libleptris/test/fuzz/generators/gen_xpath_seeds.py +123 -0
- data/vendor-src/libleptris/test/rng/include-cases/i2093-base.rng +9 -0
- data/vendor-src/libleptris/test/rng/include-cases/i2093-ext.rng +7 -0
- data/vendor-src/libleptris/test/rng/test_rng.cpp +584 -0
- data/vendor-src/libleptris/vcpkg.json +1 -1
- metadata +8 -2
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Grammar-aware HTML seed generator (SOTA C1 #2051): documents that
|
|
3
|
+
anchor the tokenizer's STATE SPACE — foreign content (SVG/MATH with
|
|
4
|
+
integration points), CDATA-ish surprises, self-closing tags, weird
|
|
5
|
+
names, implied end tags, attributes with odd spellings, comments/
|
|
6
|
+
doctypes in odd positions. HTML parsing is error-recovery by design;
|
|
7
|
+
the generator exercises the recovery paths from INSIDE the grammar
|
|
8
|
+
rather than at byte-flip distance. Deterministic under --seed.
|
|
9
|
+
|
|
10
|
+
Usage: gen_html_seeds.py OUTDIR [--seed N] [--count N]
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import os
|
|
15
|
+
import random
|
|
16
|
+
|
|
17
|
+
BLOCK = ["div", "p", "section", "li", "td", "tr", "table"]
|
|
18
|
+
FOREIGN = ["svg", "math"]
|
|
19
|
+
SVG_KIDS = ["path", "circle", "g", "foreignObject", "desc", "title",
|
|
20
|
+
"text", "clipPath", "use"]
|
|
21
|
+
MATH_KIDS = ["mi", "mo", "mn", "mrow", "msup", "annotation-xml"]
|
|
22
|
+
WEIRD_TAGS = ["a<b", "foo.bar", "x:y", "font-face-uri", "set"]
|
|
23
|
+
TEXTS = ["hello", "42", "a < b", "<notatag", "&amp", " "]
|
|
24
|
+
ATTR_SPELLINGS = ['class="x"', "id=noquotes", "data-x='y'",
|
|
25
|
+
"DATA-UPPER=1", 'disabled', '=""',
|
|
26
|
+
'style="color:red"']
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def attrs(rng):
|
|
30
|
+
return (" " + " ".join(rng.sample(
|
|
31
|
+
ATTR_SPELLINGS, rng.randint(0, 3)))) if rng.random() < 0.8 else ""
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def html(rng, depth):
|
|
35
|
+
out = []
|
|
36
|
+
for _ in range(rng.randint(1, 4)):
|
|
37
|
+
r = rng.random()
|
|
38
|
+
if r < 0.30 and depth > 0:
|
|
39
|
+
t = rng.choice(BLOCK)
|
|
40
|
+
out.append(f"<{t}{attrs(rng)}>{html(rng, depth - 1)}</{t}>")
|
|
41
|
+
elif r < 0.50:
|
|
42
|
+
f = rng.choice(FOREIGN)
|
|
43
|
+
kids = rng.choice(SVG_KIDS) if f == "svg" else rng.choice(MATH_KIDS)
|
|
44
|
+
inner = "".join(
|
|
45
|
+
f"<{kids}{attrs(rng)}{rng.choice(['', ' />', ' /'])}>"
|
|
46
|
+
for _ in range(rng.randint(1, 3)))
|
|
47
|
+
tail = rng.choice(["", "<![CDATA[x]]>", "</p>"])
|
|
48
|
+
out.append(f"<{f}{attrs(rng)}>{inner}{tail}</{f}>")
|
|
49
|
+
elif r < 0.58:
|
|
50
|
+
out.append(rng.choice(TEXTS))
|
|
51
|
+
elif r < 0.64:
|
|
52
|
+
out.append(f"<!-- comment {rng.randint(0, 9)} -->")
|
|
53
|
+
elif r < 0.70:
|
|
54
|
+
out.append(f"<{rng.choice(WEIRD_TAGS)}{attrs(rng)}>")
|
|
55
|
+
elif r < 0.76:
|
|
56
|
+
out.append(rng.choice(["<br>", "<hr/>", "<img src=x>",
|
|
57
|
+
"<input value=?>"]))
|
|
58
|
+
elif r < 0.82:
|
|
59
|
+
out.append(rng.choice(["<p>", "</p>", "<li>", "</li>"]))
|
|
60
|
+
elif r < 0.88:
|
|
61
|
+
out.append(f"<script{attrs(rng)}>if (a<b) x();</script>")
|
|
62
|
+
elif r < 0.94:
|
|
63
|
+
out.append(f"<style>p {{ color: red }}</style>")
|
|
64
|
+
else:
|
|
65
|
+
out.append("<template><td><a href=#>t</td></template>")
|
|
66
|
+
return "".join(out)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def gen_doc(rng):
|
|
70
|
+
parts = []
|
|
71
|
+
if rng.random() < 0.7:
|
|
72
|
+
parts.append(rng.choice([
|
|
73
|
+
"<!DOCTYPE html>", "<!doctype html>",
|
|
74
|
+
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\">",
|
|
75
|
+
]))
|
|
76
|
+
parts.append("<html>")
|
|
77
|
+
if rng.random() < 0.6:
|
|
78
|
+
parts.append(f"<head><meta charset=utf-8><title>t</title></head>")
|
|
79
|
+
parts.append(f"<body>{html(rng, rng.randint(1, 5))}</body>")
|
|
80
|
+
parts.append("</html>")
|
|
81
|
+
return "".join(parts) + "\n"
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def main():
|
|
85
|
+
ap = argparse.ArgumentParser()
|
|
86
|
+
ap.add_argument("outdir")
|
|
87
|
+
ap.add_argument("--seed", type=int, default=0)
|
|
88
|
+
ap.add_argument("--count", type=int, default=100)
|
|
89
|
+
args = ap.parse_args()
|
|
90
|
+
|
|
91
|
+
os.makedirs(args.outdir, exist_ok=True)
|
|
92
|
+
rng = random.Random(args.seed)
|
|
93
|
+
for i in range(args.count):
|
|
94
|
+
with open(os.path.join(args.outdir, f"gen{i:04d}.html"), "w",
|
|
95
|
+
encoding="utf-8") as f:
|
|
96
|
+
f.write(gen_doc(rng))
|
|
97
|
+
print(f"wrote {args.count} seeds to {args.outdir}")
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
if __name__ == "__main__":
|
|
101
|
+
main()
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Grammar-aware XPath/XQuery seed generator (SOTA C1 #2051). The
|
|
3
|
+
xpath_corpus's hand-written seeds are five lines; mutation explores
|
|
4
|
+
expression STRUCTURE from them slowly. This generator composes
|
|
5
|
+
expressions across the grammar: axis steps with predicates, function
|
|
6
|
+
calls (0/1/2-arg), unions, comparisons, arithmetic, numeric and
|
|
7
|
+
string literals, variables, path/absolute mixes, filtered primaries,
|
|
8
|
+
XQuery FLWOR spellings. Well-formed by construction; deterministic
|
|
9
|
+
under --seed. The nightly feeds them to the fuzz_xpath leg.
|
|
10
|
+
|
|
11
|
+
Usage: gen_xpath_seeds.py OUTDIR [--seed N] [--count N]
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import argparse
|
|
15
|
+
import os
|
|
16
|
+
import random
|
|
17
|
+
|
|
18
|
+
NAMES = ["a", "b", "item", "r", "node", "leaf", "span", "*"]
|
|
19
|
+
ATTRS = ["id", "kind", "status", "sku"]
|
|
20
|
+
AXES = ["child::", "descendant::", "following-sibling::",
|
|
21
|
+
"preceding-sibling::", "ancestor::", "self::", "attribute::"]
|
|
22
|
+
FUNCS0 = ["position()", "last()", "count(//*)", "true()", "false()",
|
|
23
|
+
"string-length(name())"]
|
|
24
|
+
FUNCS1 = ["string-length(.)", "number(@id)", "contains(@kind,'x')",
|
|
25
|
+
"starts-with(name(),'a')", "normalize-space(.)",
|
|
26
|
+
"string(.)", "not(.)", "round(number(@id))",
|
|
27
|
+
"floor(number(@id))", "ceiling(number(@id))"]
|
|
28
|
+
FUNCS2 = ["substring(.,1,2)", "concat('x',.)", "substring-after(name(),'a')",
|
|
29
|
+
"contains(.,'z')"]
|
|
30
|
+
LITS = ["1", "0", "2.5", "-3", "'x'", "\"y\"", "'a b'", "1e2", ".5"]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def predicate(rng, depth):
|
|
34
|
+
r = rng.random()
|
|
35
|
+
if r < 0.25:
|
|
36
|
+
return str(rng.randint(1, 3))
|
|
37
|
+
if r < 0.5:
|
|
38
|
+
return rng.choice(FUNCS0 + FUNCS1)
|
|
39
|
+
if r < 0.7:
|
|
40
|
+
rhs = rng.choice(["1", "'x'", "true()"])
|
|
41
|
+
op = rng.choice(["=", "!="])
|
|
42
|
+
return f"@{rng.choice(ATTRS)}{op}{rhs}"
|
|
43
|
+
return comparison(rng, depth - 1)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def step(rng, depth):
|
|
47
|
+
axis = rng.choice(AXES) if rng.random() < 0.4 else ""
|
|
48
|
+
name = rng.choice(NAMES)
|
|
49
|
+
s = f"{axis}{name}"
|
|
50
|
+
if depth > 0:
|
|
51
|
+
while rng.random() < 0.5:
|
|
52
|
+
s = f"{s}[{predicate(rng, depth - 1)}]"
|
|
53
|
+
return s
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def path(rng, depth):
|
|
57
|
+
p = step(rng, depth)
|
|
58
|
+
n = rng.randint(0, 2)
|
|
59
|
+
for _ in range(n):
|
|
60
|
+
sep = "//" if rng.random() < 0.2 else "/"
|
|
61
|
+
p = f"{p}{sep}{step(rng, depth - 1)}"
|
|
62
|
+
return p
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def comparison(rng, depth):
|
|
66
|
+
if depth <= 0:
|
|
67
|
+
return rng.choice(LITS)
|
|
68
|
+
lhs = operand(rng, depth - 1)
|
|
69
|
+
op = rng.choice(["=", "!=", "<", ">", "<=", ">=", "!=", "="])
|
|
70
|
+
rhs = operand(rng, depth - 1)
|
|
71
|
+
return f"{lhs} {op} {rhs}"
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def operand(rng, depth):
|
|
75
|
+
r = rng.random()
|
|
76
|
+
if r < 0.35:
|
|
77
|
+
return path(rng, depth)
|
|
78
|
+
if r < 0.55:
|
|
79
|
+
return rng.choice(FUNCS0 + FUNCS1 + FUNCS2)
|
|
80
|
+
if r < 0.7:
|
|
81
|
+
return rng.choice(LITS)
|
|
82
|
+
if r < 0.85:
|
|
83
|
+
return f"({comparison(rng, depth - 1)})"
|
|
84
|
+
return f"{operand(rng, depth - 1)} {rng.choice(['+', '-', 'div', 'mod'])} {rng.choice(LITS)}"
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
def expr(rng, depth):
|
|
88
|
+
e = comparison(rng, depth)
|
|
89
|
+
while rng.random() < 0.35:
|
|
90
|
+
e = f"{e} | {path(rng, depth - 1)}"
|
|
91
|
+
if rng.random() < 0.12:
|
|
92
|
+
var = rng.choice(["$x", "$item", "$n"])
|
|
93
|
+
inner = expr(rng, depth - 1).replace("'", "\\'")
|
|
94
|
+
e = f"(for {var} in (1,2) return if ({e}) then {var} else ())"
|
|
95
|
+
return e
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def main():
|
|
99
|
+
ap = argparse.ArgumentParser()
|
|
100
|
+
ap.add_argument("outdir")
|
|
101
|
+
ap.add_argument("--seed", type=int, default=0)
|
|
102
|
+
ap.add_argument("--count", type=int, default=200)
|
|
103
|
+
args = ap.parse_args()
|
|
104
|
+
|
|
105
|
+
rng = random.Random(args.seed)
|
|
106
|
+
os.makedirs(args.outdir, exist_ok=True)
|
|
107
|
+
seen = set()
|
|
108
|
+
n = 0
|
|
109
|
+
for _ in range(args.count):
|
|
110
|
+
e = expr(rng, rng.randint(1, 4))
|
|
111
|
+
if e in seen or len(e) > 400:
|
|
112
|
+
continue
|
|
113
|
+
seen.add(e)
|
|
114
|
+
# One file per expression: the fuzz legs take corpus
|
|
115
|
+
# DIRECTORIES, and libFuzzer mutates per file.
|
|
116
|
+
with open(os.path.join(args.outdir, f"gen{n:04d}.xpath"), "w") as f:
|
|
117
|
+
f.write(e + "\n")
|
|
118
|
+
n += 1
|
|
119
|
+
print(f"wrote {n} expressions to {args.outdir}")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
if __name__ == "__main__":
|
|
123
|
+
main()
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="">
|
|
3
|
+
<start><element name="ext"><ref name="Ext"/></element></start>
|
|
4
|
+
<define name="Ext">
|
|
5
|
+
<element name="doctype"><empty/></element>
|
|
6
|
+
<element name="flavor"><empty/></element>
|
|
7
|
+
<zeroOrMore><element name="ics"><empty/></element></zeroOrMore>
|
|
8
|
+
</define>
|
|
9
|
+
</grammar>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="">
|
|
3
|
+
<include href="i2093-base.rng"/>
|
|
4
|
+
<define name="Ext" combine="interleave">
|
|
5
|
+
<optional><element name="price-code"><empty/></element></optional>
|
|
6
|
+
</define>
|
|
7
|
+
</grammar>
|