mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Adds initial support to chained rules
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "actions/block.h"
|
||||
#include "actions/chain.h"
|
||||
#include "actions/redirect.h"
|
||||
#include "actions/status.h"
|
||||
#include "actions/rule_id.h"
|
||||
@@ -27,6 +28,7 @@
|
||||
#include "actions/severity.h"
|
||||
|
||||
|
||||
|
||||
#define IF_MATCH(a) \
|
||||
if (op.compare(1, std::strlen(#a), #a) == 0)
|
||||
|
||||
@@ -79,7 +81,9 @@ Action *Action::instantiate(std::string name) {
|
||||
if (name.compare(0, severity.length(), severity) == 0) {
|
||||
return new Severity(name);
|
||||
}
|
||||
|
||||
if (name == "chain") {
|
||||
return new Chain(name);
|
||||
}
|
||||
return new Action(name);
|
||||
}
|
||||
|
||||
|
35
src/actions/chain.cc
Normal file
35
src/actions/chain.cc
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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/chain.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/rule.h"
|
||||
|
||||
namespace ModSecurity {
|
||||
namespace actions {
|
||||
|
||||
|
||||
|
||||
bool Chain::evaluate(Rule *rule) {
|
||||
rule->chained = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace actions
|
||||
} // namespace ModSecurity
|
45
src/actions/chain.h
Normal file
45
src/actions/chain.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_CHAIN_H_
|
||||
#define SRC_ACTIONS_CHAIN_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
class Assay;
|
||||
|
||||
namespace ModSecurity {
|
||||
class Assay;
|
||||
class Rule;
|
||||
|
||||
namespace actions {
|
||||
|
||||
|
||||
class Chain : public Action {
|
||||
public:
|
||||
explicit Chain(std::string action)
|
||||
: Action(action, ConfigurationKind) { }
|
||||
|
||||
bool evaluate(Rule *rule) override;
|
||||
};
|
||||
|
||||
} // namespace actions
|
||||
} // namespace ModSecurity
|
||||
#endif
|
||||
|
||||
#endif // SRC_ACTIONS_CHAIN_H_
|
Reference in New Issue
Block a user