blob: 0870ed4901fb62b2da655b22550c1867285fb63d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
from chrysacase import ChrysalideTestCase
from pychrysalide.analysis.contents import MemoryContent
from pychrysalide.analysis.scan import ContentScanner
from pychrysalide.analysis.scan import ScanOptions
from pychrysalide.analysis.scan.patterns.backends import AcismBackend
from pychrysalide.analysis.scan.patterns.backends import BitapBackend
class TestRostFuzzingFixes(ChrysalideTestCase):
"""TestCases to remember all the fixes for crashes identified by fuzzing."""
def testEmptyPatternListWithContent(self):
"""Check no backend is run if there is no pattern to look for."""
content = MemoryContent(b'\n')
rule = '''
'''
backends = [
AcismBackend, # This one was segfaulting
BitapBackend,
]
for b in backends:
options = ScanOptions()
options.backend_for_data = b
scanner = ContentScanner(rule)
ctx = scanner.analyze(options, content)
self.assertIsNotNone(ctx)
def testMandatoryCondition(self):
"""Ensure a condition section exists in a rule."""
rule = '''
rule test {
}
'''
with self.assertRaisesRegex(ValueError, 'Unable to create content scanner'):
scanner = ContentScanner(rule)
|