From bebf9b2fb7f64415ffe3bc032875bb5543c39a07 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Fri, 22 Mar 2019 13:21:45 -0700 Subject: [PATCH] release 1.0.10 (#22) --- .codeclimate.yml | 6 +++--- .gitignore | 2 ++ Changes.md | 6 ++++++ appveyor.yml | 2 +- index.js | 22 +++++++++++----------- package.json | 2 +- {config => test/config}/karma.ini | 0 test/index.js | 22 ++++++++++++++-------- 8 files changed, 38 insertions(+), 24 deletions(-) rename {config => test/config}/karma.ini (100%) diff --git a/.codeclimate.yml b/.codeclimate.yml index 75cf8a1..a23fa86 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,9 +1,9 @@ -engines: +engines: eslint: enabled: true - channel: "eslint-3" + channel: "eslint-4" config: - config: ".eslintrc.json" + config: ".eslintrc.yaml" ratings: paths: diff --git a/.gitignore b/.gitignore index 5148e52..f8faa6b 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,5 @@ jspm_packages # Optional REPL history .node_repl_history + +package-lock.json diff --git a/Changes.md b/Changes.md index 0fb0ec0..4e7155c 100644 --- a/Changes.md +++ b/Changes.md @@ -1,4 +1,10 @@ +## 1.0.10 - 2019-03-22 + +* Add an 'if' to "blocked message" HTML header +* CI testing updates (node.js versions) +* moved config/karma.ini to test/config/karma.ini + ## 1.0.9 - 2017-08-17 * also prune syslog hostname when no PID in entry diff --git a/appveyor.yml b/appveyor.yml index 8858bc2..edbfbe0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ environment: - nodejs_version: "6" + nodejs_version: "8" install: - ps: Install-Product node $env:nodejs_version diff --git a/index.js b/index.js index e6b387c..b2dc238 100644 --- a/index.js +++ b/index.js @@ -10,29 +10,29 @@ exports.register = function () { plugin = this; plugin.get_logreader_ini(); plugin.load_karma_ini(); -}; +} exports.hook_init_http = function (next, server) { server.http.app.use('/logs/:uuid', exports.get_logs); server.http.app.use('/karma/rules', exports.get_rules); - return next(); -}; + next(); +} exports.get_logreader_ini = function () { plugin = this; plugin.cfg = plugin.config.get('log.reader.ini', function () { plugin.get_logreader_ini(); - }); + }) if (plugin.cfg.log && plugin.cfg.log.file) { log = plugin.cfg.log.file; } -}; +} exports.load_karma_ini = function () { plugin.karma_cfg = plugin.config.get('karma.ini', function () { plugin.load_karma_ini(); - }); + }) if (!plugin.karma_cfg.result_awards) return; if (!plugin.result_awards) plugin.result_awards = {}; @@ -52,11 +52,11 @@ exports.load_karma_ini = function () { resolution : parts[6], }; }); -}; +} exports.get_rules = function (req, res) { res.send(JSON.stringify(plugin.result_awards)); -}; +} exports.get_logs = function (req, res) { @@ -77,7 +77,7 @@ exports.get_logs = function (req, res) { res.send(html); }); }); -}; +} exports.grepWithShell = function (file, uuid, done) { @@ -239,13 +239,13 @@ function htmlHead () { function htmlBody (uuid, awards, resolve) { let str = ' \
\ -

Sorry we blocked your message:

\ +

Sorry if we blocked your message:

\

Our filters mistook your server for a malicious computer attempting \ to send spam. To improve your mail servers reputation, please contact \ your IT helpdesk or Systems Administrator and ask them for help.

'; if (awards) { - str += '

Policy Rules

\ + str += '

Policy Rules Matched

\ '; } diff --git a/package.json b/package.json index 57ab345..551d359 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "haraka-plugin-log-reader", - "version": "1.0.9", + "version": "1.0.10", "description": "display log entries from haraka log files via HTTP", "main": "index.js", "scripts": { diff --git a/config/karma.ini b/test/config/karma.ini similarity index 100% rename from config/karma.ini rename to test/config/karma.ini diff --git a/test/index.js b/test/index.js index ab51e12..d5a44b6 100644 --- a/test/index.js +++ b/test/index.js @@ -38,6 +38,8 @@ describe('register', () => { it('loads karma.ini', (done) => { this.reader.register() + this.reader.config = this.reader.config.module_config(path.resolve('test')); + this.reader.load_karma_ini() assert.equal(this.reader.karma_cfg.tarpit.delay, 0) done() }) @@ -56,6 +58,8 @@ describe('grepWithShell', () => { beforeEach((done) => { this.reader = new fixtures.plugin('index') this.reader.register(); + this.reader.config = this.reader.config.module_config(path.resolve('test')); + this.reader.load_karma_ini() done() }) @@ -66,8 +70,8 @@ describe('grepWithShell', () => { // console.log(r); assert.equal(r.split('\n').length - 1, 36); done(); - }); - }); + }) + }) it('reads matching transaction entries from a log file', (done) => { const logfile = path.join('test','fixtures','haraka.log'); @@ -76,8 +80,8 @@ describe('grepWithShell', () => { // console.log(r); assert.equal(r.split('\n').length - 1, 36); done(); - }); - }); + }) + }) it('formats matching entries as HTML', (done) => { const uuid = '3E6A027F-8307-4DA4-B105-2A39EC4B58D4.1'; @@ -89,15 +93,17 @@ describe('grepWithShell', () => { assert.ok(/^/.test(html)); assert.ok(/<\/html>$/.test(html)); done(); - }); - }); - }); -}); + }) + }) + }) +}) describe('asHtml', () => { beforeEach((done) => { this.reader = new fixtures.plugin('index') this.reader.register(); + this.reader.config = this.reader.config.module_config(path.resolve('test')); + this.reader.load_karma_ini() done() })