haraka 0.0.33 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/.githooks/pre-commit +41 -0
  2. package/.prettierignore +7 -0
  3. package/.qlty/.gitignore +7 -0
  4. package/.qlty/configs/.shellcheckrc +1 -0
  5. package/.qlty/qlty.toml +15 -0
  6. package/CHANGELOG.md +1898 -0
  7. package/CONTRIBUTORS.md +34 -0
  8. package/Dockerfile +50 -0
  9. package/LICENSE +22 -0
  10. package/Plugins.md +227 -0
  11. package/README.md +119 -4
  12. package/SECURITY.md +178 -0
  13. package/TODO +22 -0
  14. package/bin/haraka +593 -0
  15. package/bin/haraka_grep +32 -0
  16. package/config/aliases +2 -0
  17. package/config/auth_flat_file.ini +7 -0
  18. package/config/auth_vpopmaild.ini +9 -0
  19. package/config/connection.ini +79 -0
  20. package/config/delay_deny.ini +7 -0
  21. package/config/host_list +3 -0
  22. package/config/host_list_regex +6 -0
  23. package/config/http.ini +11 -0
  24. package/config/lmtp.ini +7 -0
  25. package/config/log.ini +11 -0
  26. package/config/outbound.bounce_message +18 -0
  27. package/config/outbound.bounce_message_html +36 -0
  28. package/config/outbound.bounce_message_image +106 -0
  29. package/config/outbound.ini +24 -0
  30. package/config/plugins +67 -0
  31. package/config/smtp.ini +37 -0
  32. package/config/smtp_bridge.ini +4 -0
  33. package/config/smtp_forward.ini +31 -0
  34. package/config/smtp_proxy.ini +27 -0
  35. package/config/tarpit.timeout +1 -0
  36. package/config/tls.ini +83 -0
  37. package/config/watch.ini +12 -0
  38. package/config/xclient.hosts +2 -0
  39. package/connection.js +1865 -0
  40. package/contrib/Haraka.cf +6 -0
  41. package/contrib/Haraka.pm +35 -0
  42. package/contrib/bad_smtp_server.pl +25 -0
  43. package/contrib/bsd-rc.d/haraka +63 -0
  44. package/contrib/debian-init.d/haraka +87 -0
  45. package/contrib/haraka.init +96 -0
  46. package/contrib/haraka.service +23 -0
  47. package/contrib/plugin2npm.sh +81 -0
  48. package/contrib/ubuntu-upstart/haraka.conf +27 -0
  49. package/docs/Body.md +1 -0
  50. package/docs/Config.md +1 -0
  51. package/docs/Connection.md +153 -0
  52. package/docs/CoreConfig.md +96 -0
  53. package/docs/CustomReturnCodes.md +3 -0
  54. package/docs/HAProxy.md +62 -0
  55. package/docs/Header.md +1 -0
  56. package/docs/Logging.md +129 -0
  57. package/docs/Outbound.md +210 -0
  58. package/docs/Plugins.md +372 -0
  59. package/docs/Results.md +7 -0
  60. package/docs/Transaction.md +135 -0
  61. package/docs/Tutorial.md +183 -0
  62. package/docs/deprecated/access.md +3 -0
  63. package/docs/deprecated/backscatterer.md +9 -0
  64. package/docs/deprecated/connect.rdns_access.md +53 -0
  65. package/docs/deprecated/data.headers.md +3 -0
  66. package/docs/deprecated/data.nomsgid.md +7 -0
  67. package/docs/deprecated/data.noreceived.md +11 -0
  68. package/docs/deprecated/data.rfc5322_header_checks.md +11 -0
  69. package/docs/deprecated/dkim_sign.md +97 -0
  70. package/docs/deprecated/dkim_verify.md +28 -0
  71. package/docs/deprecated/dnsbl.md +80 -0
  72. package/docs/deprecated/dnswl.md +73 -0
  73. package/docs/deprecated/lookup_rdns.strict.md +67 -0
  74. package/docs/deprecated/mail_from.access.md +52 -0
  75. package/docs/deprecated/mail_from.blocklist.md +18 -0
  76. package/docs/deprecated/mail_from.nobounces.md +8 -0
  77. package/docs/deprecated/rcpt_to.access.md +53 -0
  78. package/docs/deprecated/rcpt_to.blocklist.md +18 -0
  79. package/docs/deprecated/rcpt_to.routes.md +3 -0
  80. package/docs/deprecated/rdns.regexp.md +30 -0
  81. package/docs/plugins/aliases.md +3 -0
  82. package/docs/plugins/auth/auth_bridge.md +34 -0
  83. package/docs/plugins/auth/auth_ldap.md +4 -0
  84. package/docs/plugins/auth/auth_proxy.md +36 -0
  85. package/docs/plugins/auth/auth_vpopmaild.md +33 -0
  86. package/docs/plugins/auth/flat_file.md +40 -0
  87. package/docs/plugins/block_me.md +18 -0
  88. package/docs/plugins/data.signatures.md +11 -0
  89. package/docs/plugins/delay_deny.md +23 -0
  90. package/docs/plugins/max_unrecognized_commands.md +6 -0
  91. package/docs/plugins/prevent_credential_leaks.md +22 -0
  92. package/docs/plugins/process_title.md +42 -0
  93. package/docs/plugins/queue/deliver.md +3 -0
  94. package/docs/plugins/queue/discard.md +32 -0
  95. package/docs/plugins/queue/lmtp.md +24 -0
  96. package/docs/plugins/queue/qmail-queue.md +16 -0
  97. package/docs/plugins/queue/quarantine.md +87 -0
  98. package/docs/plugins/queue/smtp_bridge.md +32 -0
  99. package/docs/plugins/queue/smtp_forward.md +127 -0
  100. package/docs/plugins/queue/smtp_proxy.md +68 -0
  101. package/docs/plugins/queue/test.md +7 -0
  102. package/docs/plugins/rcpt_to.in_host_list.md +34 -0
  103. package/docs/plugins/rcpt_to.max_count.md +3 -0
  104. package/docs/plugins/record_envelope_addresses.md +20 -0
  105. package/docs/plugins/relay.md +3 -0
  106. package/docs/plugins/reseed_rng.md +16 -0
  107. package/docs/plugins/status.md +41 -0
  108. package/docs/plugins/tarpit.md +50 -0
  109. package/docs/plugins/tls.md +235 -0
  110. package/docs/plugins/toobusy.md +27 -0
  111. package/docs/plugins/xclient.md +10 -0
  112. package/docs/tutorials/Migrating_from_v1_to_v2.md +96 -0
  113. package/docs/tutorials/SettingUpOutbound.md +62 -0
  114. package/eslint.config.mjs +2 -0
  115. package/haraka.js +74 -0
  116. package/haraka.sh +2 -0
  117. package/http/html/404.html +58 -0
  118. package/http/html/index.html +47 -0
  119. package/http/package.json +21 -0
  120. package/line_socket.js +24 -0
  121. package/logger.js +322 -0
  122. package/outbound/client_pool.js +59 -0
  123. package/outbound/config.js +134 -0
  124. package/outbound/hmail.js +1504 -0
  125. package/outbound/index.js +349 -0
  126. package/outbound/qfile.js +93 -0
  127. package/outbound/queue.js +399 -0
  128. package/outbound/tls.js +85 -0
  129. package/outbound/todo.js +17 -0
  130. package/package.json +100 -4
  131. package/plugins/.eslintrc.yaml +3 -0
  132. package/plugins/auth/auth_base.js +261 -0
  133. package/plugins/auth/auth_bridge.js +20 -0
  134. package/plugins/auth/auth_proxy.js +227 -0
  135. package/plugins/auth/auth_vpopmaild.js +162 -0
  136. package/plugins/auth/flat_file.js +44 -0
  137. package/plugins/block_me.js +88 -0
  138. package/plugins/data.signatures.js +30 -0
  139. package/plugins/delay_deny.js +153 -0
  140. package/plugins/prevent_credential_leaks.js +61 -0
  141. package/plugins/process_title.js +197 -0
  142. package/plugins/profile.js +11 -0
  143. package/plugins/queue/deliver.js +12 -0
  144. package/plugins/queue/discard.js +27 -0
  145. package/plugins/queue/lmtp.js +45 -0
  146. package/plugins/queue/qmail-queue.js +93 -0
  147. package/plugins/queue/quarantine.js +133 -0
  148. package/plugins/queue/smtp_bridge.js +45 -0
  149. package/plugins/queue/smtp_forward.js +371 -0
  150. package/plugins/queue/smtp_proxy.js +142 -0
  151. package/plugins/queue/test.js +15 -0
  152. package/plugins/rcpt_to.host_list_base.js +65 -0
  153. package/plugins/rcpt_to.in_host_list.js +56 -0
  154. package/plugins/record_envelope_addresses.js +17 -0
  155. package/plugins/reseed_rng.js +7 -0
  156. package/plugins/status.js +274 -0
  157. package/plugins/tarpit.js +45 -0
  158. package/plugins/tls.js +164 -0
  159. package/plugins/toobusy.js +47 -0
  160. package/plugins/xclient.js +124 -0
  161. package/plugins.js +605 -0
  162. package/run_tests +11 -0
  163. package/server.js +827 -0
  164. package/smtp_client.js +504 -0
  165. package/test/.eslintrc.yaml +11 -0
  166. package/test/config/auth_flat_file.ini +5 -0
  167. package/test/config/block_me.recipient +1 -0
  168. package/test/config/block_me.senders +1 -0
  169. package/test/config/dhparams.pem +8 -0
  170. package/test/config/host_list +2 -0
  171. package/test/config/outbound_tls_cert.pem +1 -0
  172. package/test/config/outbound_tls_key.pem +1 -0
  173. package/test/config/plugins +7 -0
  174. package/test/config/smtp.ini +11 -0
  175. package/test/config/smtp_forward.ini +30 -0
  176. package/test/config/tls/example.com/_.example.com.key +28 -0
  177. package/test/config/tls/example.com/example.com.crt +25 -0
  178. package/test/config/tls/haraka.local.pem +51 -0
  179. package/test/config/tls.ini +45 -0
  180. package/test/config/tls_cert.pem +21 -0
  181. package/test/config/tls_key.pem +28 -0
  182. package/test/connection.js +820 -0
  183. package/test/fixtures/haproxy_allowed/config/connection.ini +3 -0
  184. package/test/fixtures/haproxy_disabled/config/connection.ini +3 -0
  185. package/test/fixtures/haproxy_untrusted/config/connection.ini +3 -0
  186. package/test/fixtures/line_socket.js +21 -0
  187. package/test/fixtures/todo_qfile.txt +0 -0
  188. package/test/fixtures/util_hmailitem.js +156 -0
  189. package/test/installation/config/test-plugin-flat +1 -0
  190. package/test/installation/config/test-plugin.ini +10 -0
  191. package/test/installation/config/tls.ini +1 -0
  192. package/test/installation/node_modules/load_first/index.js +5 -0
  193. package/test/installation/node_modules/load_first/package.json +11 -0
  194. package/test/installation/node_modules/test-plugin/config/test-plugin-flat +1 -0
  195. package/test/installation/node_modules/test-plugin/config/test-plugin.ini +9 -0
  196. package/test/installation/node_modules/test-plugin/package.json +5 -0
  197. package/test/installation/node_modules/test-plugin/test-plugin.js +5 -0
  198. package/test/installation/plugins/base_plugin.js +3 -0
  199. package/test/installation/plugins/folder_plugin/index.js +3 -0
  200. package/test/installation/plugins/folder_plugin/package.json +11 -0
  201. package/test/installation/plugins/inherits.js +7 -0
  202. package/test/installation/plugins/load_first.js +3 -0
  203. package/test/installation/plugins/plugin.js +1 -0
  204. package/test/installation/plugins/tls.js +3 -0
  205. package/test/logger.js +217 -0
  206. package/test/loud/config/dhparams.pem +0 -0
  207. package/test/loud/config/tls/goobered.pem +45 -0
  208. package/test/loud/config/tls.ini +43 -0
  209. package/test/mail_specimen/base64-root-part.txt +23 -0
  210. package/test/mail_specimen/varied-fold-lengths-preserve-data.txt +283 -0
  211. package/test/outbound/bounce_net_errors.js +133 -0
  212. package/test/outbound/bounce_rfc3464.js +226 -0
  213. package/test/outbound/hmail.js +210 -0
  214. package/test/outbound/index.js +385 -0
  215. package/test/outbound/qfile.js +124 -0
  216. package/test/outbound/queue.js +325 -0
  217. package/test/plugins/auth/auth_base.js +620 -0
  218. package/test/plugins/auth/auth_bridge.js +80 -0
  219. package/test/plugins/auth/auth_vpopmaild.js +81 -0
  220. package/test/plugins/auth/flat_file.js +123 -0
  221. package/test/plugins/block_me.js +141 -0
  222. package/test/plugins/data.signatures.js +111 -0
  223. package/test/plugins/delay_deny.js +262 -0
  224. package/test/plugins/prevent_credential_leaks.js +174 -0
  225. package/test/plugins/process_title.js +141 -0
  226. package/test/plugins/queue/deliver.js +98 -0
  227. package/test/plugins/queue/discard.js +78 -0
  228. package/test/plugins/queue/lmtp.js +137 -0
  229. package/test/plugins/queue/qmail-queue.js +98 -0
  230. package/test/plugins/queue/quarantine.js +80 -0
  231. package/test/plugins/queue/smtp_bridge.js +152 -0
  232. package/test/plugins/queue/smtp_forward.js +1023 -0
  233. package/test/plugins/queue/smtp_proxy.js +138 -0
  234. package/test/plugins/rcpt_to.host_list_base.js +102 -0
  235. package/test/plugins/rcpt_to.in_host_list.js +186 -0
  236. package/test/plugins/record_envelope_addresses.js +66 -0
  237. package/test/plugins/reseed_rng.js +34 -0
  238. package/test/plugins/status.js +207 -0
  239. package/test/plugins/tarpit.js +90 -0
  240. package/test/plugins/tls.js +86 -0
  241. package/test/plugins/toobusy.js +198 -0
  242. package/test/plugins/xclient.js +119 -0
  243. package/test/plugins.js +230 -0
  244. package/test/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_fixed +0 -0
  245. package/test/queue/1507509981169_1507509981169_0_61403_e0Y0Ym_1_haraka +0 -0
  246. package/test/queue/1508269674999_1508269674999_0_34002_socVUF_1_haraka +0 -0
  247. package/test/queue/1508455115683_1508455115683_0_90253_9Q4o4V_1_haraka +0 -0
  248. package/test/queue/zero-length +0 -0
  249. package/test/server.js +1012 -0
  250. package/test/smtp_client.js +1303 -0
  251. package/test/tls_socket.js +321 -0
  252. package/test/transaction.js +554 -0
  253. package/tls_socket.js +771 -0
  254. package/transaction.js +267 -0
