New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

haraka-plugin-karma

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

haraka-plugin-karma - npm Package Compare versions

Comparing version 1.0.1 to 1.0.3

Changes.md

23

.eslintrc.json
{
"env": {
"node": true,
"mocha": true
},
"extends": "eslint:recommended",
"installedESLint": true,
"plugins": [
"haraka"
],
"extends": [ "eslint:recommended", "plugin:haraka/recommended" ],
"root": true,
"rules": {
"comma-dangle": [2, "only-multiline"],
"dot-notation": 2,
"indent": [2, 2, {"SwitchCase": 1}],
"one-var": [2, "never"],
"no-trailing-spaces": [2, { "skipBlankLines": false }],
"keyword-spacing": [2, {
"before": true,
"after": true
}],
"no-delete-var": 2,
"no-empty": ["error", { "allowEmptyCatch": true }],
"no-label-var": 2,
"no-shadow": 2,
"no-unused-vars": [ 1, { "args": "none" }],
"no-console": 0
}
}

@@ -26,3 +26,3 @@ 'use strict';

plugin.load_karma_ini();
plugin.load_redis_ini();
plugin.merge_redis_ini();

@@ -72,4 +72,2 @@ plugin.register_hook('init_master', 'init_redis_plugin');

}
if (!cfg.redis.host) cfg.redis.host = '127.0.0.1';
if (!cfg.redis.port) cfg.redis.port = 6379;
};

@@ -114,3 +112,3 @@

