Adds new operator to check for data leakage of Austrian social security number

This commit is contained in:
Rufus125
2019-03-27 15:14:57 +01:00
committed by Felipe Zimmerle
parent 6d266fae85
commit 86ce479b59
11 changed files with 7376 additions and 7105 deletions

View File

@@ -0,0 +1,55 @@
#ifndef SRC_OPERATORS_VERIFY_SVNR_H_
#define SRC_OPERATORS_VERIFY_SVNR_H_
#include <string>
#include <memory>
#include <utility>
#include "src/operators/operator.h"
#include "src/utils/regex.h"
namespace modsecurity {
using Utils::SMatch;
using Utils::regex_search;
using Utils::Regex;
namespace operators {
class VerifySVNR : public Operator {
public:
/** @ingroup ModSecurity_Operator */
explicit VerifySVNR(std::unique_ptr<RunTimeString> param)
: Operator("VerifySVNR", std::move(param)) {
m_re = new Regex(m_param);
}
~VerifySVNR() {
delete m_re;
}
bool evaluate(Transaction *transaction, Rule *rule,
const std::string &input) override {
return evaluate(transaction, NULL, input, NULL);
}
bool evaluate(Transaction *transaction,
const std::string &input) override {
return evaluate(transaction, NULL, input);
}
bool evaluate(Transaction *transaction, Rule *rule,
const std::string& input,
std::shared_ptr<RuleMessage> ruleMessage) override;
int convert_to_int(const char c);
bool verify(const char *ssnumber, int len);
private:
Regex *m_re;
};
} // namespace operators
} // namespace modsecurity
#endif // SRC_OPERATORS_VERIFY_SVNR_H_