@@ -0,0 +1,230 @@
1
+ 'use strict'
2
+
3
+ process.env.WITHOUT_CONFIG_CACHE = true
4
+
5
+ const { describe, it, beforeEach, afterEach } = require('node:test')
6
+ const assert = require('node:assert/strict')
7
+ const fs = require('node:fs')
8
+ const path = require('node:path')
9
+
10
+ const plugin = require('../plugins')
11
+
12
+ const piName = 'testPlugin'
13
+
14
+ /*
15
+
16
+ From: https://github.com/haraka/Haraka/pull/1278#issuecomment-172134064
17
+
18
+ * Need to test installed mode + core mode
19
+ * Need to test each variation of loading plugins
20
+ INSTALLED MODE
21
+ * Create test/installation/ with config/, plugins/, and node_modules
22
+ * Plugin in <install_dir>/plugins/<name>.js
23
+ * Plugin in <install_dir>/plugins/<name>/ with package.json
24
+ * Plugin in <install_dir>/node_modules/<name>/ with package.json
25
+ CORE MODE + INSTALLED MODE
26
+ * Plugin in <core>/plugins/<name>.js
27
+ * Plugin in <core>/plugins/<name>/ with package.json
28
+ * Plugin in <core>/node_modules/<name>/ with package.json
29
+ * Need to test conflict on name in various forms
30
+ * Check plugins/<name>.js loads, not node_modules/<name>/package.json
31
+ * Should be enough of a check(?)
32
+ * Need to test plugin not existing
33
+ * Check <bogus_name_guaranteed_to_not_exist> fails
34
+ * Need to test plugin existing and failing to compile
35
+ * Create bad plugin in test/installation/plugins/bad_plugin.js
36
+ * Need to test plugin inheritance
37
+ * Base plugin in test/installation/plugins/base_plugin.js
38
+ * Real plugin in test/installation/plugins/inherits.js
39
+ * Check base methods work
40
+ * Check plugin.base.base_plugin is set/correct
41
+ * Plugin timeouts (already tested)
42
+
43
+ */
44
+
45
+ describe('plugin', () => {
46
+ it('new Plugin() object', () => {
47
+ const pi = new plugin.Plugin(piName)
48
+ assert.ok(pi)
49
+ })
50
+
51
+ describe('get_timeout', () => {
52
+ const toPath = path.resolve('config', `${piName}.timeout`)
53
+ it('0s', (t, done) => {
54
+ fs.writeFile(toPath, '0', () => {
55
+ this.plugin = new plugin.Plugin(piName)
56
+ assert.equal(this.plugin.timeout, 0)
57
+ fs.unlink(toPath, done)
58
+ })
59
+ })
60
+
61
+ it('3s', (t, done) => {
62
+ fs.writeFile(toPath, '3', () => {
63
+ this.plugin = new plugin.Plugin(piName)
64
+ assert.equal(this.plugin.timeout, 3)
65
+ fs.unlink(toPath, done)
66
+ })
67
+ })
68
+
69
+ it('60s', (t, done) => {
70
+ fs.writeFile(toPath, '60', () => {
71
+ this.plugin = new plugin.Plugin(piName)
72
+ assert.equal(this.plugin.timeout, 60)
73
+ fs.unlink(toPath, done)
74
+ })
75
+ })
76
+
77
+ it('30s default (overrides NaN)', (t, done) => {
78
+ fs.writeFile(toPath, 'apple', () => {
79
+ this.plugin = new plugin.Plugin(piName)
80
+ assert.equal(this.plugin.timeout, 30)
81
+ fs.unlink(toPath, done)
82
+ })
83
+ })
84
+ })
85
+
86
+ describe('plugin_paths', () => {
87
+ beforeEach(() => {
88
+ delete process.env.HARAKA
89
+ })
90
+
91
+ afterEach(() => {
92
+ delete process.env.HARAKA
93
+ })
94
+
95
+ it('CORE plugin: (tls)', () => {
96
+ const p = new plugin.Plugin('tls')
97
+
98
+ assert.equal(p.plugin_path, path.resolve(__dirname, '..', 'plugins', 'tls.js'))
99
+ })
100
+
101
+ it('INSTALLED override: (tls)', () => {
102
+ process.env.HARAKA = path.resolve(__dirname, '..', 'test', 'installation')
103
+
104
+ const p = new plugin.Plugin('tls')
105
+
106
+ assert.equal(p.plugin_path, path.resolve(__dirname, 'installation', 'plugins', 'tls.js'))
107
+ })
108
+
109
+ it('INSTALLED node_modules package plugin: (test-plugin)', () => {
110
+ process.env.HARAKA = path.resolve(__dirname, '..', 'test', 'installation')
111
+
112
+ const p = new plugin.Plugin('test-plugin')
113
+
114
+ assert.equal(
115
+ p.plugin_path,
116
+ path.resolve(__dirname, 'installation', 'node_modules', 'test-plugin', 'package.json'),
117
+ )
118
+ assert.ok(p.hasPackageJson)
119
+ try {
120
+ p._compile()
121
+ assert.ok(true, 'compiles OK')
122
+ } catch (e) {
123
+ console.error(e.stack)
124
+ assert.ok(false, 'compiles OK')
125
+ }
126
+ })
127
+
128
+ it('CORE package plugin: redis', () => {
129
+ const p = new plugin.Plugin('haraka-plugin-redis')
130
+
131
+ assert.equal(
132
+ p.plugin_path,
133
+ path.resolve(__dirname, '..', 'node_modules', 'haraka-plugin-redis', 'package.json'),
134
+ )
135
+ assert.ok(p.hasPackageJson)
136
+ })
137
+
138
+ it('plugins overrides node_modules', () => {
139
+ process.env.HARAKA = path.resolve(__dirname, '..', 'test', 'installation')
140
+
141
+ const p = new plugin.Plugin('load_first')
142
+
143
+ assert.equal(p.plugin_path, path.resolve(__dirname, 'installation', 'plugins', 'load_first.js'))
144
+ try {
145
+ p._compile()
146
+ assert.ok(true, 'compiles OK')
147
+ } catch (e) {
148
+ console.error(e.stack)
149
+ assert.ok(false, 'compiles OK')
150
+ }
151
+ assert.ok(p.loaded_first)
152
+ })
153
+
154
+ it('INSTALLED plugins folder plugin: (folder_plugin)', () => {
155
+ process.env.HARAKA = path.resolve(__dirname, '..', 'test', 'installation')
156
+
157
+ const p = new plugin.Plugin('folder_plugin')
158
+
159
+ assert.equal(
160
+ p.plugin_path,
161
+ path.resolve(__dirname, 'installation', 'plugins', 'folder_plugin', 'package.json'),
162
+ )
163
+ assert.ok(p.hasPackageJson)
164
+ try {
165
+ p._compile()
166
+ assert.ok(true, 'compiles OK')
167
+ } catch (e) {
168
+ console.error(e.stack)
169
+ assert.ok(false, 'compiles OK')
170
+ }
171
+ })
172
+
173
+ it('Inheritance: (inherits)', () => {
174
+ process.env.HARAKA = path.resolve(__dirname, '..', 'test', 'installation')
175
+
176
+ const p = new plugin.Plugin('inherits')
177
+
178
+ assert.equal(p.plugin_path, path.resolve(__dirname, 'installation', 'plugins', 'inherits.js'))
179
+ try {
180
+ p._compile()
181
+ assert.ok(true, 'compiles OK')
182
+ } catch (e) {
183
+ console.error(e.stack)
184
+ assert.ok(false, 'compiles OK')
185
+ }
186
+ p.register()
187
+ assert.ok(p.base.base_plugin)
188
+ })
189
+ })
190
+
191
+ describe('plugin_config', () => {
192
+ beforeEach(() => {
193
+ delete process.env.HARAKA
194
+ })
195
+
196
+ afterEach(() => {
197
+ delete process.env.HARAKA
198
+ })
199
+
200
+ it('CORE plugin: (tls)', () => {
201
+ const p = new plugin.Plugin('tls')
202
+
203
+ assert.equal(p.config.root_path, path.resolve(__dirname, '..', 'config'))
204
+ assert.equal(p.config.overrides_path, undefined)
205
+ })
206
+
207
+ it('INSTALLED override: (tls)', () => {
208
+ process.env.HARAKA = path.resolve(__dirname, '..', 'test', 'installation')
209
+
210
+ const p = new plugin.Plugin('tls')
211
+
212
+ assert.equal(p.config.root_path, path.resolve(__dirname, '..', 'config'))
213
+ assert.equal(p.config.overrides_path, path.resolve(__dirname, 'installation', 'config'))
214
+ const tls_ini = p.config.get('tls.ini')
215
+ assert.equal(tls_ini.main.ciphers, 'test')
216
+ })
217
+
218
+ it('INSTALLED node_modules package plugin: (test-plugin)', () => {
219
+ process.env.HARAKA = path.resolve(__dirname, '..', 'test', 'installation')
220
+
221
+ const p = new plugin.Plugin('test-plugin')
222
+
223
+ assert.equal(
224
+ p.config.root_path,
225
+ path.resolve(__dirname, 'installation', 'node_modules', 'test-plugin', 'config'),
226
+ )
227
+ assert.equal(p.config.overrides_path, path.resolve(__dirname, 'installation', 'config'))
228
+ })
229
+ })
230
+ })
File without changes