Commit eea79f44 by Victor M. Alvarez

set_config now returns None instead of an empty string and have a test case.

parent be1ac232
...@@ -1000,6 +1000,16 @@ class TestYara(unittest.TestCase): ...@@ -1000,6 +1000,16 @@ class TestYara(unittest.TestCase):
r = next(it) r = next(it)
self.assertTrue(r.identifier == 'test3') self.assertTrue(r.identifier == 'test3')
def testSetConfig(self):
yara.set_config(max_strings_per_rule=1)
self.assertSyntaxError(['''
rule test { strings: $a = "1" $b = "2" condition: all of them }
'''])
yara.set_config(max_strings_per_rule=10000)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()
...@@ -1836,21 +1836,28 @@ static PyObject* yara_set_config( ...@@ -1836,21 +1836,28 @@ static PyObject* yara_set_config(
&stack_size, &stack_size,
&max_strings_per_rule)) &max_strings_per_rule))
{ {
if(stack_size != 0) { if (stack_size != 0)
if((error = yr_set_configuration(YR_CONFIG_STACK_SIZE, {
&stack_size)) != ERROR_SUCCESS) { error = yr_set_configuration(
YR_CONFIG_STACK_SIZE,
&stack_size);
if ( error != ERROR_SUCCESS)
return handle_error(error, NULL); return handle_error(error, NULL);
} }
}
if(max_strings_per_rule != 0) { if (max_strings_per_rule != 0)
if((error = yr_set_configuration(YR_CONFIG_MAX_STRINGS_PER_RULE, {
&max_strings_per_rule)) != ERROR_SUCCESS) { error = yr_set_configuration(
YR_CONFIG_MAX_STRINGS_PER_RULE,
&max_strings_per_rule);
if (error != ERROR_SUCCESS)
return handle_error(error, NULL); return handle_error(error, NULL);
} }
} }
}
return Py_BuildValue(""); Py_RETURN_NONE;
} }
static PyObject* yara_compile( static PyObject* yara_compile(
......
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