mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
parser: Fix the expanded list inclusion
This commit is contained in:
parent
c98be42f8f
commit
ab88083159
@ -402,7 +402,9 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
|
|||||||
driver.error (*driver.loc.back(), "", file + std::string(": Not able to open file."));
|
driver.error (*driver.loc.back(), "", file + std::string(": Not able to open file."));
|
||||||
throw p::syntax_error(*driver.loc.back(), "");
|
throw p::syntax_error(*driver.loc.back(), "");
|
||||||
}
|
}
|
||||||
for (auto& s: modsecurity::utils::expandEnv(fi, 0)) {
|
std::list<std::string> files = modsecurity::utils::expandEnv(fi, 0);
|
||||||
|
files.reverse();
|
||||||
|
for (auto& s: files) {
|
||||||
std::string f = modsecurity::utils::find_resource(s, driver.ref.back());
|
std::string f = modsecurity::utils::find_resource(s, driver.ref.back());
|
||||||
yyin = fopen(f.c_str(), "r" );
|
yyin = fopen(f.c_str(), "r" );
|
||||||
if (!yyin) {
|
if (!yyin) {
|
||||||
@ -426,7 +428,9 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
|
|||||||
driver.error (*driver.loc.back(), "", file + std::string(": Not able to open file."));
|
driver.error (*driver.loc.back(), "", file + std::string(": Not able to open file."));
|
||||||
throw p::syntax_error(*driver.loc.back(), "");
|
throw p::syntax_error(*driver.loc.back(), "");
|
||||||
}
|
}
|
||||||
for (auto& s: modsecurity::utils::expandEnv(fi, 0)) {
|
std::list<std::string> files = modsecurity::utils::expandEnv(fi, 0);
|
||||||
|
files.reverse();
|
||||||
|
for (auto& s: files) {
|
||||||
std::string f = modsecurity::utils::find_resource(s, driver.ref.back());
|
std::string f = modsecurity::utils::find_resource(s, driver.ref.back());
|
||||||
yyin = fopen(f.c_str(), "r" );
|
yyin = fopen(f.c_str(), "r" );
|
||||||
if (!yyin) {
|
if (!yyin) {
|
||||||
@ -437,7 +441,6 @@ VAR_FREE_TEXT_SPACE_COMMA [^, \t\"]+
|
|||||||
driver.ref.push_back(f.c_str());
|
driver.ref.push_back(f.c_str());
|
||||||
driver.loc.push_back(new yy::location());
|
driver.loc.push_back(new yy::location());
|
||||||
yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));
|
yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));
|
||||||
|
|
||||||
}
|
}
|
||||||
free(f);
|
free(f);
|
||||||
}
|
}
|
||||||
|
@ -106,8 +106,8 @@ std::string get_path(const std::string& file) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::vector<std::string> expandEnv(const std::string& var, int flags) {
|
std::list<std::string> expandEnv(const std::string& var, int flags) {
|
||||||
std::vector<std::string> vars;
|
std::list<std::string> vars;
|
||||||
|
|
||||||
wordexp_t p;
|
wordexp_t p;
|
||||||
if (wordexp(var.c_str(), &p, flags) == false) {
|
if (wordexp(var.c_str(), &p, flags) == false) {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <list>
|
||||||
|
|
||||||
#include "modsecurity/modsecurity.h"
|
#include "modsecurity/modsecurity.h"
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ namespace utils {
|
|||||||
double cpu_seconds(void);
|
double cpu_seconds(void);
|
||||||
std::string find_resource(const std::string& file, const std::string& param);
|
std::string find_resource(const std::string& file, const std::string& param);
|
||||||
std::string get_path(const std::string& file);
|
std::string get_path(const std::string& file);
|
||||||
std::vector<std::string> expandEnv(const std::string& var, int flags);
|
std::list<std::string> expandEnv(const std::string& var, int flags);
|
||||||
void createDir(std::string dir, int mode);
|
void createDir(std::string dir, int mode);
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,12 +37,12 @@ void print_help() {
|
|||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
modsecurity::Rules *modsecRules = new modsecurity::Rules();
|
modsecurity::Rules *modsecRules = new modsecurity::Rules();
|
||||||
std::vector<std::string> files;
|
std::list<std::string> files;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
int i = 1;
|
int i = 1;
|
||||||
while (i < argc) {
|
while (i < argc) {
|
||||||
std::vector<std::string> tfiles = modsecurity::utils::expandEnv(
|
std::list<std::string> tfiles = modsecurity::utils::expandEnv(
|
||||||
argv[i], 0);
|
argv[i], 0);
|
||||||
for (const auto &file : tfiles) {
|
for (const auto &file : tfiles) {
|
||||||
files.insert(files.begin(), file);
|
files.insert(files.begin(), file);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user