summaryrefslogtreecommitdiff
path: root/tests/analysis/scan/fuzzing.py
blob: 64eeb332389bbeecec57a2a05354ae0e2159125e (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

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)