Skip to content

Commit

Permalink
fix(DKIM): Use Mailauth to calculate message body hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Oct 21, 2024
1 parent df06cba commit 9117281
Show file tree
Hide file tree
Showing 8 changed files with 1,231 additions and 1,817 deletions.
10 changes: 4 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
- uses: googleapis/release-please-action@v4
id: release
with:
release-type: node
package-name: ${{env.NPM_MODULE_NAME}}
pull-request-title-pattern: 'chore${scope}: release ${version} [skip-ci]'
# The logic below handles the npm publication:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# these if statements ensure that a publication only occurs when
# a new release is created:
if: ${{ steps.release.outputs.release_created }}
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: 20
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}
- run: npm ci
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
test:
strategy:
matrix:
node: [16.x, 18.x, 20.x]
node: [16.x, 18.x, 20.x, 22.x]
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
# Service containers to run with `container-job`
Expand Down Expand Up @@ -36,7 +36,7 @@ jobs:
mongodb-db: wildduck-test

- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- run: which mongo
Expand Down
154 changes: 0 additions & 154 deletions lib/dkim-relaxed-body.js

This file was deleted.

5 changes: 3 additions & 2 deletions lib/mail-drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ const log = require('npmlog');
const MessageParser = require('./message-parser');
const PassThrough = require('stream').PassThrough;
const LineEnds = require('./line-ends');
const DkimRelaxedBody = require('./dkim-relaxed-body');
const plugins = require('./plugins');
const mailsplit = require('mailsplit');
const util = require('util');
const libmime = require('libmime');
const StreamHash = require('./stream-hash');

let { BodyHashStream } = require('mailauth/lib/dkim/body');

const MAX_HEAD_SIZE = 2 * 1024 * 1024;

// Processes a message stream and stores it to queue
Expand Down Expand Up @@ -122,7 +123,7 @@ class MailDrop {
envelope.dkim.hashAlgo = envelope.dkim.hashAlgo || config.dkim.hashAlgo || 'sha256';
envelope.dkim.debug = envelope.dkim.hasOwnProperty('debug') ? envelope.dkim.debug : config.dkim.debug;

let dkimStream = new DkimRelaxedBody(envelope.dkim);
let dkimStream = new BodyHashStream('relaxed/relaxed', envelope.dkim.hashAlgo);
let lineEnds = new LineEnds();
dkimStream.on('hash', bodyHash => {
// store relaxed body hash for signing
Expand Down
Loading

0 comments on commit 9117281

Please sign in to comment.