mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
Fix issue related to Lua script load
This commit is contained in:
parent
c98e665475
commit
eaa4770c5d
@ -75,7 +75,7 @@ bool Lua::load(std::string script, std::string *err) {
|
|||||||
const char *luaerr = lua_tostring(L, -1);
|
const char *luaerr = lua_tostring(L, -1);
|
||||||
err->assign("Failed to compile script '" + script + "");
|
err->assign("Failed to compile script '" + script + "");
|
||||||
if (luaerr) {
|
if (luaerr) {
|
||||||
err->append(": " + *luaerr);
|
err->append(": " + std::string(luaerr));
|
||||||
}
|
}
|
||||||
err->append(".");
|
err->append(".");
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
@ -91,7 +91,7 @@ bool Lua::load(std::string script, std::string *err) {
|
|||||||
const char *luaerr = lua_tostring(L, -1);
|
const char *luaerr = lua_tostring(L, -1);
|
||||||
err->assign("Failed to compile script '" + script + "");
|
err->assign("Failed to compile script '" + script + "");
|
||||||
if (luaerr) {
|
if (luaerr) {
|
||||||
err->append(": " + *luaerr);
|
err->append(": " + std::string(luaerr));
|
||||||
}
|
}
|
||||||
err->append(".");
|
err->append(".");
|
||||||
lua_close(L);
|
lua_close(L);
|
||||||
@ -366,6 +366,8 @@ int Lua::setvar(lua_State *L) {
|
|||||||
|
|
||||||
t->m_collections.storeOrUpdateFirst(collection,
|
t->m_collections.storeOrUpdateFirst(collection,
|
||||||
variableName, var_value);
|
variableName, var_value);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1881,18 +1881,18 @@ namespace yy {
|
|||||||
case 75:
|
case 75:
|
||||||
#line 1117 "seclang-parser.yy" // lalr1.cc:859
|
#line 1117 "seclang-parser.yy" // lalr1.cc:859
|
||||||
{
|
{
|
||||||
|
std::string err;
|
||||||
std::vector<actions::Action *> *a = new std::vector<actions::Action *>();
|
std::vector<actions::Action *> *a = new std::vector<actions::Action *>();
|
||||||
for (auto &i : *yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<actions::Action> > > > ().get()) {
|
for (auto &i : *yystack_[0].value.as< std::unique_ptr<std::vector<std::unique_ptr<actions::Action> > > > ().get()) {
|
||||||
a->push_back(i.release());
|
a->push_back(i.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleScript *r = new RuleScript(
|
RuleScript *r = new RuleScript(
|
||||||
/* path to script */ yystack_[1].value.as< std::string > (),
|
/* path to script */ yystack_[1].value.as< std::string > (),
|
||||||
/* actions */ a,
|
/* actions */ a,
|
||||||
/* file name */ driver.ref.back(),
|
/* file name */ driver.ref.back(),
|
||||||
/* line number */ yystack_[2].location.end.line
|
/* line number */ yystack_[2].location.end.line
|
||||||
);
|
);
|
||||||
std::string err;
|
|
||||||
if (r->init(&err) == false) {
|
if (r->init(&err) == false) {
|
||||||
driver.error(yystack_[2].location, "Failed to load script: " + err);
|
driver.error(yystack_[2].location, "Failed to load script: " + err);
|
||||||
delete r;
|
delete r;
|
||||||
|
@ -1115,18 +1115,18 @@ expression:
|
|||||||
}
|
}
|
||||||
| DIRECTIVE_SECRULESCRIPT actions
|
| DIRECTIVE_SECRULESCRIPT actions
|
||||||
{
|
{
|
||||||
|
std::string err;
|
||||||
std::vector<actions::Action *> *a = new std::vector<actions::Action *>();
|
std::vector<actions::Action *> *a = new std::vector<actions::Action *>();
|
||||||
for (auto &i : *$2.get()) {
|
for (auto &i : *$2.get()) {
|
||||||
a->push_back(i.release());
|
a->push_back(i.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
RuleScript *r = new RuleScript(
|
RuleScript *r = new RuleScript(
|
||||||
/* path to script */ $1,
|
/* path to script */ $1,
|
||||||
/* actions */ a,
|
/* actions */ a,
|
||||||
/* file name */ driver.ref.back(),
|
/* file name */ driver.ref.back(),
|
||||||
/* line number */ @0.end.line
|
/* line number */ @0.end.line
|
||||||
);
|
);
|
||||||
std::string err;
|
|
||||||
if (r->init(&err) == false) {
|
if (r->init(&err) == false) {
|
||||||
driver.error(@0, "Failed to load script: " + err);
|
driver.error(@0, "Failed to load script: " + err);
|
||||||
delete r;
|
delete r;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user