1 
2 #ifndef SRC_OPERATORS_VERIFY_SVNR_H_
3 #define SRC_OPERATORS_VERIFY_SVNR_H_
4 
5 #include <string>
6 #include <memory>
7 #include <utility>
8 
9 #include "src/operators/operator.h"
10 #include "src/utils/regex.h"
11 
12 
13 namespace modsecurity {
14 using Utils::SMatch;
15 using Utils::regex_search;
16 using Utils::Regex;
17 
18 namespace operators {
19 
20 class VerifySVNR : public Operator {
21  public:
22     /** @ingroup ModSecurity_Operator */
VerifySVNR(std::unique_ptr<RunTimeString> param)23     explicit VerifySVNR(std::unique_ptr<RunTimeString> param)
24         : Operator("VerifySVNR", std::move(param)) {
25         m_re = new Regex(m_param);
26     }
27 
~VerifySVNR()28     ~VerifySVNR() {
29         delete m_re;
30     }
31 
32     bool operator=(const VerifySVNR &a) = delete;
33     VerifySVNR(const VerifySVNR &a) = delete;
34 
35     bool evaluate(Transaction *transaction, RuleWithActions *rule,
36         const std::string& input,
37         std::shared_ptr<RuleMessage> ruleMessage) override;
38 
39     bool verify(const char *ssnumber, int len);
40 
41  private:
42     Regex *m_re;
43     static int convert_to_int(const char c);
44     const char bad_svnr[12][11] = { "0000000000",
45         "0123456789",
46         "1234567890",
47         "1111111111",
48         "2222222222",
49         "3333333333",
50         "4444444444",
51         "5555555555",
52         "6666666666",
53         "7777777777",
54         "8888888888",
55         "9999999999"};
56 };
57 
58 }  // namespace operators
59 }  // namespace modsecurity
60 
61 
62 #endif  // SRC_OPERATORS_VERIFY_SVNR_H_
63 
64