Adds support to setenv action

Issue #1044
This commit is contained in:
Felipe Zimmerle
2018-09-25 10:18:43 -03:00
parent 4dd2812757
commit bc3d3f1915
12 changed files with 5137 additions and 5434 deletions

48
src/actions/set_env.cc Normal file
View File

@@ -0,0 +1,48 @@
/*
* ModSecurity, http://www.modsecurity.org/
* Copyright (c) 2015 Trustwave Holdings, Inc. (http://www.trustwave.com/)
*
* You may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* If any of the files related to licensing are missing or if you have any
* other questions related to licensing please contact Trustwave Holdings, Inc.
* directly using the email address security@modsecurity.org.
*
*/
#include "src/actions/set_env.h"
#include <iostream>
#include <string>
#include "modsecurity/transaction.h"
#include "modsecurity/rule.h"
#include "src/utils/string.h"
namespace modsecurity {
namespace actions {
bool SetENV::init(std::string *error) {
return true;
}
bool SetENV::evaluate(Rule *rule, Transaction *t) {
std::string colNameExpanded(m_string->evaluate(t));
#ifndef NO_LOGS
t->debug(8, "Setting envoriment variable: "
+ colNameExpanded + ".");
#endif
putenv((char *)colNameExpanded.c_str());
return true;
}
} // namespace actions
} // namespace modsecurity