Skip to content

Commit

Permalink
Merge pull request #20 from haraka/19-unparseable-from
Browse files Browse the repository at this point in the history
wrap from header parse attempt in a try
  • Loading branch information
msimerson authored Apr 10, 2020
2 parents 69b232a + 4b43f6a commit 07d9442
Show file tree
Hide file tree
Showing 14 changed files with 517 additions and 435 deletions.
9 changes: 6 additions & 3 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
engines:
engines:
eslint:
enabled: true
channel: "eslint-3"
channel: "eslint-6"
config:
config: ".eslintrc.json"
config: ".eslintrc.yaml"
checks:
complexity:
enabled: false

ratings:
paths:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/ci-test-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CI Tests - Windows

on: [ push, pull_request ]

# no docker/images support on Windows (currently), so run w/o Redis
# also, stack run commands so test doesn't begin before install completes

jobs:

ci-test-win:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ windows-latest ]
node-version: [10.x, 12.x, 13.x]
fail-fast: false

steps:
- uses: actions/checkout@v1
name: Checkout haraka-plugin-access
with:
fetch-depth: 1

- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}

- name: npm install and test
run: |
npm install
npm run test
env:
CI: true
35 changes: 35 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI Tests

on: [ push, pull_request ]

jobs:

ci-test:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest ]
node-version: [10.x, 12.x]
fail-fast: false

steps:
- uses: actions/checkout@v1
name: Checkout haraka-plugin-access
with:
fetch-depth: 1

- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}

- name: npm install
run: npm install

- name: Run test suite
run: npm run test

env:
CI: true
32 changes: 32 additions & 0 deletions .github/workflows/coveralls.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on: [ pull_request ]

name: Test Coverage

jobs:

coverage:
name: Codecov
runs-on: ubuntu-latest

steps:

- uses: actions/checkout@master
name: Checkout haraka-plugin-access
with:
fetch-depth: 1

- name: Use Node.js 10
uses: actions/setup-node@master
with:
node-version: 10.x

- name: install, run
run: |
npm install
npm install --no-save nyc codecov
npm run cover
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Lint

on: [ push, pull_request ]

jobs:

lint:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 12.x ]

steps:
- uses: actions/checkout@v1
name: Checkout haraka-plugin-access
with:
fetch-depth: 1

- uses: actions/setup-node@v1
name: Use Node.js ${{ matrix.node-version }}
with:
node-version: ${{ matrix.node-version }}

- name: npm install
run: npm install

- name: Lint using eslint
run: npm run lint

env:
CI: true
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

4 changes: 4 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# 1.1.4 - 2020-04-09

- wrap from parsing in a try #20

# 1.1.3 - 2018-11-16

- check if OD was found before attemping to use it
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[![Build Status][ci-img]][ci-url]
[![Code Climate][clim-img]][clim-url]
[![Greenkeeper badge][gk-img]][gk-url]
[![NPM][npm-img]][npm-url]
[![Windows Build Status][ci-win-img]][ci-win-url]

[![NPM][npm-img]][npm-url]

# haraka-plugin-access - ACLs

This plugin applies Access Control Lists during the connect, helo, mail, and
Expand Down Expand Up @@ -222,7 +222,5 @@ OD is *bbc.co.uk*.
[ci-win-url]: https://ci.appveyor.com/project/msimerson/haraka-plugin-access
[clim-img]: https://codeclimate.com/github/haraka/haraka-plugin-access/badges/gpa.svg
[clim-url]: https://codeclimate.com/github/haraka/haraka-plugin-access
[gk-img]: https://badges.greenkeeper.io/haraka/haraka-plugin-access.svg
[gk-url]: https://greenkeeper.io/
[npm-img]: https://nodei.co/npm/haraka-plugin-access.png
[npm-url]: https://www.npmjs.com/package/haraka-plugin-access
20 changes: 0 additions & 20 deletions appveyor.yml

This file was deleted.

22 changes: 14 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,15 @@ exports.data_any = function (next, connection) {
return next();
}

const hdr_addr = haddr.parse(hdr_from)[0];
let hdr_addr;
try {
hdr_addr = haddr.parse(hdr_from)[0];
}
catch (e) {
connection.transaction.results.add(plugin, {fail: `data(unparsable_from:${hdr_from})`});
return next();
}

if (!hdr_addr) {
connection.transaction.results.add(plugin, {fail: `data(unparsable_from:${hdr_from})`});
return next();
Expand Down Expand Up @@ -439,11 +447,9 @@ exports.in_re_list = function (type, phase, address) {

exports.in_file = function (file_name, address, connection) {
const plugin = this;
// using indexOf on an array here is about 20x slower than testing against
// a key in an object
// using indexOf on an array here is about 20x slower than testing against a key in an object
connection.logdebug(plugin, `checking ${address} against ${file_name}`);
return (plugin.config.get(file_name, 'list')
.indexOf(address) === -1) ? false : true;
return (plugin.config.get(file_name, 'list').indexOf(address) === -1) ? false : true;
}

exports.in_re_file = function (file_name, address) {
Expand All @@ -462,7 +468,7 @@ exports.in_re_file = function (file_name, address) {
exports.load_file = function (type, phase) {
const plugin = this;
if (!plugin.cfg.check[phase]) {
plugin.loginfo(plugin, `skipping ${plugin.cfg[type][phase]}`);
plugin.logdebug(plugin, `skipping ${plugin.cfg[type][phase]}`);
return;
}

Expand All @@ -489,7 +495,7 @@ exports.load_file = function (type, phase) {
exports.load_re_file = function (type, phase) {
const plugin = this;
if (!plugin.cfg.check[phase]) {
plugin.loginfo(plugin, `skipping ${plugin.cfg.re[type][phase]}`);
plugin.logdebug(plugin, `skipping ${plugin.cfg.re[type][phase]}`);
return;
}

Expand All @@ -514,7 +520,7 @@ exports.load_re_file = function (type, phase) {
exports.load_domain_file = function (type, phase) {
const plugin = this;
if (!plugin.cfg.check[phase]) {
plugin.loginfo(plugin, `skipping ${plugin.cfg[type][phase]}`);
plugin.logdebug(plugin, `skipping ${plugin.cfg[type][phase]}`);
return;
}

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"name": "haraka-plugin-access",
"version": "1.1.3",
"version": "1.1.4",
"description": "Haraka plugin for ACLs for email connections",
"main": "index.js",
"scripts": {
"lint": "./node_modules/.bin/eslint *.js test/**/*.js",
"lintfix": "./node_modules/.bin/eslint --fix *.js test/**/*.js",
"test": "./node_modules/.bin/nodeunit"
"lint": "npx eslint *.js test/*.js",
"lintfix": "npx eslint --fix *.js test/*.js",
"test": "npx mocha",
"cover": "NODE_ENV=cov npx nyc --reporter=lcovonly -x tests npm run test"
},
"repository": {
"type": "git",
Expand All @@ -24,11 +25,10 @@
},
"homepage": "https://github.com/haraka/haraka-plugin-access#readme",
"devDependencies": {
"eslint": ">=4",
"eslint": ">=6",
"eslint-plugin-haraka": "*",
"haraka-test-fixtures": "*",
"mocha": "*",
"nodeunit": "*"
"mocha": "*"
},
"dependencies": {
"address-rfc2822": "*",
Expand Down
34 changes: 0 additions & 34 deletions redress.sh

This file was deleted.

15 changes: 0 additions & 15 deletions test/.eslintrc.json

This file was deleted.

Loading

0 comments on commit 07d9442

Please sign in to comment.