mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-19 02:40:35 +03:00
Adds support to the @rbl operator
This commit is contained in:
@@ -16,6 +16,12 @@
|
||||
#ifndef SRC_OPERATORS_RBL_H_
|
||||
#define SRC_OPERATORS_RBL_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "operators/operator.h"
|
||||
@@ -27,9 +33,64 @@ namespace operators {
|
||||
|
||||
class Rbl : public Operator {
|
||||
public:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
enum RblProvider {
|
||||
/**
|
||||
* UnknownProvider
|
||||
*
|
||||
*/
|
||||
UnknownProvider,
|
||||
/**
|
||||
* httpbl.org
|
||||
*
|
||||
*/
|
||||
httpbl,
|
||||
/**
|
||||
* uribl.com
|
||||
*
|
||||
*/
|
||||
uribl,
|
||||
/**
|
||||
* spamhaus.org
|
||||
*
|
||||
*/
|
||||
spamhaus,
|
||||
};
|
||||
|
||||
/** @ingroup ModSecurity_Operator */
|
||||
Rbl(std::string o, std::string p, bool i);
|
||||
Rbl(std::string op, std::string param, bool negation)
|
||||
: Operator(op, param, negation),
|
||||
m_demandsPassword(false),
|
||||
m_service(param) {
|
||||
m_provider = RblProvider::UnknownProvider;
|
||||
if (m_service == "httpbl.org") {
|
||||
m_demandsPassword = true;
|
||||
m_provider = RblProvider::httpbl;
|
||||
} else if (m_service == "uribl.com") {
|
||||
m_provider = RblProvider::httpbl;
|
||||
} else if (m_service == "spamhaus.org") {
|
||||
m_provider = RblProvider::httpbl;
|
||||
}
|
||||
}
|
||||
|
||||
bool evaluate(Transaction *transaction, const std::string &str) override;
|
||||
|
||||
std::string mapIpToAddress(std::string ipStr, Transaction *trans);
|
||||
|
||||
void futherInfo_httpbl(struct sockaddr_in *sin, std::string ipStr,
|
||||
Transaction *trans);
|
||||
void futherInfo_spamhaus(unsigned int high8bits, std::string ipStr,
|
||||
Transaction *trans);
|
||||
void futherInfo_uribl(unsigned int high8bits, std::string ipStr,
|
||||
Transaction *trans);
|
||||
void furtherInfo(struct sockaddr_in *sin, std::string ipStr,
|
||||
Transaction *trans);
|
||||
|
||||
std::string m_service;
|
||||
bool m_demandsPassword;
|
||||
RblProvider m_provider;
|
||||
};
|
||||
|
||||
} // namespace operators
|
||||
|
||||
Reference in New Issue
Block a user