Handles better the memory utilization

- Added reference counts to Rule and AuditLog;
- Some memory leaks were removed, including GeoLookup;
- Deal better with parser errors;
- Overriding the AutlogLogWritter destructor.
This commit is contained in:
Felipe Zimmerle
2015-07-26 22:40:51 -03:00
parent 0e7c13e3c0
commit e016b72a8e
31 changed files with 385 additions and 169 deletions

View File

@@ -55,7 +55,7 @@ bool Action::evaluate(Rule *rule) {
void Action::fill_intervention(ModSecurityIntervention *i) {
}
Action *Action::instantiate(std::string name) {
Action *Action::instantiate(const std::string& name) {
std::string status("status:");
std::string redirect("redirect:");
std::string block("block");

View File

@@ -14,6 +14,7 @@
*/
#include <string>
#include <iostream>
#include "modsecurity/intervention.h"
@@ -31,13 +32,16 @@ namespace actions {
class Action {
public:
explicit Action(std::string _action)
explicit Action(const std::string& _action)
: action_kind(2),
action(_action) { }
explicit Action(std::string _action, int kind)
action(_action),
temporaryAction(false) { }
explicit Action(const std::string& _action, int kind)
: action_kind(kind),
action(_action) { }
action(_action),
temporaryAction(false) { }
virtual ~Action() { }
/**
*
* Define the action kind regarding to the execution time.
@@ -79,9 +83,10 @@ class Action {
virtual bool evaluate(Assay *assay);
virtual bool evaluate(Rule *rule);
static Action *instantiate(std::string action);
static Action *instantiate(const std::string& name);
virtual void fill_intervention(ModSecurityIntervention *intervention);
bool temporaryAction;
};

View File

@@ -23,12 +23,13 @@
namespace ModSecurity {
namespace actions {
Redirect::Redirect(std::string action)
: Action(action) {
this->url = action;
this->url.erase(0, 9);
this->action = action;
this->action_kind = 2;
Redirect::~Redirect() {
}
Redirect::Redirect(const std::string& action)
: Action(action, RunTimeOnlyIfMatchKind),
url(action) {
this->url = this->url.erase(0, 9);
this->status = 302;
}

View File

@@ -30,7 +30,8 @@ namespace actions {
class Redirect : public Action {
public:
explicit Redirect(std::string action);
explicit Redirect(const std::string &action);
~Redirect() override;
bool evaluate(Assay *assay) override;
int status;