Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for connect over TLS were bypassed due to the unix socket path being populated #107

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
5a379f0
fix: add missing error handler on _ping() method
Dec 8, 2022
86d7fa4
test: deactivate unix socket from default config
Dec 8, 2022
0ab41bb
ci: add self-signed certificate to node trusted store
Dec 8, 2022
667c4f6
test: typo
Dec 8, 2022
cb6b7e4
test: connect stunnel to clamav using the unix socket
Dec 8, 2022
1759b1a
ci: add 127.0.0.1 to SAN
Dec 8, 2022
8657944
ci: SAN overrides CN...
Dec 8, 2022
3d71749
ci: restart stunnel using systemd?
Dec 9, 2022
511e9ce
ci: wait for freshclam
Dec 9, 2022
66937c3
ci: elevate
Dec 9, 2022
36c3272
ci: tail
Dec 9, 2022
afccc2e
ci: tail more
Dec 9, 2022
8b7edff
ci: use the database test passed message.
Dec 9, 2022
4402033
ci: wait for clamd to open up socket
Dec 9, 2022
265cf77
ci: don't ls, folder may not exist yet
Dec 9, 2022
5c65481
ci: inspect clamav-daemon
Dec 9, 2022
ef2c063
ci: wait for freshclam to state it either notified daemon or failed to
Dec 9, 2022
33a042a
ci: remove wait on socket.
Dec 9, 2022
3219eac
ci: add ::1 to SAN IP List
Dec 9, 2022
385e76a
ci: address pesky deprecation warnings
Dec 9, 2022
79d3c0e
ci: edit file in place
Dec 9, 2022
a2d2ba0
ci: daemon-reload & some minor debugging printouts
Dec 9, 2022
1ccd2d8
ci: add on failure runner config
Dec 9, 2022
1721243
ci: stop-reconfigure-start?
Dec 9, 2022
5469753
ci: wait for socket file to exist
Dec 9, 2022
3f00caa
ci: print response
Dec 9, 2022
b499fe1
ci: test is a Socket File
Dec 9, 2022
0c0d6a2
ci: stunnel logs?
Dec 9, 2022
4f6549c
ci: override stunnel target socket on runner
Dec 9, 2022
c39e56b
ci: update /etc/file
Dec 9, 2022
e91cb98
ci: sudo
Dec 9, 2022
bd1ec17
test: stunnel listen on ipv6
Dec 9, 2022
facac40
test: test IPv4 & IPv6 explicitly
Dec 9, 2022
002e5b4
fix: use existing property
Dec 9, 2022
ace3044
test: rename test case
Dec 9, 2022
9ad857b
chore: update devdependencies
Jan 4, 2023
0f59931
build: rebuild lockfile to expunge json5 cve
Jan 4, 2023
6de4380
test: retry failed tests once, hoping it'll get over github's ubuntu …
Jan 4, 2023
6dd885b
doc: run jsdoc2md
Jan 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@ jobs:
run: sudo apt-get install clamav clamav-daemon
- name: Restart Freshclam
run: sudo systemctl restart clamav-freshclam
- name: Chill for 30 seconds
run: sleep 30
- name: Restart ClamD
run: sudo systemctl restart clamav-daemon
- name: Chill for 30 seconds again
run: sleep 30
- name: Wait for freshclam to be up to date
run: |
until sudo grep "$(date | cut -c -10)" /var/log/clamav/freshclam.log | grep -Eq 'Clamd was NOT notified|Clamd successfully notified about the update.'; do sleep 1; done;
sudo tail /var/log/clamav/freshclam.log
- name: Remove Syslog from ClamD Config & Restard ClamD
run: |
sudo systemctl stop clamav-daemon;
sudo sed -i /syslog/d /lib/systemd/system/clamav-daemon.service;
sudo systemctl daemon-reload;
cat /lib/systemd/system/clamav-daemon.service;
sudo systemctl start clamav-daemon;
- name: Install OpenSSL
run: sudo apt-get install openssl
- name: Generate Key Pair for TLS
run: openssl req -new -sha256 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost" -newkey ed25519 -keyout key.pem -nodes -x509 -days 365 -out cert.pem
run: openssl req -new -sha256 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost" -addext "subjectAltName = DNS:localhost,IP:127.0.0.1,IP:::1" -newkey ed25519 -keyout key.pem -nodes -x509 -days 365 -out cert.pem
- name: Install stunnel
run: sudo apt-get install stunnel4
- name: Install / Trust certificate
Expand All @@ -39,9 +44,13 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set stunnel config
run: sudo cp tests/stunnel.conf /etc/stunnel/
run: |
sudo cp tests/stunnel.conf /etc/stunnel/
sudo sed -i "s/\/var\/run\/clamd.scan\/clamd.sock/$(sudo cat /etc/clamav/clamd.conf |grep "LocalSocket "|cut -d " " -f 2 | sed 's/\//\\\//g')/" /etc/stunnel/stunnel.conf
- name: Restart stunnel
run: sudo /etc/init.d/stunnel4 restart
run: |
sudo systemctl restart stunnel4;
sudo ss -tlnp;
- name: Open ~ for all users to read
run: chmod 755 ~
- name: Use Node.js ${{ matrix.node-version }}
Expand All @@ -50,5 +59,17 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Wait for ClamD Socket
run: |
sudo systemctl status clamav-daemon
until [ -S $(cat /etc/clamav/clamd.conf |grep "LocalSocket "|cut -d ' ' -f 2) ]; do sleep 1; done
- name: Run tests
run: npm test
env:
NODE_EXTRA_CA_CERTS: /usr/local/share/ca-certificates/snakeoil.crt
- name: debug?
if: ${{ failure() }}
run: |
sudo journalctl -e -u stunnel4;
sudo journalctl -e -u clamav-daemon;
echo 'PING' | openssl s_client --connect localhost:3311 -ign_eof;
3 changes: 2 additions & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Initialization method.
| [options.clamdscan.reloadDb] | <code>boolean</code> | <code>false</code> | If true, will re-load the DB on ever call (slow) |
| [options.clamdscan.active] | <code>boolean</code> | <code>true</code> | If true, this module will consider using the `clamdscan` binary |
| [options.clamdscan.bypassTest] | <code>boolean</code> | <code>false</code> | If true, check to see if socket is avaliable |
| [options.clamdscan.tls] | <code>boolean</code> | <code>false</code> | If true, connect to a TLS-Termination proxy in front of ClamAV |
| [options.preference] | <code>object</code> | <code>&#x27;clamdscan&#x27;</code> | If preferred binary is found and active, it will be used by default |
| [cb] | <code>function</code> | | Callback method. Prototype: `(err, <instance of NodeClam>)` |

