syntax-symphony 0.3.0__tar.gz → 0.4.0__tar.gz
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.
- {syntax_symphony-0.3.0/src/syntax_symphony.egg-info → syntax_symphony-0.4.0}/PKG-INFO +2 -2
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/README.md +1 -1
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/pyproject.toml +1 -1
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony/__init__.py +5 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony/cli.py +2 -2
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony/derivation_tree.py +1 -1
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony/fuzzer.py +7 -44
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0/src/syntax_symphony.egg-info}/PKG-INFO +2 -2
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/LICENSE +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/setup.cfg +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony/grammar.py +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony/py.typed +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony.egg-info/SOURCES.txt +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony.egg-info/dependency_links.txt +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony.egg-info/entry_points.txt +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony.egg-info/requires.txt +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony.egg-info/top_level.txt +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/tests/test_cli.py +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/tests/test_derivation_tree.py +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/tests/test_fuzzer.py +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/tests/test_grammar.py +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/tests/test_public_api.py +0 -0
- {syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/tests/test_validation.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: syntax_symphony
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Efficient grammar-based fuzzer.
|
|
5
5
|
Author-email: Stanimir Iglev <iglev.stanimir@gmail.com>
|
|
6
6
|
Maintainer-email: Stanimir Iglev <iglev.stanimir@gmail.com>
|
|
@@ -152,7 +152,7 @@ options:
|
|
|
152
152
|
-e EXT, --file-extension EXT
|
|
153
153
|
The file extension to be used for the produced documents. Default: txt
|
|
154
154
|
--max-depth NUMBER Maximum depth for the derivation trees. Default: 10
|
|
155
|
-
--min-depth NUMBER Minimum depth for the derivation trees. Default:
|
|
155
|
+
--min-depth NUMBER Minimum depth for the derivation trees. Default: 0
|
|
156
156
|
-k NUMBER, --kcov NUMBER
|
|
157
157
|
Number of strings to generate for k-cov. Default: 1
|
|
158
158
|
--seed NUMBER Random seed for reproducible fuzzing. Default: non-deterministic
|
|
@@ -105,7 +105,7 @@ options:
|
|
|
105
105
|
-e EXT, --file-extension EXT
|
|
106
106
|
The file extension to be used for the produced documents. Default: txt
|
|
107
107
|
--max-depth NUMBER Maximum depth for the derivation trees. Default: 10
|
|
108
|
-
--min-depth NUMBER Minimum depth for the derivation trees. Default:
|
|
108
|
+
--min-depth NUMBER Minimum depth for the derivation trees. Default: 0
|
|
109
109
|
-k NUMBER, --kcov NUMBER
|
|
110
110
|
Number of strings to generate for k-cov. Default: 1
|
|
111
111
|
--seed NUMBER Random seed for reproducible fuzzing. Default: non-deterministic
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"""Efficient grammar-based fuzzer with k-path coverage."""
|
|
2
2
|
|
|
3
|
+
from importlib.metadata import version
|
|
4
|
+
|
|
3
5
|
from .derivation_tree import DT
|
|
4
6
|
from .fuzzer import SyntaxSymphony
|
|
5
7
|
from .grammar import Grammar, load_grammar_from_file
|
|
6
8
|
|
|
9
|
+
__version__ = version("syntax_symphony")
|
|
10
|
+
|
|
7
11
|
__all__ = [
|
|
8
12
|
"DT",
|
|
9
13
|
"Grammar",
|
|
10
14
|
"SyntaxSymphony",
|
|
15
|
+
"__version__",
|
|
11
16
|
"load_grammar_from_file",
|
|
12
17
|
]
|
|
@@ -69,11 +69,11 @@ def ssfuzz() -> None:
|
|
|
69
69
|
parser.add_argument(
|
|
70
70
|
"--min-depth",
|
|
71
71
|
dest="min_depth",
|
|
72
|
-
default=
|
|
72
|
+
default=0,
|
|
73
73
|
metavar="NUMBER",
|
|
74
74
|
required=False,
|
|
75
75
|
type=int,
|
|
76
|
-
help="Minimum depth for the derivation trees. Default:
|
|
76
|
+
help="Minimum depth for the derivation trees. Default: 0",
|
|
77
77
|
)
|
|
78
78
|
parser.add_argument(
|
|
79
79
|
"-k",
|
|
@@ -31,7 +31,7 @@ class DT:
|
|
|
31
31
|
|
|
32
32
|
def __getitem__(self, index: int | slice) -> DT | list[DT]:
|
|
33
33
|
if self.children is None:
|
|
34
|
-
raise IndexError("
|
|
34
|
+
raise IndexError("Unexpanded symbols do not have children!")
|
|
35
35
|
return self.children[index]
|
|
36
36
|
|
|
37
37
|
def __iter__(self) -> Iterator[DT]:
|
|
@@ -2,8 +2,7 @@ import copy
|
|
|
2
2
|
import logging
|
|
3
3
|
import random
|
|
4
4
|
from collections import deque
|
|
5
|
-
from collections.abc import Callable,
|
|
6
|
-
from itertools import chain
|
|
5
|
+
from collections.abc import Callable, Iterable
|
|
7
6
|
|
|
8
7
|
from .derivation_tree import DT
|
|
9
8
|
from .grammar import Grammar, is_nonterminal
|
|
@@ -61,7 +60,9 @@ class SyntaxSymphony:
|
|
|
61
60
|
# NOTE: Shuffle the paths, so that we only need to pop from the list.
|
|
62
61
|
for symbol in self.uncovered_k_paths:
|
|
63
62
|
self._rng.shuffle(self.uncovered_k_paths[symbol])
|
|
64
|
-
|
|
63
|
+
self._remaining_k_paths = sum(
|
|
64
|
+
len(paths) for paths in self.uncovered_k_paths.values()
|
|
65
|
+
)
|
|
65
66
|
|
|
66
67
|
def symbol_cost(self, symbol: str, seen: set[str]) -> int | float:
|
|
67
68
|
"""Computes the cost of a symbol.
|
|
@@ -229,45 +230,6 @@ class SyntaxSymphony:
|
|
|
229
230
|
kpaths[symbol].extend(paths)
|
|
230
231
|
return kpaths
|
|
231
232
|
|
|
232
|
-
def convert_paths_to_trees(
|
|
233
|
-
self, paths: dict[str, list[list[list[str]]]]
|
|
234
|
-
) -> Generator[DT, None, None]:
|
|
235
|
-
"""Converts the k-path symbol map to derivation trees.
|
|
236
|
-
|
|
237
|
-
Args:
|
|
238
|
-
paths (dict[str, list[list[str]]]):
|
|
239
|
-
A dictionary mapping each nonterminal to a list of paths.
|
|
240
|
-
|
|
241
|
-
Returns:
|
|
242
|
-
Generator[DT, None, None]: A generator for derivation trees.
|
|
243
|
-
"""
|
|
244
|
-
# NOTE: Legacy function.
|
|
245
|
-
|
|
246
|
-
def expand_tree(tree: DT, path: list[list[str]], depth: int) -> DT:
|
|
247
|
-
if depth >= len(path):
|
|
248
|
-
return tree
|
|
249
|
-
|
|
250
|
-
expansion = path[depth]
|
|
251
|
-
children: list[DT] = []
|
|
252
|
-
|
|
253
|
-
if expansion not in self.grammar[tree.symbol]:
|
|
254
|
-
tree.children = None
|
|
255
|
-
return tree
|
|
256
|
-
|
|
257
|
-
for symbol in expansion:
|
|
258
|
-
if is_nonterminal(symbol):
|
|
259
|
-
child_tree = expand_tree(DT(symbol, None), path, depth + 1)
|
|
260
|
-
children.append(child_tree)
|
|
261
|
-
else:
|
|
262
|
-
children.append(DT(symbol, []))
|
|
263
|
-
|
|
264
|
-
tree.children = children
|
|
265
|
-
return tree
|
|
266
|
-
|
|
267
|
-
for nonterminal in paths:
|
|
268
|
-
for path in paths[nonterminal]:
|
|
269
|
-
yield expand_tree(DT(nonterminal, None), path, 0)
|
|
270
|
-
|
|
271
233
|
def complete_tree(self, dtree: DT) -> DT:
|
|
272
234
|
"""Completes a derivation tree by expanding the unexpanded nonterminals.
|
|
273
235
|
|
|
@@ -323,12 +285,12 @@ class SyntaxSymphony:
|
|
|
323
285
|
return expand_tree(DT(item.symbol, None), path, 0)
|
|
324
286
|
|
|
325
287
|
def remaining_k_paths(self) -> int:
|
|
326
|
-
"""
|
|
288
|
+
"""Return the number of remaining uncovered k-paths.
|
|
327
289
|
|
|
328
290
|
Returns:
|
|
329
291
|
int: The number of remaining uncovered k-paths.
|
|
330
292
|
"""
|
|
331
|
-
return
|
|
293
|
+
return self._remaining_k_paths
|
|
332
294
|
|
|
333
295
|
def tree_fuzz(self, tree: DT) -> DT:
|
|
334
296
|
"""Fuzzes a derivation tree by expanding the unexpanded nonterminals.
|
|
@@ -349,6 +311,7 @@ class SyntaxSymphony:
|
|
|
349
311
|
|
|
350
312
|
if len(self.uncovered_k_paths[item.symbol]) > 0 and depth < self._max_depth:
|
|
351
313
|
path = self.uncovered_k_paths[item.symbol].pop()
|
|
314
|
+
self._remaining_k_paths -= 1
|
|
352
315
|
k_tree = self._k_path_to_tree(item, path)
|
|
353
316
|
for i in k_tree:
|
|
354
317
|
if i.children is None:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: syntax_symphony
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Efficient grammar-based fuzzer.
|
|
5
5
|
Author-email: Stanimir Iglev <iglev.stanimir@gmail.com>
|
|
6
6
|
Maintainer-email: Stanimir Iglev <iglev.stanimir@gmail.com>
|
|
@@ -152,7 +152,7 @@ options:
|
|
|
152
152
|
-e EXT, --file-extension EXT
|
|
153
153
|
The file extension to be used for the produced documents. Default: txt
|
|
154
154
|
--max-depth NUMBER Maximum depth for the derivation trees. Default: 10
|
|
155
|
-
--min-depth NUMBER Minimum depth for the derivation trees. Default:
|
|
155
|
+
--min-depth NUMBER Minimum depth for the derivation trees. Default: 0
|
|
156
156
|
-k NUMBER, --kcov NUMBER
|
|
157
157
|
Number of strings to generate for k-cov. Default: 1
|
|
158
158
|
--seed NUMBER Random seed for reproducible fuzzing. Default: non-deterministic
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{syntax_symphony-0.3.0 → syntax_symphony-0.4.0}/src/syntax_symphony.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|