haraka / Haraka

A fast, highly extensible, and event driven SMTP server
https://haraka.github.io
MIT License
5.09k stars 662 forks source link

dkim_verify calls next before results are verified #1553

Closed kcberg closed 8 years ago

kcberg commented 8 years ago

Haraka version

2.8.8

Expected behavior

by the time the queue plugin is called the transaction notes should have the dkims results when a dkim signature is present.

Observed behavior

when the queue plugin is run the dkim results may or may not be on the transaction notes. Based on the callback flow in the dkim_verify.js it appears the next hook is being called to soon. next should be called in the callback of DKIMVerifyStream instead of on tx.message_stream.once('end')

Steps to reproduce

Log the presence of the DKIM-signature header and the tx.notes.dkim_results in a custom queue plugin and you'll see that some messages are queued before the tx.notes.dkim_results has been populated.

We've patched this issue in our systems by removing the message_stream.once('end', next) line of code and added calls to next into the DKIMVerifyStream callback ensuring queuing will not be called until dkim verification is complete.

baudehlo commented 8 years ago

Can you test #1566 for me? I don't use the plugin here but the fix looks sane.