Expand Down Expand Up @@ -357,7 +358,7 @@ use of a TCP or UNIX Domain socket. In other words, this will not work if you on
have access to a local ClamAV binary.

**Kind**: instance method of [<code>NodeClam</code>](#NodeClam)
**Returns**: <code>Promise.&lt;object&gt;</code> - Object like: `{ file: String, isInfected: Boolean, viruses: Array }`
**Returns**: <code>Promise.&lt;object&gt;</code> - Object like: `{ file: String, isInfected: Boolean, viruses: Array } `

| Param | Type | Description |
| --- | --- | --- |
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test: all
@mkdir -p tests/mixed_scan_dir/folder1
@mkdir -p tests/mixed_scan_dir/folder2
@touch tests/clamscan-log
@./node_modules/.bin/mocha --exit --trace-warnings --trace-deprecation --retries 0 --full-trace --timeout 5000 --check-leaks --reporter spec $(TESTS)
@./node_modules/.bin/mocha --exit --trace-warnings --trace-deprecation --retries 1 --full-trace --timeout 5000 --check-leaks --reporter spec $(TESTS)
kylefarris marked this conversation as resolved.
Show resolved Hide resolved

clean:
rm -rf node_modules
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ class NodeClam {
}
}
// Host can be ignored since the default is `localhost`
else if (this.settings.tls) {
else if (this.settings.clamdscan.tls) {
client = tls.connect({ port: this.settings.clamdscan.port, timeout });
} else {
client = net.createConnection({ port: this.settings.clamdscan.port, timeout });
Expand Down Expand Up @@ -713,7 +713,7 @@ class NodeClam {
else reject(err);
}
});

client.on('error', (err) => reject(err));
client.on('data', (data) => {
if (data.toString().trim() === 'PONG') {
dataReceived = true;
Expand Down
Loading