Adds capture action to verifyCC

This commit is contained in:
Felipe Zimmerle
2018-03-09 11:26:24 -03:00
parent 77a885da5f
commit df25c48f53
5 changed files with 65 additions and 5 deletions

View File

@@ -117,7 +117,8 @@ bool VerifyCC::init(const std::string &param2, std::string *error) {
}
bool VerifyCC::evaluate(Transaction *transaction, const std::string &i) {
bool VerifyCC::evaluate(Transaction *t, Rule *rule,
const std::string& i, std::shared_ptr<RuleMessage> ruleMessage) {
int offset = 0;
bool is_cc = false;
int target_length = i.length();
@@ -136,14 +137,22 @@ bool VerifyCC::evaluate(Transaction *transaction, const std::string &i) {
if (ret < 0) {
return false;
}
if (ret > 0) {
match = std::string(i, ovector[0], ovector[1] - ovector[0]);
is_cc = luhnVerify(match.c_str(), match.size());
if (is_cc) {
if (transaction) {
if (t) {
if (rule && t
&& rule->getActionsByName("capture").size() > 0) {
t->m_collections.m_tx_collection->storeOrUpdateFirst(
"0", std::string(match));
#ifndef NO_LOGS
transaction->debug(9, "CC# match \"" + m_param +
t->debug(7, "Added VerifyCC match TX.0: " + \
std::string(match));
#endif
}
#ifndef NO_LOGS
t->debug(9, "CC# match \"" + m_param +
"\" at " + i + ". [offset " +
std::to_string(offset) + "]");
#endif

View File

@@ -36,7 +36,9 @@ class VerifyCC : public Operator {
~VerifyCC();
int luhnVerify(const char *ccnumber, int len);
bool evaluate(Transaction *transaction, const std::string &input) override;
bool evaluate(Transaction *t, Rule *rule,
const std::string& input,
std::shared_ptr<RuleMessage> ruleMessage) override;
bool init(const std::string &param, std::string *error) override;
private:
pcre *m_pc;