haraka-plugin-karma
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -8,5 +8,4 @@ { | ||
"rules": { | ||
"indent": [2, 2, {"SwitchCase": 1}], | ||
"no-console": 0 | ||
"indent": [2, 2, {"SwitchCase": 1}] | ||
} | ||
} |
## 1.0.7 - 2017-06-16 | ||
- update for eslint 4 compat | ||
- Add results_redis_publish=true for haraka-results changes #9 | ||
## 1.0.6 - 2017-05-04 | ||
@@ -3,0 +8,0 @@ |
77
index.js
@@ -17,4 +17,4 @@ 'use strict'; | ||
plugin.deny_hooks = utils.to_object( | ||
['unrecognized_command','helo','data','data_post','queue'] | ||
); | ||
['unrecognized_command','helo','data','data_post','queue'] | ||
); | ||
plugin.deny_exclude_hooks = utils.to_object('rcpt_to, queue'); | ||
@@ -33,2 +33,4 @@ plugin.deny_exclude_plugins = utils.to_object([ | ||
plugin.register_hook('connect_init', 'ip_history_from_redis'); | ||
plugin.server.notes.results_redis_publish = true; | ||
}; | ||
@@ -527,17 +529,19 @@ | ||
var results = { | ||
good: dbr.good, | ||
bad: dbr.bad, | ||
connections: dbr.connections, | ||
history: parseInt((dbr.good || 0) - (dbr.bad || 0)), | ||
emit: true, | ||
} | ||
// Careful: don't become self-fulfilling prophecy. | ||
if (parseInt(dbr.good) > 5 && parseInt(dbr.bad) === 0) { | ||
connection.results.add(plugin, {pass: 'all_good'}); | ||
results.pass = 'all_good'; | ||
} | ||
if (parseInt(dbr.bad) > 5 && parseInt(dbr.good) === 0) { | ||
connection.results.add(plugin, {fail: 'all_bad'}); | ||
results.fail = 'all_bad'; | ||
} | ||
connection.results.add(plugin, { | ||
good: dbr.good, | ||
bad: dbr.bad, | ||
connections: dbr.connections, | ||
history: parseInt((dbr.good || 0) - (dbr.bad || 0)), | ||
emit: true, | ||
}); | ||
connection.results.add(plugin, results); | ||
@@ -838,5 +842,5 @@ plugin.check_awards(connection); | ||
var trimmed = nl.substring(0, 5) === 'notes' ? nl.substring(6) : | ||
nl.substring(0, 7) === 'results' ? nl.substring(8) : | ||
nl.substring(0,19) === 'transaction.results' ? | ||
nl.substring(20) : nl; | ||
nl.substring(0, 7) === 'results' ? nl.substring(8) : | ||
nl.substring(0,19) === 'transaction.results' ? | ||
nl.substring(20) : nl; | ||
@@ -895,13 +899,10 @@ if (trimmed.substring(0,7) === 'rcpt_to') trimmed = trimmed.substring(8); | ||
var plugin = this; | ||
if (!plugin.db) return; | ||
var report_as = plugin; | ||
var report_msg = 'asn'; | ||
var report_as = { name: plugin.name }; | ||
if (plugin.cfg.asn.report_as) { | ||
report_as = { name: plugin.cfg.asn.report_as }; | ||
report_msg = 'karma'; | ||
report_as.name = plugin.cfg.asn.report_as; | ||
} | ||
if (!plugin.db) return; | ||
plugin.db.hgetall(asnkey, function (err, res) { | ||
@@ -921,8 +922,16 @@ if (err) { | ||
var asn_score = parseInt(res.good || 0) - (res.bad || 0); | ||
var asn_results = { | ||
asn_score: asn_score, | ||
asn_connections: res.connections, | ||
asn_good: res.good, | ||
asn_bad: res.bad, | ||
emit: true, | ||
} | ||
if (asn_score) { | ||
if (asn_score < -5) { | ||
connection.results.add(report_as, {fail: report_msg}); | ||
asn_results.fail = 'asn:history'; | ||
} | ||
else if (asn_score > 5) { | ||
connection.results.add(report_as, {pass: report_msg}); | ||
asn_results.pass = 'asn:history'; | ||
} | ||
@@ -932,15 +941,9 @@ } | ||
if (parseInt(res.bad) > 5 && parseInt(res.good) === 0) { | ||
connection.results.add(report_as, {fail: 'asn_all_bad'}); | ||
asn_results.fail = 'asn:all_bad'; | ||
} | ||
if (parseInt(res.good) > 5 && parseInt(res.bad) === 0) { | ||
connection.results.add(report_as, {pass: 'asn_all_good'}); | ||
asn_results.pass = 'asn:all_good'; | ||
} | ||
connection.results.add(report_as, { | ||
asn_score: asn_score, | ||
asn_connections: res.connections, | ||
asn_good: res.good, | ||
asn_bad: res.bad, | ||
emit: true, | ||
}); | ||
connection.results.add(report_as, asn_results); | ||
}); | ||
@@ -953,5 +956,5 @@ }; | ||
plugin.db.multi() | ||
.hmset(dbkey, {'bad': 0, 'good': 0, 'connections': 1}) | ||
.expire(dbkey, expire) | ||
.exec(); | ||
.hmset(dbkey, {'bad': 0, 'good': 0, 'connections': 1}) | ||
.expire(dbkey, expire) | ||
.exec(); | ||
}; | ||
@@ -974,5 +977,5 @@ | ||
plugin.db.multi() | ||
.hmset(asnkey, {'bad': 0, 'good': 0, 'connections': 1}) | ||
.expire(asnkey, expire * 2) // keep ASN longer | ||
.exec(); | ||
.hmset(asnkey, {'bad': 0, 'good': 0, 'connections': 1}) | ||
.expire(asnkey, expire * 2) // keep ASN longer | ||
.exec(); | ||
}; |
{ | ||
"name": "haraka-plugin-karma", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "Watch live SMTP traffic in a web interface", | ||
@@ -9,2 +9,3 @@ "main": "index.js", | ||
"lint": "./node_modules/.bin/eslint *.js test/*.js", | ||
"lintfix": "./node_modules/.bin/eslint --fix *.js test/*.js", | ||
"cover": "./node_modules/.bin/istanbul cover ./run_tests" | ||
@@ -11,0 +12,0 @@ }, |
@@ -194,2 +194,3 @@ [![Build Status][ci-img]][ci-url] | ||
[p0f-url]: /manual/plugins/connect.p0f.html | ||
@@ -196,0 +197,0 @@ [geoip-url]: https://github.com/haraka/haraka-plugin-geoip |
@@ -115,3 +115,3 @@ 'use strict'; | ||
this.plugin.hook_deny(next, this.connection, | ||
['','','','','','rcpt_to']); | ||
['','','','','','rcpt_to']); | ||
}, | ||
@@ -273,3 +273,3 @@ 'pi_hook=queue': function (test) { | ||
this.connection.results.add('auth/auth_base', | ||
{fail: 'PLAIN'}); | ||
{fail: 'PLAIN'}); | ||
var r = this.plugin.check_awards(this.connection); | ||
@@ -635,3 +635,3 @@ test.equal(undefined, r); | ||
this.plugin.check_result(this.connection, | ||
'{"plugin":"geoip","result":{"country":"CN"}}'); | ||
'{"plugin":"geoip","result":{"country":"CN"}}'); | ||
// console.log(this.connection.results.store); | ||
@@ -650,3 +650,3 @@ test.equals(this.connection.results.store.karma.score, 2); | ||
this.plugin.check_result(this.connection, | ||
'{"plugin":"dnsbl","result":{"fail":"dnsbl.sorbs.net"}}'); | ||
'{"plugin":"dnsbl","result":{"fail":"dnsbl.sorbs.net"}}'); | ||
// console.log(this.connection.results.store); | ||
@@ -653,0 +653,0 @@ test.equals(this.connection.results.store.karma.score, -5); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
81849
217
1