Skip to content

Commit 0f361b7

Browse files
author
Felipe Zimmerle
committed
Adds capture action to RBL
1 parent df25c48 commit 0f361b7

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

CHANGES

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
v3.0.x - YYYY-MMM-DD (To be released)
22
-------------------------------------
33

4+
- Adds capture action to rbl
5+
[Issue #1698 - @zimmerle]
46
- Adds capture action to verifyCC
57
[Issue #1698 - @michaelgranzow-avi, @zimmerle]
68
- Adds capture action to verifySSN

src/operators/rbl.cc

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,11 @@ void Rbl::furtherInfo(struct sockaddr_in *sin, std::string ipStr,
196196
}
197197

198198

199-
bool Rbl::evaluate(Transaction *transaction, const std::string &ipStr) {
199+
bool Rbl::evaluate(Transaction *t, Rule *rule,
200+
const std::string& ipStr,
201+
std::shared_ptr<RuleMessage> ruleMessage) {
200202
struct addrinfo *info = NULL;
201-
std::string host = mapIpToAddress(ipStr, transaction);
203+
std::string host = mapIpToAddress(ipStr, t);
202204
int rc = 0;
203205

204206
if (host.empty()) {
@@ -211,15 +213,24 @@ bool Rbl::evaluate(Transaction *transaction, const std::string &ipStr) {
211213
if (info != NULL) {
212214
freeaddrinfo(info);
213215
}
214-
debug(transaction, 5, "RBL lookup of " + ipStr + " failed.");
216+
debug(t, 5, "RBL lookup of " + ipStr + " failed.");
215217
return false;
216218
}
217219

218220
struct sockaddr *addr = info->ai_addr;
219221
struct sockaddr_in *sin = (struct sockaddr_in *) addr;
220-
furtherInfo(sin, ipStr, transaction);
222+
furtherInfo(sin, ipStr, t);
221223

222224
freeaddrinfo(info);
225+
if (rule && t
226+
&& rule->getActionsByName("capture").size() > 0) {
227+
t->m_collections.m_tx_collection->storeOrUpdateFirst(
228+
"0", std::string(ipStr));
229+
#ifndef NO_LOGS
230+
t->debug(7, "Added RXL match TX.0: " + \
231+
std::string(ipStr));
232+
#endif
233+
}
223234

224235
return true;
225236
}

src/operators/rbl.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ class Rbl : public Operator {
7575
m_provider = RblProvider::httpbl;
7676
}
7777
}
78-
bool evaluate(Transaction *transaction, const std::string &str) override;
78+
bool evaluate(Transaction *transaction, Rule *rule,
79+
const std::string& input,
80+
std::shared_ptr<RuleMessage> ruleMessage) override;
7981

8082
std::string mapIpToAddress(std::string ipStr, Transaction *trans);
8183

0 commit comments

Comments
 (0)