haraka-plugin-karma 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +7 -38
- package/Changes.md +6 -0
- package/index.js +14 -15
- package/package.json +8 -8
package/.github/workflows/ci.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
name: CI
|
|
2
2
|
|
|
3
|
-
on: [ push ]
|
|
3
|
+
on: [ push, pull_request ]
|
|
4
4
|
|
|
5
5
|
env:
|
|
6
6
|
CI: true
|
|
@@ -10,41 +10,10 @@ jobs:
|
|
|
10
10
|
lint:
|
|
11
11
|
uses: haraka/.github/.github/workflows/lint.yml@master
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
needs: lint
|
|
15
|
-
|
|
16
|
-
services:
|
|
17
|
-
redis:
|
|
18
|
-
image: redis
|
|
19
|
-
ports:
|
|
20
|
-
- 6379:6379
|
|
21
|
-
strategy:
|
|
22
|
-
matrix:
|
|
23
|
-
os: [ ubuntu-latest ]
|
|
24
|
-
node-version: [ 18, 20 ]
|
|
25
|
-
fail-fast: false
|
|
26
|
-
steps:
|
|
27
|
-
- uses: actions/checkout@v3
|
|
28
|
-
- uses: actions/setup-node@v3
|
|
29
|
-
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
|
|
30
|
-
with:
|
|
31
|
-
node-version: ${{ matrix.node-version }}
|
|
32
|
-
- run: npm install
|
|
33
|
-
- run: npm test
|
|
13
|
+
ubuntu:
|
|
14
|
+
needs: [ lint ]
|
|
15
|
+
uses: haraka/.github/.github/workflows/ubuntu.yml@master
|
|
34
16
|
|
|
35
|
-
|
|
36
|
-
needs: lint
|
|
37
|
-
|
|
38
|
-
strategy:
|
|
39
|
-
matrix:
|
|
40
|
-
os: [ windows-latest ]
|
|
41
|
-
node-version: [ 18, 20 ]
|
|
42
|
-
fail-fast: false
|
|
43
|
-
steps:
|
|
44
|
-
- uses: actions/checkout@v3
|
|
45
|
-
- uses: actions/setup-node@v3
|
|
46
|
-
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
|
|
47
|
-
with:
|
|
48
|
-
node-version: ${{ matrix.node-version }}
|
|
49
|
-
- run: npm install
|
|
50
|
-
- run: npm test
|
|
17
|
+
windows:
|
|
18
|
+
needs: [ lint ]
|
|
19
|
+
uses: haraka/.github/.github/workflows/windows.yml@master
|
package/Changes.md
CHANGED
package/index.js
CHANGED
|
@@ -169,8 +169,7 @@ exports.check_result = function (connection, message) {
|
|
|
169
169
|
if (typeof thisResult === 'string' && !thisResult) continue // empty
|
|
170
170
|
|
|
171
171
|
// do any award conditions match this result?
|
|
172
|
-
for (
|
|
173
|
-
const thisAward = pi_prop[i]
|
|
172
|
+
for (const thisAward of pi_prop) { // each award...
|
|
174
173
|
// { id: '011', operator: 'equals', value: 'all_bad', award: '-2'}
|
|
175
174
|
const thisResArr = this.result_as_array(thisResult)
|
|
176
175
|
switch (thisAward.operator) {
|
|
@@ -223,8 +222,8 @@ exports.check_result_asn = function (asn, conn) {
|
|
|
223
222
|
|
|
224
223
|
exports.check_result_lt = function (thisResult, thisAward, conn) {
|
|
225
224
|
|
|
226
|
-
for (
|
|
227
|
-
const tr = parseFloat(
|
|
225
|
+
for (const element of thisResult) {
|
|
226
|
+
const tr = parseFloat(element)
|
|
228
227
|
if (tr >= parseFloat(thisAward.value)) continue
|
|
229
228
|
if (conn.results.has('karma', 'awards', thisAward.id)) continue
|
|
230
229
|
|
|
@@ -235,8 +234,8 @@ exports.check_result_lt = function (thisResult, thisAward, conn) {
|
|
|
235
234
|
|
|
236
235
|
exports.check_result_gt = function (thisResult, thisAward, conn) {
|
|
237
236
|
|
|
238
|
-
for (
|
|
239
|
-
const tr = parseFloat(
|
|
237
|
+
for (const element of thisResult) {
|
|
238
|
+
const tr = parseFloat(element)
|
|
240
239
|
if (tr <= parseFloat(thisAward.value)) continue
|
|
241
240
|
if (conn.results.has('karma', 'awards', thisAward.id)) continue
|
|
242
241
|
|
|
@@ -247,12 +246,12 @@ exports.check_result_gt = function (thisResult, thisAward, conn) {
|
|
|
247
246
|
|
|
248
247
|
exports.check_result_equal = function (thisResult, thisAward, conn) {
|
|
249
248
|
|
|
250
|
-
for (
|
|
249
|
+
for (const element of thisResult) {
|
|
251
250
|
if (thisAward.value === 'true') {
|
|
252
|
-
if (!
|
|
251
|
+
if (!element) continue
|
|
253
252
|
}
|
|
254
253
|
else {
|
|
255
|
-
if (
|
|
254
|
+
if (element != thisAward.value) continue
|
|
256
255
|
}
|
|
257
256
|
if (!/auth/.test(thisAward.plugin)) {
|
|
258
257
|
// only auth attempts are scored > 1x
|
|
@@ -267,8 +266,8 @@ exports.check_result_equal = function (thisResult, thisAward, conn) {
|
|
|
267
266
|
exports.check_result_match = function (thisResult, thisAward, conn) {
|
|
268
267
|
const re = new RegExp(thisAward.value, 'i')
|
|
269
268
|
|
|
270
|
-
for (
|
|
271
|
-
if (!re.test(
|
|
269
|
+
for (const element of thisResult) {
|
|
270
|
+
if (!re.test(element)) continue
|
|
272
271
|
if (conn.results.has('karma', 'awards', thisAward.id)) continue
|
|
273
272
|
|
|
274
273
|
conn.results.incr(this, {score: thisAward.award})
|
|
@@ -278,20 +277,20 @@ exports.check_result_match = function (thisResult, thisAward, conn) {
|
|
|
278
277
|
|
|
279
278
|
exports.check_result_length = function (thisResult, thisAward, conn) {
|
|
280
279
|
|
|
281
|
-
for (
|
|
280
|
+
for (const element of thisResult) {
|
|
282
281
|
const [operator, qty] = thisAward.value.split(/\s+/) // requires node 6+
|
|
283
282
|
|
|
284
283
|
switch (operator) {
|
|
285
284
|
case 'eq':
|
|
286
285
|
case 'equal':
|
|
287
286
|
case 'equals':
|
|
288
|
-
if (parseInt(
|
|
287
|
+
if (parseInt(element, 10) != parseInt(qty, 10)) continue
|
|
289
288
|
break
|
|
290
289
|
case 'gt':
|
|
291
|
-
if (parseInt(
|
|
290
|
+
if (parseInt(element, 10) <= parseInt(qty, 10)) continue
|
|
292
291
|
break
|
|
293
292
|
case 'lt':
|
|
294
|
-
if (parseInt(
|
|
293
|
+
if (parseInt(element, 10) >= parseInt(qty, 10)) continue
|
|
295
294
|
break
|
|
296
295
|
default:
|
|
297
296
|
conn.results.add(this, { err: `invalid operator: ${operator}` })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "haraka-plugin-karma",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "A heuristics scoring and reputation engine for SMTP connections",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,16 +23,16 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/haraka/haraka-plugin-karma#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"address-rfc2821": "
|
|
27
|
-
"haraka-constants": "
|
|
28
|
-
"haraka-utils": "
|
|
29
|
-
"haraka-plugin-redis": "2.0.
|
|
30
|
-
"redis": "4.6.11"
|
|
26
|
+
"address-rfc2821": "^2.1.1",
|
|
27
|
+
"haraka-constants": "^1.0.2",
|
|
28
|
+
"haraka-utils": "^1.0.3",
|
|
29
|
+
"haraka-plugin-redis": "^2.0.6",
|
|
30
|
+
"redis": "^4.6.11"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"eslint": "8.55.0",
|
|
33
|
+
"eslint": "^8.55.0",
|
|
34
34
|
"eslint-plugin-haraka": "*",
|
|
35
35
|
"haraka-test-fixtures": "*",
|
|
36
|
-
"mocha": "10.2.0"
|
|
36
|
+
"mocha": "^10.2.0"
|
|
37
37
|
}
|
|
38
38
|
}
|