summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2023-08-06 21:40:42 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2023-08-06 21:40:42 (GMT)
commitdbe05c349a0892306d7317d3c26a56e9b19eca92 (patch)
tree93739751af7def06bea9aa168ebb8210edb8aa95 /tests
parent532ae1e0a10d00193719dcd1704744bf2966a25b (diff)
Prevent the ACISM backend from crashing when a scan is performed with no pattern.
Diffstat (limited to 'tests')
-rw-r--r--tests/analysis/scan/fuzzing.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/analysis/scan/fuzzing.py b/tests/analysis/scan/fuzzing.py
new file mode 100644
index 0000000..64eeb33
--- /dev/null
+++ b/tests/analysis/scan/fuzzing.py
@@ -0,0 +1,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)