// ex: karma.result_awards.clamd.fail = { .... }
Object.keys(plugin.cfg.result_awards).forEach(function(anum) {
Object.keys(plugin.cfg.result_awards).forEach(function (anum) {
// plugin, property, operator, value, award, reason, resolution

@@ -169,2 +167,4 @@ var parts = plugin.cfg.result_awards[anum].split(/(?:\s*\|\s*)/);

switch (thisAward.operator) {
case 'eq':
case 'equal':
case 'equals':

@@ -182,2 +182,5 @@ plugin.check_result_equal(thisResArr, thisAward, connection);

break;
case 'length':
plugin.check_result_length(thisResArr, thisAward, connection);
break;
}

@@ -243,3 +246,2 @@ }

/* jshint eqeqeq: false */
for (var j=0; j < thisResult.length; j++) {

@@ -275,2 +277,33 @@ if (thisAward.value === 'true') {

exports.check_result_length = function (thisResult, thisAward, conn) {
var plugin = this;
for (let j=0; j < thisResult.length; j++) {
// var [operator, qty] = thisAward.value.split(/\s+/); // requires node 6
var matches = thisAward.value.split(/\s+/);
var operator = matches[0];
var qty = matches[1];
switch (operator) {
case 'eq':
case 'equal':
case 'equals':
if (parseInt(thisResult[j], 10) != parseInt(qty, 10)) continue;
break;
case 'gt':
if (parseInt(thisResult[j], 10) <= parseInt(qty, 10)) continue;
break;
case 'lt':
if (parseInt(thisResult[j], 10) >= parseInt(qty, 10)) continue;
break;
default:
conn.results.add(plugin, { err: 'invalid operator:' + operator });
continue;
}
conn.results.incr(plugin, {score: thisAward.award});
conn.results.push(plugin, {awards: thisAward.id});
}
};
exports.apply_tarpit = function (connection, hook, score, next) {

@@ -470,3 +503,3 @@ var plugin = this;

exports.hook_unrecognized_command = function(next, connection, cmd) {
exports.hook_unrecognized_command = function (next, connection, cmd) {
var plugin = this;

@@ -731,3 +764,3 @@

var award = parseFloat(bits[0]);
if (!bits[1] || bits[1] !== 'if') { // no if conditions
if (!bits[1] || bits[1] !== 'if') { // no if conditions
if (!note) { continue; } // failed truth test

@@ -781,3 +814,3 @@ if (!wants) { // no wants, truth matches

operator + '" not supported.');
continue; // not supported!
continue;
}

@@ -855,3 +888,3 @@ break;

exports.assemble_note_obj = function(prefix, key) {
exports.assemble_note_obj = function (prefix, key) {
var note = prefix;

@@ -858,0 +891,0 @@ var parts = key.split('.');

{
"name": "haraka-plugin-karma",
"version": "1.0.1",
"version": "1.0.3",
"description": "Watch live SMTP traffic in a web interface",

@@ -25,8 +25,9 @@ "main": "index.js",

"dependencies": {
"address-rfc2821": "^1.0.1",
"haraka-constants": "^1.0.0",
"haraka-utils": "^1.0.0"
"address-rfc2821": "*",
"haraka-constants": ">=1.0.2",
"haraka-utils": "*"
},
"devDependencies": {
"eslint": ">=3",
"eslint-plugin-haraka": "*",
"haraka-test-fixtures": "*",

@@ -33,0 +34,0 @@ "nodeunit": "*"

@@ -5,2 +5,3 @@ [![Build Status][ci-img]][ci-url]

[![NPM][npm-img]][npm-url]
[![Greenkeeper badge](https://badges.greenkeeper.io/haraka/haraka-plugin-karma.svg)](https://greenkeeper.io/)

@@ -7,0 +8,0 @@ # Karma - A heuristics based reputation engine for the Haraka MTA

@@ -543,2 +543,81 @@ 'use strict';

exports.check_result_length = {
setUp : _set_up,
'eq pattern is scored': function (test) {
test.expect(2);
var award = {
id : 1, award : 2,
operator : 'length', value : 'eq 3',
reason : 'testing', resolution : 'hah',
};
this.plugin.check_result_length(['3'], award, this.connection);
// console.log(this.connection.results.store);
test.equals(this.connection.results.store.karma.score, 2);
test.equals(this.connection.results.store.karma.awards[0], 1);
test.done();
},
'eq pattern is not scored': function (test) {
test.expect(1);
var award = {
id : 1, award : 2,
operator : 'length', value : 'eq 3',
reason : 'testing', resolution : 'hah',
};
this.plugin.check_result_length(['4'], award, this.connection);
// console.log(this.connection.results.store.karma);
test.deepEqual(this.connection.results.store.karma, undefined);
test.done();
},
'gt pattern is scored': function (test) {
test.expect(2);
var award = {
id : 1, award : 2,
operator : 'length', value : 'gt 3',
reason : 'testing', resolution : 'hah',
};
this.plugin.check_result_length(['5'], award, this.connection);
// console.log(this.connection.results.store);
test.equals(this.connection.results.store.karma.score, 2);
test.equals(this.connection.results.store.karma.awards[0], 1);
test.done();
},
'gt pattern is not scored': function (test) {
test.expect(1);
var award = {
id : 1, award : 2,
operator : 'length', value : 'gt 3',
reason : 'testing', resolution : 'hah',
};
this.plugin.check_result_length(['3'], award, this.connection);
// console.log(this.connection.results.store.karma);
test.deepEqual(this.connection.results.store.karma, undefined);
test.done();
},
'lt pattern is scored': function (test) {
test.expect(2);
var award = {
id : 1, award : 2,
operator : 'length', value : 'lt 3',
reason : 'testing', resolution : 'hah',
};
this.plugin.check_result_length(['2'], award, this.connection);
// console.log(this.connection.results.store);
test.equals(this.connection.results.store.karma.score, 2);
test.equals(this.connection.results.store.karma.awards[0], 1);
test.done();
},
'lt pattern is not scored': function (test) {
test.expect(1);
var award = {
id : 1, award : 2,
operator : 'length', value : 'lt 3',
reason : 'testing', resolution : 'hah',
};
this.plugin.check_result_length(['3'], award, this.connection);
// console.log(this.connection.results.store.karma);
test.deepEqual(this.connection.results.store.karma, undefined);
test.done();
},
};
exports.check_result = {

@@ -545,0 +624,0 @@ setUp : _set_up,

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc