mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Fix a few things to provide an easy interface for script bindings
This commit is contained in:
parent
ac10d8863c
commit
fb3696ac04
@ -173,7 +173,7 @@ class Assay {
|
||||
std::list<std::string> rulesMessages;
|
||||
std::list<std::string> ruleTags;
|
||||
|
||||
std::list<std::pair<int, std::string>> auditLogModifier;
|
||||
std::list< std::pair<int, std::string> > auditLogModifier;
|
||||
std::string m_marker;
|
||||
|
||||
private:
|
||||
|
@ -140,7 +140,7 @@ class ModSecurity {
|
||||
ModSecurity();
|
||||
~ModSecurity();
|
||||
|
||||
static std::string whoAmI();
|
||||
static const std::string whoAmI();
|
||||
void setConnectorInformation(std::string connector);
|
||||
void setServerLogCb(LogCb cb);
|
||||
void serverLog(void *data, const std::string& msg);
|
||||
|
@ -23,11 +23,14 @@
|
||||
#define SRC_RULE_H_
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "variables/variable.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
namespace modsecurity {
|
||||
namespace Variables {
|
||||
class Variable;
|
||||
}
|
||||
|
||||
class Rule {
|
||||
public:
|
||||
@ -47,6 +50,8 @@ class Rule {
|
||||
std::vector<actions::Action *> actions_runtime_pre;
|
||||
std::vector<actions::Action *> actions_runtime_pos;
|
||||
|
||||
std::vector<std::string> getActionNames();
|
||||
|
||||
std::vector<Variables::Variable *> *variables;
|
||||
int phase;
|
||||
long rule_id;
|
@ -92,6 +92,14 @@ class RulesProperties {
|
||||
}
|
||||
|
||||
std::vector<Rule *> rules[7];
|
||||
std::vector<Rule *> * getRulesForPhase(int phase) {
|
||||
if (phase > 7)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return &rules[phase];
|
||||
};
|
||||
|
||||
// ModSecurity::Phases::NUMBER_OF_PHASES
|
||||
std::vector<actions::Action *> defaultActions[7];
|
||||
// ModSecurity::Phases::NUMBER_OF_PHASES
|
||||
|
@ -51,9 +51,6 @@ class Variables :
|
||||
|
||||
std::string* resolveFirst(const std::string& var);
|
||||
|
||||
std::string* resolveFirst(const std::string& collectionName,
|
||||
const std::string& var);
|
||||
|
||||
|
||||
void resolveSingleMatch(const std::string& var,
|
||||
std::vector<const transaction::Variable *> *l);
|
||||
|
@ -27,6 +27,7 @@ pkginclude_HEADERS = \
|
||||
../headers/modsecurity/debug_log.h \
|
||||
../headers/modsecurity/intervention.h \
|
||||
../headers/modsecurity/modsecurity.h \
|
||||
../headers/modsecurity/rule.h \
|
||||
../headers/modsecurity/rules.h \
|
||||
../headers/modsecurity/rules_properties.h
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
|
||||
#include "actions/block.h"
|
||||
#include "actions/chain.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "modsecurity/intervention.h"
|
||||
|
||||
namespace modsecurity {
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "operators/operator.h"
|
||||
#include "operators/pm.h"
|
||||
#include "operators/rx.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "src/utils.h"
|
||||
#include "modsecurity/modsecurity.h"
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "actions/action.h"
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/utils.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "src/macro_expansion.h"
|
||||
|
||||
namespace modsecurity {
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
|
||||
namespace modsecurity {
|
||||
namespace actions {
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "modsecurity/assay.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "src/macro_expansion.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "modsecurity/modsecurity.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "src/config.h"
|
||||
#include "src/unique_id.h"
|
||||
#ifdef MSC_WITH_CURL
|
||||
@ -76,7 +76,7 @@ ModSecurity::~ModSecurity() {
|
||||
* update it, make it in a fashion that won't break the existent parsers.
|
||||
* (e.g. adding extra information _only_ to the end of the string)
|
||||
*/
|
||||
std::string ModSecurity::whoAmI() {
|
||||
const std::string ModSecurity::whoAmI() {
|
||||
std::string platform("Unknown platform");
|
||||
|
||||
#if AIX
|
||||
|
@ -33,7 +33,7 @@ class Driver;
|
||||
#include "actions/transformations/transformation.h"
|
||||
#include "actions/transformations/none.h"
|
||||
#include "operators/operator.h"
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
#include "utils/geo_lookup.h"
|
||||
#include "audit_log.h"
|
||||
#include "utils.h"
|
||||
|
21
src/rule.cc
21
src/rule.cc
@ -13,7 +13,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "src/rule.h"
|
||||
#include "modsecurity/rule.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -135,6 +135,25 @@ Rule::Rule(Operator *_op,
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> Rule::getActionNames() {
|
||||
std::vector<std::string> a;
|
||||
for (auto &z : this->actions_runtime_pos)
|
||||
{
|
||||
a.push_back(z->action);
|
||||
}
|
||||
for (auto &z : this->actions_runtime_pre)
|
||||
{
|
||||
a.push_back(z->action);
|
||||
}
|
||||
for (auto &z : this->actions_conf)
|
||||
{
|
||||
a.push_back(z->action);
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
|
||||
bool Rule::evaluateActions(Assay *assay) {
|
||||
int none = 0;
|
||||
bool containsDisruptive = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user