From e57ee8908f9fc82fd62f1e049690fbf08628d8ed Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Wed, 7 Oct 2015 15:26:08 -0300 Subject: [PATCH] Searches for included configuration using the resource policy --- src/parser/seclang-scanner.ll | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/parser/seclang-scanner.ll b/src/parser/seclang-scanner.ll index 2e42e0da..c232161c 100755 --- a/src/parser/seclang-scanner.ll +++ b/src/parser/seclang-scanner.ll @@ -377,16 +377,16 @@ CONFIG_DIR_UNICODE_MAP_FILE (?i:SecUnicodeMapFile) {CONFIG_INCLUDE}[ ]{CONFIG_VALUE_PATH} { const char *file = strchr(yytext, ' ') + 1; for (auto& s: ModSecurity::expandEnv(file, 0)) { - yyin = fopen(s.c_str(), "r" ); + std::string f = ModSecurity::find_resource(s, driver.ref.back()); + yyin = fopen(f.c_str(), "r" ); if (!yyin) { BEGIN(INITIAL); driver.error (*driver.loc.back(), "", s + std::string(": Not able to open file.")); throw yy::seclang_parser::syntax_error(*driver.loc.back(), ""); } - driver.ref.push_back(file); + driver.ref.push_back(f); driver.loc.push_back(new yy::location()); yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE )); - } } @@ -395,13 +395,14 @@ CONFIG_DIR_UNICODE_MAP_FILE (?i:SecUnicodeMapFile) char *f = strdup(file + 1); f[strlen(f)-1] = '\0'; for (auto& s: ModSecurity::expandEnv(f, 0)) { - yyin = fopen(s.c_str(), "r" ); + std::string f = ModSecurity::find_resource(s, driver.ref.back()); + yyin = fopen(f.c_str(), "r" ); if (!yyin) { BEGIN(INITIAL); driver.error (*driver.loc.back(), "", s + std::string(": Not able to open file.")); throw yy::seclang_parser::syntax_error(*driver.loc.back(), ""); } - driver.ref.push_back(s.c_str()); + driver.ref.push_back(f.c_str()); driver.loc.push_back(new yy::location()); yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));