Socket
Socket
Sign inDemoInstall

haraka-plugin-elasticsearch

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

haraka-plugin-elasticsearch - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

test/fixtures/elasticsearch.ini

7

Changes.md
## 1.0.6 - 2020-07-21
- add URI for connection settings
- add options to specify user & ssl connection settings
- bump elasticsearch client to version 7.8
## 1.0.5 - 2020-04-29

@@ -3,0 +10,0 @@

35

index.js

@@ -24,2 +24,3 @@ 'use strict';

'+main.log_connections',
'*.rejectUnauthorized'
]

@@ -35,5 +36,5 @@ },

// convert bare entries (w/undef values) to true
Object.keys(this.cfg.ignore_hosts).forEach(key => {
if (!this.cfg.ignore_hosts[key]) this.cfg.ignore_hosts[key]=true;
});
for (const h in this.cfg.ignore_hosts) {
if (!this.cfg.ignore_hosts[h]) this.cfg.ignore_hosts[h]=true;
}
}

@@ -57,6 +58,14 @@

// ignore all options
Object.keys(plugin.cfg.hosts).forEach(host => {
plugin.cfg.es_hosts.push(`http://${host}:9200`);
});
for (const host in plugin.cfg.hosts) {
if (plugin.cfg.hosts[host]) {
plugin.cfg.es_hosts.push(plugin.cfg.hosts[host]);
}
else {
plugin.cfg.es_hosts.push(`http://${host}:9200`);
}
}
plugin.clientArgs = { nodes: plugin.cfg.es_hosts };
if (plugin.cfg.auth) plugin.clientArgs.auth = plugin.cfg.auth;
if (plugin.cfg.ssl) plugin.clientArgs.ssl = plugin.cfg.ssl;
}

@@ -67,5 +76,3 @@

plugin.es = new Elasticsearch.Client({
nodes: plugin.cfg.es_hosts,
});
plugin.es = new Elasticsearch.Client(plugin.clientArgs);

@@ -156,5 +163,5 @@ plugin.es.ping({}, function (error) {

if (!obj || typeof obj !== 'object') return arr;
Object.keys(obj).forEach(k => {
for (const k in obj) {
arr.push({ k, v: obj[k] });
});
}
return arr;

@@ -231,3 +238,3 @@ }

Object.keys(plugin.cfg.conn_props).forEach(f => {
for (const f in plugin.cfg.conn_props) {
if (conn[f] === undefined) return;

@@ -241,3 +248,3 @@ if (conn[f] === 0) return;

}
});
}

@@ -244,0 +251,0 @@ conn_res.duration = (Date.now() - conn.start_time)/1000;

4

package.json
{
"name": "haraka-plugin-elasticsearch",
"version": "1.0.5",
"version": "1.0.6",
"description": "Haraka plugin that saves logs to Elasticsearch",

@@ -27,3 +27,3 @@ "main": "index.js",

"dependencies": {
"@elastic/elasticsearch": "^6.8",
"@elastic/elasticsearch": "^7.8",
"haraka-utils": "*"

@@ -30,0 +30,0 @@ },

@@ -16,4 +16,5 @@

process.env.WITHOUT_CONFIG_CACHE = '1';
this.connection = fixtures.connection.createConnection();
this.plugin.config.root_path = path.resolve(__dirname, '..', '..', 'config');
this.plugin.config.root_path = path.resolve('test', 'fixtures');

@@ -29,3 +30,6 @@ done();

// console.log(this.plugin.cfg);
assert.deepEqual(this.plugin.cfg.hosts, { '127.0.0.1': undefined });
assert.deepEqual(this.plugin.cfg.hosts, {
'127.0.0.1': undefined,
'172.16.10.1': 'https://user:password@172.16.10.1:9200'
});
assert.ok(this.plugin.cfg);

@@ -46,2 +50,30 @@ assert.ok(this.plugin.cfg.index);

})
it('passes through a URL string', function (done) {
this.plugin.cfg = { hosts: { '1.1.1.1': 'https://test:pass@1.1.1.1' } };
this.plugin.get_es_hosts();
assert.deepEqual(['https://test:pass@1.1.1.1'], this.plugin.cfg.es_hosts);
done();
})
it('applies auth & ssl config to client config', function (done) {
console.log(this.plugin.cfg);
this.plugin.config.root_path = path.resolve('test', 'fixtures');
this.plugin.load_es_ini();
// console.log(this.plugin.cfg);
assert.deepEqual(this.plugin.clientArgs, {
auth: {
username: "haraka",
password: "nice-long-pass-phrase"
},
nodes: [
"https://user:password@172.16.10.1:9200",
"http://127.0.0.1:9200"
],
"ssl": {
"rejectUnauthorized": false
}
});
done();
})
})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc