Unverified Commit b8fd598e by Tomáš Ďuriš Committed by GitHub

Warning on unknown escape sequences enabled by compiler argument (#223)

Co-authored-by: Tomáš Ďuriš <tomas.duris@avast.com>
parent 3abadbb2
...@@ -2624,7 +2624,7 @@ static PyObject* yara_compile( ...@@ -2624,7 +2624,7 @@ static PyObject* yara_compile(
{ {
static char *kwlist[] = { static char *kwlist[] = {
"filepath", "source", "file", "filepaths", "sources", "filepath", "source", "file", "filepaths", "sources",
"includes", "externals", "error_on_warning", "include_callback", NULL}; "includes", "externals", "error_on_warning", "strict_escape", "include_callback", NULL};
YR_COMPILER* compiler; YR_COMPILER* compiler;
YR_RULES* yara_rules; YR_RULES* yara_rules;
...@@ -2641,6 +2641,7 @@ static PyObject* yara_compile( ...@@ -2641,6 +2641,7 @@ static PyObject* yara_compile(
PyObject* includes = NULL; PyObject* includes = NULL;
PyObject* externals = NULL; PyObject* externals = NULL;
PyObject* error_on_warning = NULL; PyObject* error_on_warning = NULL;
PyObject* strict_escape = NULL;
PyObject* include_callback = NULL; PyObject* include_callback = NULL;
Py_ssize_t pos = 0; Py_ssize_t pos = 0;
...@@ -2657,7 +2658,7 @@ static PyObject* yara_compile( ...@@ -2657,7 +2658,7 @@ static PyObject* yara_compile(
if (PyArg_ParseTupleAndKeywords( if (PyArg_ParseTupleAndKeywords(
args, args,
keywords, keywords,
"|ssOOOOOOO", "|ssOOOOOOOO",
kwlist, kwlist,
&filepath, &filepath,
&source, &source,
...@@ -2667,6 +2668,7 @@ static PyObject* yara_compile( ...@@ -2667,6 +2668,7 @@ static PyObject* yara_compile(
&includes, &includes,
&externals, &externals,
&error_on_warning, &error_on_warning,
&strict_escape,
&include_callback)) &include_callback))
{ {
char num_args = 0; char num_args = 0;
...@@ -2716,6 +2718,21 @@ static PyObject* yara_compile( ...@@ -2716,6 +2718,21 @@ static PyObject* yara_compile(
} }
} }
if (strict_escape != NULL)
{
if (PyBool_Check(strict_escape))
{
compiler->strict_escape = PyObject_IsTrue(strict_escape);
}
else
{
yr_compiler_destroy(compiler);
return PyErr_Format(
PyExc_TypeError,
"'strict_escape' param must be of boolean type");
}
}
if (includes != NULL) if (includes != NULL)
{ {
if (PyBool_Check(includes)) if (PyBool_Check(includes))
......
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