mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds support to the action `maturity'
This commit is contained in:
parent
714df8db20
commit
8143f8ea89
@ -81,6 +81,7 @@ class Rule {
|
||||
std::string m_log_message;
|
||||
std::string m_log_data;
|
||||
int m_accuracy;
|
||||
int m_maturity;
|
||||
|
||||
private:
|
||||
bool m_unconditional;
|
||||
@ -99,7 +100,7 @@ class RuleMessage {
|
||||
m_data = std::string("");
|
||||
m_severity = 0;
|
||||
m_ver = rule->m_ver;
|
||||
m_maturity = 0;
|
||||
m_maturity = rule->m_maturity;
|
||||
m_rule = rule;
|
||||
};
|
||||
RuleMessage(Rule *rule, std::string message) {
|
||||
@ -112,7 +113,7 @@ class RuleMessage {
|
||||
m_data = std::string("");
|
||||
m_severity = 0;
|
||||
m_ver = rule->m_ver;
|
||||
m_maturity = 0;
|
||||
m_maturity = rule->m_maturity;
|
||||
m_rule = rule;
|
||||
};
|
||||
|
||||
|
@ -72,6 +72,7 @@ ACTIONS = \
|
||||
actions/init_col.cc \
|
||||
actions/deny.cc \
|
||||
actions/log_data.cc \
|
||||
actions/maturity.cc \
|
||||
actions/msg.cc \
|
||||
actions/no_audit_log.cc \
|
||||
actions/pass.cc \
|
||||
|
47
src/actions/maturity.cc
Normal file
47
src/actions/maturity.cc
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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 "actions/maturity.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/transaction.h"
|
||||
#include "src/utils.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "src/macro_expansion.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
|
||||
Maturity::Maturity(std::string action)
|
||||
: Action(action, ConfigurationKind),
|
||||
m_maturity_str(action) {
|
||||
if (m_maturity_str.at(0) == '\'') {
|
||||
m_maturity_str.erase(0, 1);
|
||||
m_maturity_str.pop_back();
|
||||
}
|
||||
m_maturity = std::stoi(m_maturity_str);
|
||||
}
|
||||
|
||||
|
||||
bool Maturity::evaluate(Rule *rule, Transaction *transaction) {
|
||||
rule->m_maturity = m_maturity;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
45
src/actions/maturity.h
Normal file
45
src/actions/maturity.h
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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 <string>
|
||||
|
||||
#include "actions/action.h"
|
||||
|
||||
#ifndef SRC_ACTIONS_MATURITY_H_
|
||||
#define SRC_ACTIONS_MATURITY_H_
|
||||
|
||||
class Transaction;
|
||||
|
||||
namespace modsecurity {
|
||||
class Transaction;
|
||||
namespace actions {
|
||||
|
||||
|
||||
class Maturity : public Action {
|
||||
public:
|
||||
explicit Maturity(std::string action);
|
||||
|
||||
bool evaluate(Rule *rule, Transaction *transaction) override;
|
||||
|
||||
private:
|
||||
std::string m_maturity_str;
|
||||
int m_maturity;
|
||||
};
|
||||
|
||||
|
||||
} // namespace actions
|
||||
} // namespace modsecurity
|
||||
|
||||
#endif // SRC_ACTIONS_MATURITY_H_
|
@ -30,6 +30,7 @@ class Driver;
|
||||
#include "actions/msg.h"
|
||||
#include "actions/phase.h"
|
||||
#include "actions/log_data.h"
|
||||
#include "actions/maturity.h"
|
||||
#include "actions/redirect.h"
|
||||
#include "actions/rev.h"
|
||||
#include "actions/ver.h"
|
||||
@ -75,6 +76,7 @@ using modsecurity::actions::Msg;
|
||||
using modsecurity::actions::Phase;
|
||||
using modsecurity::actions::transformations::None;
|
||||
using modsecurity::actions::LogData;
|
||||
using modsecurity::actions::Maturity;
|
||||
using modsecurity::actions::transformations::Transformation;
|
||||
using modsecurity::operators::Operator;
|
||||
using modsecurity::Rule;
|
||||
@ -995,7 +997,7 @@ act:
|
||||
}
|
||||
| ACTION_MATURITY
|
||||
{
|
||||
$$ = Action::instantiate($1);
|
||||
$$ = new Maturity($1);
|
||||
}
|
||||
| ACTION_CTL_BDY_XML
|
||||
{
|
||||
|
@ -83,6 +83,7 @@ Rule::Rule(std::string marker)
|
||||
m_unconditional(false),
|
||||
m_secmarker(true),
|
||||
m_marker(marker),
|
||||
m_maturity(0),
|
||||
m_referenceCount(0),
|
||||
m_fileName(""),
|
||||
m_lineNumber(0) { }
|
||||
|
Loading…
x
Reference in New Issue
Block a user