Skip to content

Commit

Permalink
Release v2.1.3 (#56)
Browse files Browse the repository at this point in the history
- ci: use shared configs
- style(es6): replace for..i with for...of
- deps(*): bump versions to latest
  • Loading branch information
msimerson authored Dec 13, 2023
1 parent 9209e65 commit 19e2fff
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 61 deletions.
45 changes: 7 additions & 38 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on: [ push ]
on: [ push, pull_request ]

env:
CI: true
Expand All @@ -10,41 +10,10 @@ jobs:
lint:
uses: haraka/.github/.github/workflows/lint.yml@master

test:
needs: lint
runs-on: ${{ matrix.os }}
services:
redis:
image: redis
ports:
- 6379:6379
strategy:
matrix:
os: [ ubuntu-latest ]
node-version: [ 18, 20 ]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
ubuntu:
needs: [ lint ]
uses: haraka/.github/.github/workflows/ubuntu.yml@master

test-win:
needs: lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest ]
node-version: [ 18, 20 ]
fail-fast: false
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
windows:
needs: [ lint ]
uses: haraka/.github/.github/workflows/windows.yml@master
6 changes: 6 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@

#### N.N.N - YYYY-MM-DD

### [2.1.3] - 2023-12-12

- ci: use shared configs
- style(es6): replace for..i with for...of
- deps(*): bump versions to latest


### [2.1.2] - 2023-12-11

Expand Down
29 changes: 14 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ exports.check_result = function (connection, message) {
if (typeof thisResult === 'string' && !thisResult) continue // empty

// do any award conditions match this result?
for (let i=0; i < pi_prop.length; i++) { // each award...
const thisAward = pi_prop[i]
for (const thisAward of pi_prop) { // each award...
// { id: '011', operator: 'equals', value: 'all_bad', award: '-2'}
const thisResArr = this.result_as_array(thisResult)
switch (thisAward.operator) {
Expand Down Expand Up @@ -223,8 +222,8 @@ exports.check_result_asn = function (asn, conn) {

exports.check_result_lt = function (thisResult, thisAward, conn) {

for (let j=0; j < thisResult.length; j++) {
const tr = parseFloat(thisResult[j])
for (const element of thisResult) {
const tr = parseFloat(element)
if (tr >= parseFloat(thisAward.value)) continue
if (conn.results.has('karma', 'awards', thisAward.id)) continue

Expand All @@ -235,8 +234,8 @@ exports.check_result_lt = function (thisResult, thisAward, conn) {

exports.check_result_gt = function (thisResult, thisAward, conn) {

for (let j=0; j < thisResult.length; j++) {
const tr = parseFloat(thisResult[j])
for (const element of thisResult) {
const tr = parseFloat(element)
if (tr <= parseFloat(thisAward.value)) continue
if (conn.results.has('karma', 'awards', thisAward.id)) continue

Expand All @@ -247,12 +246,12 @@ exports.check_result_gt = function (thisResult, thisAward, conn) {

exports.check_result_equal = function (thisResult, thisAward, conn) {

for (let j=0; j < thisResult.length; j++) {
for (const element of thisResult) {
if (thisAward.value === 'true') {
if (!thisResult[j]) continue
if (!element) continue
}
else {
if (thisResult[j] != thisAward.value) continue
if (element != thisAward.value) continue
}
if (!/auth/.test(thisAward.plugin)) {
// only auth attempts are scored > 1x
Expand All @@ -267,8 +266,8 @@ exports.check_result_equal = function (thisResult, thisAward, conn) {
exports.check_result_match = function (thisResult, thisAward, conn) {
const re = new RegExp(thisAward.value, 'i')

for (let i=0; i < thisResult.length; i++) {
if (!re.test(thisResult[i])) continue
for (const element of thisResult) {
if (!re.test(element)) continue
if (conn.results.has('karma', 'awards', thisAward.id)) continue

conn.results.incr(this, {score: thisAward.award})
Expand All @@ -278,20 +277,20 @@ exports.check_result_match = function (thisResult, thisAward, conn) {

exports.check_result_length = function (thisResult, thisAward, conn) {

for (let j=0; j < thisResult.length; j++) {
for (const element of thisResult) {
const [operator, qty] = thisAward.value.split(/\s+/) // requires node 6+

switch (operator) {
case 'eq':
case 'equal':
case 'equals':
if (parseInt(thisResult[j], 10) != parseInt(qty, 10)) continue
if (parseInt(element, 10) != parseInt(qty, 10)) continue
break
case 'gt':
if (parseInt(thisResult[j], 10) <= parseInt(qty, 10)) continue
if (parseInt(element, 10) <= parseInt(qty, 10)) continue
break
case 'lt':
if (parseInt(thisResult[j], 10) >= parseInt(qty, 10)) continue
if (parseInt(element, 10) >= parseInt(qty, 10)) continue
break
default:
conn.results.add(this, { err: `invalid operator: ${operator}` })
Expand Down
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "haraka-plugin-karma",
"version": "2.1.2",
"version": "2.1.3",
"description": "A heuristics scoring and reputation engine for SMTP connections",
"main": "index.js",
"scripts": {
Expand All @@ -23,16 +23,16 @@
},
"homepage": "https://github.com/haraka/haraka-plugin-karma#readme",
"dependencies": {
"address-rfc2821": "*",
"haraka-constants": ">=1.0.2",
"haraka-utils": "*",
"haraka-plugin-redis": "2.0.5",
"redis": "4.6.11"
"address-rfc2821": "^2.1.1",
"haraka-constants": "^1.0.2",
"haraka-utils": "^1.0.3",
"haraka-plugin-redis": "^2.0.6",
"redis": "^4.6.11"
},
"devDependencies": {
"eslint": "8.55.0",
"eslint": "^8.55.0",
"eslint-plugin-haraka": "*",
"haraka-test-fixtures": "*",
"mocha": "10.2.0"
"mocha": "^10.2.0"
}
}

0 comments on commit 19e2fff

Please sign in to comment.