mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 07:56:12 +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> rulesMessages;
|
||||||
std::list<std::string> ruleTags;
|
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;
|
std::string m_marker;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -140,7 +140,7 @@ class ModSecurity {
|
|||||||
ModSecurity();
|
ModSecurity();
|
||||||
~ModSecurity();
|
~ModSecurity();
|
||||||
|
|
||||||
static std::string whoAmI();
|
static const std::string whoAmI();
|
||||||
void setConnectorInformation(std::string connector);
|
void setConnectorInformation(std::string connector);
|
||||||
void setServerLogCb(LogCb cb);
|
void setServerLogCb(LogCb cb);
|
||||||
void serverLog(void *data, const std::string& msg);
|
void serverLog(void *data, const std::string& msg);
|
||||||
|
@ -23,11 +23,14 @@
|
|||||||
#define SRC_RULE_H_
|
#define SRC_RULE_H_
|
||||||
|
|
||||||
#include "modsecurity/modsecurity.h"
|
#include "modsecurity/modsecurity.h"
|
||||||
#include "variables/variable.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
|
namespace Variables {
|
||||||
|
class Variable;
|
||||||
|
}
|
||||||
|
|
||||||
class Rule {
|
class Rule {
|
||||||
public:
|
public:
|
||||||
@ -47,6 +50,8 @@ class Rule {
|
|||||||
std::vector<actions::Action *> actions_runtime_pre;
|
std::vector<actions::Action *> actions_runtime_pre;
|
||||||
std::vector<actions::Action *> actions_runtime_pos;
|
std::vector<actions::Action *> actions_runtime_pos;
|
||||||
|
|
||||||
|
std::vector<std::string> getActionNames();
|
||||||
|
|
||||||
std::vector<Variables::Variable *> *variables;
|
std::vector<Variables::Variable *> *variables;
|
||||||
int phase;
|
int phase;
|
||||||
long rule_id;
|
long rule_id;
|
@ -92,6 +92,14 @@ class RulesProperties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Rule *> rules[7];
|
std::vector<Rule *> rules[7];
|
||||||
|
std::vector<Rule *> * getRulesForPhase(int phase) {
|
||||||
|
if (phase > 7)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return &rules[phase];
|
||||||
|
};
|
||||||
|
|
||||||
// ModSecurity::Phases::NUMBER_OF_PHASES
|
// ModSecurity::Phases::NUMBER_OF_PHASES
|
||||||
std::vector<actions::Action *> defaultActions[7];
|
std::vector<actions::Action *> defaultActions[7];
|
||||||
// ModSecurity::Phases::NUMBER_OF_PHASES
|
// ModSecurity::Phases::NUMBER_OF_PHASES
|
||||||
|
@ -51,9 +51,6 @@ class Variables :
|
|||||||
|
|
||||||
std::string* resolveFirst(const std::string& var);
|
std::string* resolveFirst(const std::string& var);
|
||||||
|
|
||||||
std::string* resolveFirst(const std::string& collectionName,
|
|
||||||
const std::string& var);
|
|
||||||
|
|
||||||
|
|
||||||
void resolveSingleMatch(const std::string& var,
|
void resolveSingleMatch(const std::string& var,
|
||||||
std::vector<const transaction::Variable *> *l);
|
std::vector<const transaction::Variable *> *l);
|
||||||
|
@ -27,6 +27,7 @@ pkginclude_HEADERS = \
|
|||||||
../headers/modsecurity/debug_log.h \
|
../headers/modsecurity/debug_log.h \
|
||||||
../headers/modsecurity/intervention.h \
|
../headers/modsecurity/intervention.h \
|
||||||
../headers/modsecurity/modsecurity.h \
|
../headers/modsecurity/modsecurity.h \
|
||||||
|
../headers/modsecurity/rule.h \
|
||||||
../headers/modsecurity/rules.h \
|
../headers/modsecurity/rules.h \
|
||||||
../headers/modsecurity/rules_properties.h
|
../headers/modsecurity/rules_properties.h
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
|
|
||||||
#include "actions/block.h"
|
#include "actions/block.h"
|
||||||
#include "actions/chain.h"
|
#include "actions/chain.h"
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
#include "modsecurity/intervention.h"
|
#include "modsecurity/intervention.h"
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
|
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
#include "operators/operator.h"
|
#include "operators/operator.h"
|
||||||
#include "operators/pm.h"
|
#include "operators/pm.h"
|
||||||
#include "operators/rx.h"
|
#include "operators/rx.h"
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
#include "src/utils.h"
|
#include "src/utils.h"
|
||||||
#include "modsecurity/modsecurity.h"
|
#include "modsecurity/modsecurity.h"
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "actions/action.h"
|
#include "actions/action.h"
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
#include "src/utils.h"
|
#include "src/utils.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
#include "src/macro_expansion.h"
|
#include "src/macro_expansion.h"
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
|
|
||||||
namespace modsecurity {
|
namespace modsecurity {
|
||||||
namespace actions {
|
namespace actions {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "modsecurity/assay.h"
|
#include "modsecurity/assay.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
#include "src/macro_expansion.h"
|
#include "src/macro_expansion.h"
|
||||||
#include "src/utils.h"
|
#include "src/utils.h"
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#include "modsecurity/modsecurity.h"
|
#include "modsecurity/modsecurity.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
#include "src/config.h"
|
#include "src/config.h"
|
||||||
#include "src/unique_id.h"
|
#include "src/unique_id.h"
|
||||||
#ifdef MSC_WITH_CURL
|
#ifdef MSC_WITH_CURL
|
||||||
@ -76,7 +76,7 @@ ModSecurity::~ModSecurity() {
|
|||||||
* update it, make it in a fashion that won't break the existent parsers.
|
* 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)
|
* (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");
|
std::string platform("Unknown platform");
|
||||||
|
|
||||||
#if AIX
|
#if AIX
|
||||||
|
@ -33,7 +33,7 @@ class Driver;
|
|||||||
#include "actions/transformations/transformation.h"
|
#include "actions/transformations/transformation.h"
|
||||||
#include "actions/transformations/none.h"
|
#include "actions/transformations/none.h"
|
||||||
#include "operators/operator.h"
|
#include "operators/operator.h"
|
||||||
#include "src/rule.h"
|
#include "modsecurity/rule.h"
|
||||||
#include "utils/geo_lookup.h"
|
#include "utils/geo_lookup.h"
|
||||||
#include "audit_log.h"
|
#include "audit_log.h"
|
||||||
#include "utils.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>
|
#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) {
|
bool Rule::evaluateActions(Assay *assay) {
|
||||||
int none = 0;
|
int none = 0;
|
||||||
bool containsDisruptive = false;
|
bool containsDisruptive = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user