Skip to content

Commit

Permalink
release 1.0.10 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson authored Mar 22, 2019
1 parent 607301f commit bebf9b2
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
engines:
engines:
eslint:
enabled: true
channel: "eslint-3"
channel: "eslint-4"
config:
config: ".eslintrc.json"
config: ".eslintrc.yaml"

ratings:
paths:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ jspm_packages

# Optional REPL history
.node_repl_history

package-lock.json
6 changes: 6 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
environment:
nodejs_version: "6"
nodejs_version: "8"

install:
- ps: Install-Product node $env:nodejs_version
Expand Down
22 changes: 11 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
Expand All @@ -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) {

Expand All @@ -77,7 +77,7 @@ exports.get_logs = function (req, res) {
res.send(html);
});
});
};
}

exports.grepWithShell = function (file, uuid, done) {

Expand Down Expand Up @@ -239,13 +239,13 @@ function htmlHead () {
function htmlBody (uuid, awards, resolve) {
let str = '<body> \
<div class="tab-content"> \
<h3>Sorry we blocked your message:</h3> \
<h3>Sorry if we blocked your message:</h3> \
<p>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.</p>';

if (awards) {
str += '<hr><h3>Policy Rules</h3> \
str += '<hr><h3>Policy Rules Matched</h3> \
<ul>' + awards + '</ul>';
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
File renamed without changes.
22 changes: 14 additions & 8 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
Expand All @@ -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()
})

Expand All @@ -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');
Expand All @@ -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';
Expand All @@ -89,15 +93,17 @@ describe('grepWithShell', () => {
assert.ok(/^<html>/.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()
})

Expand Down

0 comments on commit bebf9b2

Please sign in to comment.