Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added warning on unknown escape sequences #1880

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cli/yara.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ static bool ignore_warnings = false;
static bool fast_scan = false;
static bool negate = false;
static bool print_count_only = false;
static bool strict_escape = false;
static bool fail_on_warnings = false;
static bool rules_are_compiled = false;
static long total_count = 0;
Expand Down Expand Up @@ -191,6 +192,12 @@ args_option_t options[] = {
&print_count_only,
_T("print only number of matches")),

OPT_BOOLEAN(
'E',
_T("strict-escape"),
&strict_escape,
_T("warn on unknown escape sequences")),

OPT_STRING_MULTI(
'd',
_T("define"),
Expand Down Expand Up @@ -1557,6 +1564,11 @@ int _tmain(int argc, const char_t** argv)

yr_compiler_set_callback(compiler, print_compiler_error, &cr);

if (strict_escape)
compiler->strict_escape = true;
else
compiler->strict_escape = false;

if (!compile_files(compiler, argc, argv))
exit_with_code(EXIT_FAILURE);

Expand Down
12 changes: 12 additions & 0 deletions cli/yarac.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ static char* ext_vars[MAX_ARGS_EXT_VAR + 1];
static bool ignore_warnings = false;
static bool show_version = false;
static bool show_help = false;
static bool strict_escape = false;
static bool fail_on_warnings = false;
static long max_strings_per_rule = DEFAULT_MAX_STRINGS_PER_RULE;

Expand Down Expand Up @@ -103,6 +104,12 @@ args_option_t options[] = {

OPT_BOOLEAN('h', _T("help"), &show_help, _T("show this help and exit")),

OPT_BOOLEAN(
'E',
_T("strict-escape"),
&strict_escape,
_T("warn on unknown escape sequences")),

OPT_LONG(
0,
_T("max-strings-per-rule"),
Expand Down Expand Up @@ -233,6 +240,11 @@ int _tmain(int argc, const char_t** argv)

yr_compiler_set_callback(compiler, report_error, &cr);

if (strict_escape)
compiler->strict_escape = true;
else
compiler->strict_escape = false;

if (!compile_files(compiler, argc, argv))
exit_with_code(EXIT_FAILURE);

Expand Down
2 changes: 1 addition & 1 deletion libyara/base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ int _yr_base64_create_regexp(
// printf("%s\n", re_str);

FAIL_ON_ERROR_WITH_CLEANUP(
yr_re_parse(re_str, re_ast, re_error), yr_free(re_str));
yr_re_parse(re_str, re_ast, re_error, RE_PARSER_FLAG_NONE), yr_free(re_str));

yr_free(re_str);

Expand Down
1 change: 1 addition & 0 deletions libyara/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ YR_API int yr_compiler_create(YR_COMPILER** compiler)
new_compiler->re_ast_clbk_user_data = NULL;
new_compiler->last_error = ERROR_SUCCESS;
new_compiler->last_error_line = 0;
new_compiler->strict_escape = false;
new_compiler->current_line = 0;
new_compiler->file_name_stack_ptr = 0;
new_compiler->fixup_stack_head = NULL;
Expand Down
Loading