haraka / haraka-config

Haraka config file loader and parser
https://www.npmjs.com/package/haraka-config
MIT License
10 stars 13 forks source link

default booleans in default config #61

Closed celesteking closed 5 months ago

celesteking commented 3 years ago

When there's a default config residing in Haraka dir and you're working on Haraka/plugins/xx.js , it won't consider the boolean that's been specified in that default config. Instead, it will take whatever "default" has been specified via this.config.get's booleans option. Works fine with user config residing in config dir.

echo 'bleh = false' > Haraka/config/xx.ini
// xx.js:
const cfg = this.config.get('xx.ini', { booleans: [ '+main.bleh' ] })
assert(cfg.main.bleh == false)
msimerson commented 5 months ago

I am unable to replicate this report:

diff --git a/config/spamassassin.ini b/config/spamassassin.ini
 ; messages larger than this are not scored by SA
 max_size=500000

+bleh=false
+
 ; Munge the subject of messages with a score higher than..
 ; munge_subject_threshold=5
 subject_prefix=*** SPAM ***
diff --git a/plugins/spamassassin.js b/plugins/spamassassin.js
index f1d17cab..1b5dd4e2 100644
--- a/plugins/spamassassin.js
+++ b/plugins/spamassassin.js
@@ -6,11 +6,13 @@ const utils = require('haraka-utils');

 exports.register = function () {
     this.load_spamassassin_ini();
+    this.loginfo(JSON.stringify(this.cfg.main));
 }

 exports.load_spamassassin_ini = function () {
     this.cfg = this.config.get('spamassassin.ini', {
         booleans: [
+            '+main.bleh',
             '+add_headers',
             '+check.authenticated',
             '+check.private_ip',

Result:

{
    "bleh": false,
    "add_headers": true,
    "spamd_socket": "172.16.15.6:783",
    "spamd_user": "first-recipient",
    "max_size": 500000,
    "subject_prefix": "*** SPAM ***",
    "old_headers_action": "rename",
    "modern_status_syntax": 1,
    "spamc_auth_header": "X-Haraka-Relay"
}