Commit 6f1cac0e by plusvic

Add test case for modules callback

parent 7fd19abf
...@@ -915,6 +915,23 @@ class TestYara(unittest.TestCase): ...@@ -915,6 +915,23 @@ class TestYara(unittest.TestCase):
self.assertTrue(len(m) == 1) self.assertTrue(len(m) == 1)
def testModuleData(self):
data = {}
def callback(module_data):
data['constants'] = module_data.get('constants')
r1 = yara.compile(
source='import "tests" rule test { condition: false }')
r1.match(data='', modules_callback=callback)
self.assertTrue(data['constants']['foo'] == 'foo')
self.assertTrue(data['constants']['empty'] == '')
self.assertTrue(data['constants']['one'] == 1)
self.assertTrue(data['constants']['two'] == 2)
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment