Skip to content

Commit 5382626

Browse files
authored
Merge pull request #12 from cloud-ecs/spring-cleaning-2
- test: replace mocha with node:test - refactor: convert scanner stack from callbacks to async/await - ci: install and start rspamd, spamassassin, and clamd to test against - ci: install opendkim and opendmarc - clamdscan: strip file to it as clamd likely doesn't have file perms - style: prettier
2 parents 447aa0a + 52d8865 commit 5382626

52 files changed

Lines changed: 2480 additions & 2557 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,37 +20,85 @@ jobs:
2020
- uses: actions/setup-node@v6
2121
with:
2222
node-version: lts/*
23-
- run: npm ci || npm install
23+
- run: npm install
2424
- run: npm run lint
2525

2626
test:
27+
needs: [get-lts]
2728
strategy:
2829
fail-fast: false
2930
matrix:
3031
os: [ubuntu-latest]
31-
node-version: [22, 24]
32+
node-version: ${{ fromJson(needs.get-lts.outputs.lts) }}
3233
runs-on: ${{ matrix.os }}
3334
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
3435
steps:
3536
- uses: actions/checkout@v6
3637
- uses: actions/setup-node@v6
3738
with:
3839
node-version: ${{ matrix.node-version }}
39-
- run: npm ci || npm install
40+
- run: npm install
4041
- run: npm test
4142

4243
macos:
43-
strategy:
44-
fail-fast: false
45-
matrix:
46-
os: [macos-latest]
47-
node-version: [24]
48-
runs-on: ${{ matrix.os }}
49-
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
44+
runs-on: macos-latest
45+
name: Node LTS on macOS
5046
steps:
5147
- uses: actions/checkout@v6
5248
- uses: actions/setup-node@v6
5349
with:
54-
node-version: ${{ matrix.node-version }}
55-
- run: npm ci || npm install
50+
node-version: lts/*
51+
- run: npm install
5652
- run: npm test
53+
54+
get-lts:
55+
runs-on: ubuntu-latest
56+
steps:
57+
- id: get
58+
uses: msimerson/node-lts-versions@v1
59+
outputs:
60+
active: ${{ steps.get.outputs.active }}
61+
maintenance: ${{ steps.get.outputs.maintenance }}
62+
lts: ${{ steps.get.outputs.lts }}
63+
current: ${{ steps.get.outputs.current }}
64+
min: ${{ steps.get.outputs.min }}
65+
66+
live:
67+
name: live scanners
68+
runs-on: ubuntu-latest
69+
timeout-minutes: 15
70+
env:
71+
ECSD_ENV: ci
72+
steps:
73+
- uses: actions/checkout@v6
74+
- uses: actions/setup-node@v6
75+
with:
76+
node-version: lts/*
77+
- run: npm install
78+
- name: install spamassassin
79+
run: sh ./test/helpers/install-spamassassin.sh
80+
- name: install rspamd
81+
run: sh ./test/helpers/install-rspamd.sh
82+
- name: install opendkim
83+
run: sh ./test/helpers/install-opendkim.sh
84+
- name: wait for scanners to listen
85+
run: sh ./test/helpers/wait-for-scanners.sh spamd rspamd
86+
- run: npm test
87+
88+
clamav:
89+
name: clamav
90+
runs-on: ubuntu-latest
91+
timeout-minutes: 30
92+
env:
93+
ECSD_ENV: ci
94+
steps:
95+
- uses: actions/checkout@v6
96+
- uses: actions/setup-node@v6
97+
with:
98+
node-version: lts/*
99+
- run: npm install
100+
- name: install clamav
101+
run: sh ./test/helpers/install-clamav.sh
102+
- name: wait for clamd to listen
103+
run: sh ./test/helpers/wait-for-scanners.sh clamd
104+
- run: node --test --test-force-exit test/clamav.js

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ spool
66
ess.sublime-*
77
html/vendor
88
package-lock.json
9+
cloud-email-scanner.local.ini

.mocharc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

AGENTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ If a package-level instruction file exists, it is authoritative for that package
5454
- Results: `connection.transaction.results.add(this, { pass|fail|skip|msg|err, emit })`; query with `results.has(plugin, list, search)`. `emit: true` already logs the collated line — don't also `loginfo`/`logerror` the same thing. results.add(this, {err}) always logs.
5555
- Config loads via `config.get` with a hot-reload callback; declare every boolean or it stays a string and `=== true/false` silently fails:
5656
```js
57-
this.cfg = this.config.get('name.ini', { booleans: ['+a.b', '-c.d'] }, () => this.load())
57+
this.cfg = this.config.get('name.ini', { booleans: ['+a.b', '-c.d'] }, () =>
58+
this.load(),
59+
)
5860
```
5961
- Keep handlers thin. Push pure decision logic and I/O into `lib/*.js` as pure functions that return a verdict/value; the handler just maps that to `results.add` + `next`. For external I/O (DNS, network), expose an injectable seam — a swappable function whose default is the real implementation — so tests run without mocks.
6062
- If you add files outside `index.js` (e.g. a `lib/` dir), add them to `package.json` `files` so they publish.

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,18 @@ A web service that receives emails via HTTP and scans them with one or many filt
1010
- [x] rspamd
1111
- [ ] dcc
1212
- [ ] virustotal
13+
- [x] clamav
14+
- [x] bitdefender
15+
- [x] opendkim
16+
- [ ] opendmarc
17+
18+
### Still viable?
19+
1320
- [ ] fprot
1421
- [ ] f-secure
15-
- [x] clamav
1622
- [ ] eset
1723
- [ ] kaspersky
1824
- [ ] comodo
19-
- [x] bitdefender
20-
- [x] opendkim
21-
- [ ] opendmarc
2225

2326
### Legacy / Deprecated Scanners
2427

@@ -76,10 +79,9 @@ matt; result=\"Innocent\"; class=\"Whitelisted\"; probability=0.0000; confidence
7679

7780
![status page image](https://cloud.githubusercontent.com/assets/261635/11162087/56acf54a-8a46-11e5-882c-5d8b5a704d71.png)
7881

79-
80-
[ci-img]: https://travis-ci.org/cloud-ecs/ecsd.svg
81-
[ci-url]: https://travis-ci.org/cloud-ecs/ecsd
82+
[ci-img]: https://github.com/cloud-ecs/ecsd/actions/workflows/ci.yml/badge.svg
83+
[ci-url]: https://github.com/cloud-ecs/ecsd/actions/workflows/ci.yml
8284
[cov-img]: https://codecov.io/github/cloud-ecs/ecsd/coverage.svg
8385
[cov-url]: https://codecov.io/github/cloud-ecs/ecsd
84-
[qlty-img]: https://codeclimate.com/github/cloud-ecs/ecsd/badges/gpa.svg
85-
[qlty-url]: https://codeclimate.com/github/cloud-ecs/ecsd
86+
[qlty-img]: https://qlty.sh/gh/cloud-ecs/projects/ecsd/maintainability.svg
87+
[qlty-url]: https://qlty.sh/gh/cloud-ecs/projects/ecsd

cloud-email-scanner.ci.ini

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; CI overrides (ECSD_ENV=ci). The scanners are installed and started on the
2+
; GitHub runner, so point the network engines at localhost.
3+
4+
[clamav.net]
5+
host = 127.0.0.1
6+
port = 3310
7+
8+
[spamassassin.net]
9+
host = 127.0.0.1
10+
port = 783
11+
12+
[rspamd.net]
13+
host = 127.0.0.1
14+
port = 11333

cloud-email-scanner.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ port = 8000
1818

1919
[clamav.net]
2020
; host = 0.0.0.0
21-
; port = 3306
21+
; port = 3310
2222

2323
[clamav.cli]
2424
; bin = clamdscan
@@ -91,4 +91,4 @@ port = 8000
9191

9292
[dspam.cli]
9393
; bin = dspam
94-
; args = --mode=tum --process --deliver=summary --stdout <
94+
; args = --mode=tum --process --deliver=summary --stdout <

eslint.config.js

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
'use strict';
1+
'use strict'
22

3-
const js = require('@eslint/js');
4-
const globals = require('globals');
3+
const js = require('@eslint/js')
4+
const globals = require('globals')
55

66
module.exports = [
7-
js.configs.recommended,
8-
{
9-
languageOptions: {
10-
ecmaVersion: 'latest',
11-
sourceType: 'commonjs',
12-
globals: {
13-
...globals.node,
14-
...globals.mocha,
15-
},
16-
},
17-
rules: {
18-
'no-console': 'off',
19-
'no-unused-vars': 'warn',
20-
},
7+
js.configs.recommended,
8+
{
9+
languageOptions: {
10+
ecmaVersion: 'latest',
11+
sourceType: 'commonjs',
12+
globals: {
13+
...globals.node,
14+
},
2115
},
22-
];
16+
rules: {
17+
'no-console': 'off',
18+
'no-unused-vars': 'warn',
19+
},
20+
},
21+
]

0 commit comments

Comments
 (0)