Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.0.2 #18

Merged
merged 8 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
engines:
eslint:
enabled: true
channel: "eslint-8"
channel: 'eslint-8'
config:
config: ".eslintrc.yaml"
config: '.eslintrc.yaml'

checks:
similar-code:
Expand All @@ -13,5 +13,5 @@ checks:
threshold: 10

ratings:
paths:
- "**.js"
paths:
- '**.js'
17 changes: 4 additions & 13 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,9 @@ env:
node: true
es6: true
mocha: true
es2020: true
es2022: true

plugins: [ haraka ]
extends: ['@haraka']

extends: [ eslint:recommended, plugin:haraka/recommended ]

root: true

globals:
OK: true
CONT: true
DENY: true
DENYSOFT: true
DENYDISCONNECT: true
DENYSOFTDISCONNECT: true
rules:
no-unused-vars: 1
6 changes: 4 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Fixes #

Changes proposed in this pull request:
-
-

-
-

Checklist:

- [ ] docs updated
- [ ] tests updated
- [ ] Changes.md updated
Expand Down
29 changes: 7 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
name: CI

on: [ push ]
on: [push, pull_request]

env:
CI: true

jobs:

lint:
uses: haraka/.github/.github/workflows/lint.yml@master

# coverage:
# uses: haraka/.github/.github/workflows/coverage.yml@master
# secrets: inherit

test:
needs: lint
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
node-version: [ 14, 16, 18 ]
fail-fast: false

steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
name: Node ${{ matrix.node-version }} on ${{ matrix.os }}
with:
node-version: ${{ matrix.node-version }}

- run: npm install
ubuntu:
needs: [lint]
uses: haraka/.github/.github/workflows/ubuntu.yml@master

- run: npm test
windows:
needs: [lint]
uses: haraka/.github/.github/workflows/windows.yml@master
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: "CodeQL"
name: 'CodeQL'

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]
schedule:
- cron: '18 7 * * 4'

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ on:
push:
branches:
- master
paths:
- package.json

env:
CI: true

jobs:
publish:
uses: haraka/.github/.github/workflows/publish.yml@master
secrets: inherit
secrets: inherit
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule ".release"]
path = .release
url = [email protected]:msimerson/.release.git
2 changes: 2 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
singleQuote: true
semi: false
1 change: 1 addition & 0 deletions .release
Submodule .release added at 0fa4e6
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Changelog

The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Unreleased

### [1.0.2] - 2024-04-29

- fix: log when doing operations. Fixes #14
- index: make separate if blocks in cascading list
- fix: rename config/aliases to config/aliases.json
- fix: wildcard + domain matches before domain. Fixes #15
- lint: remove duplicate / stale rules from .eslintrc
- dep: eslint-plugin-haraka -> @haraka/eslint-config
- deps: bump to latest versions
- chore: populate [files] in package.json
- doc(CHANGELOG) renamed from Changes
- doc(CONTRIBUTORS): added
- doc(README): fix URL for CI tests
- ci: update to shared GHA workflows
- added the option to alias all emails with \* (#12)

### 1.0.1 - 2022-05-26

- synced from Haraka/plugins/aliases
- dep(eslint): 3 -> 8
- chore(ci): add github workflows, codeql, ci, publish
- chore(ci): delete travis and appveyor configs
- chore: ignore package-lock.json
- chore(test): replaced nodeunit with mocha
- lint: use shorthand in tests

### 1.0.0 - 2017-09-01

- imported from haraka

[1.0.2]: https://github.com/haraka/haraka-plugin-aliases/releases/tag/v1.0.2
8 changes: 8 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Contributors

This handcrafted artisinal software is brought to you by:

| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-plugin-aliases/commits?author=msimerson">7</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/38138252?v=4"><br><a href="https://github.com/TimoKoole">TimoKoole</a> (<a href="https://github.com/haraka/haraka-plugin-aliases/commits?author=TimoKoole">1</a>) |
| :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
19 changes: 0 additions & 19 deletions Changes.md

This file was deleted.

91 changes: 47 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

# haraka-plugin-aliases

This plugin allows the configuration of aliases that perform an action or
change the RCPT address. Aliases are specified in a JSON formatted config file,
and must have an action. Syntax errors found in the JSON config will stop the server.
This plugin allows the configuration of aliases that perform an action or change the RCPT address. Aliases are specified in a JSON formatted config file, and must have an action. Syntax errors found in the JSON config will stop the server.

IMPORTANT: this plugin must appear in `config/plugins` before other plugins
that run on hook_rcpt
IMPORTANT: this plugin must appear in `config/plugins` before other plugins that run on hook_rcpt

WARNING: DO NOT USE THIS PLUGIN WITH queue/smtp\_proxy.
WARNING: DO NOT USE THIS PLUGIN WITH queue/smtp_proxy.

## Configuration

Expand All @@ -20,13 +17,13 @@ WARNING: DO NOT USE THIS PLUGIN WITH queue/smtp\_proxy.
JSON formatted config file that contains keys to match against RCPT addresses, and values that are objects with an "action" : "<action>" property. Example:

```json
{ "test1" : { "action" : "drop" } }
{ "test1": { "action": "drop" } }
```

In the above example the "test1" alias will drop any message that matches test1, test1-*, or test1+* (wildcard '-' or '+', see below). Actions may have 0 or more options listed like so:
In the above example the "test1" alias will drop any message that matches test1, test1-_, or test1+_ (wildcard '-' or '+', see below). Actions may have 0 or more options listed like so:

```json
{ "test3" : { "action" : "alias", "to" : "test3-works" } }
{ "test3": { "action": "alias", "to": "test3-works" } }
```

In the above example the "test3" alias has an action of "alias" and a mandatory "to" field. If "to" were missing the alias would fail and an error would be emitted.
Expand All @@ -44,101 +41,107 @@ Aliases of 'user', '@host' and 'user@host' possible:
Aliases may be expanded to multiple recipients:

```json
{ "[email protected]": { "action": "alias", "to": ["[email protected]", "[email protected]"] } }
{
"[email protected]": {
"action": "alias",
"to": ["[email protected]", "[email protected]"]
}
}
```

### wildcard notation

This plugin supports wildcard matching of aliases against the right most string of a RCPT address. The characters '-' and '+' are commonly used for subaddressing and this plugin can alias the "user" part of the address.
This plugin supports wildcard matching of aliases against the right most string of a RCPT address. The characters '-' and '+' are commonly used for subaddressing and this plugin can alias the "user" part of the address.

If the address were [email protected] (or [email protected]), the below alias would match:

```json
{ "test2" : { "action" : "drop" } }
{ "test2": { "action": "drop" } }
```

Larger and more specific aliases match first when using wildcard '-' notation. If the above RCPT was evaluated with this alias config, it would alias:
Larger and more specific aliases match first when using wildcard '-' notation. If the above RCPT was evaluated with this alias config, it would alias:

```json
{
"test2" : { "action" : "drop" },
"test2-testing" : { "action" : "alias", "to" : "[email protected]" }
"test2": { "action": "drop" },
"test2-testing": { "action": "alias", "to": "[email protected]" }
}
```

It also allows you to route all emails to a certain domain:

```json
{
"*" : { "action" : "alias", "to" : "[email protected]" }
"*": { "action": "alias", "to": "[email protected]" }
}
```

#### chaining and circuits

Alias chaining is not supported. As a side-effect, we enjoy protections against alias circuits.

* optional one line formatting
- optional one line formatting

Any valid JSON will due. Please consider keeping each alias on its own line so that others that wish to grep the aliases file have an easier time finding the full configuration for an alias.

* nondeterministic duplicate matches
- nondeterministic duplicate matches

This plugin was written with speed in mind. That means every lookup hashes into the alias file for its match. While the act of doing so is fast, it does mean that any duplicate alias entries will match nondeterministically. That is, we cannot predict what will happen here:
This plugin was written with speed in mind. That means every lookup hashes into the alias file for its match. While the act of doing so is fast, it does mean that any duplicate alias entries will match nondeterministically. That is, we cannot predict what will happen here:

```json
{
"coinflip" : { "action" : "alias", "to" : "[email protected]" },
"coinflip" : { "action" : "alias", "to" : "[email protected]" }
"coinflip": { "action": "alias", "to": "[email protected]" },
"coinflip": { "action": "alias", "to": "[email protected]" }
}
```

Due to node.js implementation, one result will likely always be chosen over the other, so this is not exactly a coinflip. We simply cannot say what the language implementation will do and it could change.
Due to node.js implementation, one result will likely always be chosen over the other, so this is not exactly a coinflip. We simply cannot say what the language implementation will do and it could change.

## action (required)

The following is a list of supported actions and their options.

* drop
- drop

Drops a message while pretending everything was okay to the sender. This acts like an alias to /dev/null.
Drops a message while pretending everything was okay to the sender. This acts like an alias to /dev/null.

* alias
- alias

Maps the alias key to the address specified in the "to" option. A note about matching in addition to the note about wildcard '-' above. When we match an alias, we store the hostname of the match for a shortcut substitution syntax later.
Maps the alias key to the address specified in the "to" option. A note about matching in addition to the note about wildcard '-' above. When we match an alias, we store the hostname of the match for a shortcut substitution syntax later.

* to (required)
- to (required)

This option is the full address, or local part at matched hostname that the RCPT address will be re-written to. For an example of an alias to a full address consider the following:
This option is the full address, or local part at matched hostname that the RCPT address will be re-written to. For an example of an alias to a full address consider the following:

```json
{ "test5" : { "action" : "alias", "to" : "[email protected]" } }
```
```json
{ "test5": { "action": "alias", "to": "[email protected]" } }
```

This maps RCPT matches for "test5" to "[email protected]". This would map "[email protected]" to "[email protected]" every time. Compare this notation with its shortcut counterpart, best used when the "to" address is at the same domain as the match:
This maps RCPT matches for "test5" to "[email protected]". This would map "[email protected]" to "[email protected]" every time. Compare this notation with its shortcut counterpart, best used when the "to" address is at the same domain as the match:

```json
{ "test4" : { "action" : "alias", "to" : "test4" } }
```
```json
{ "test4": { "action": "alias", "to": "test4" } }
```

This notation is more compact. Mail to "[email protected]" will map to "[email protected]". This notation enables lots of aliases on a single domain to map to other local parts at the same domain.
This notation is more compact. Mail to "[email protected]" will map to "[email protected]". This notation enables lots of aliases on a single domain to map to other local parts at the same domain.

## Example Configuration

```json
{
"test1" : { "action" : "drop" },
"test2" : { "action" : "drop" },
"test3" : { "action" : "alias", "to" : "test3-works" },
"test4" : { "action" : "alias", "to" : "test4" },
"test5" : { "action" : "alias", "to" : "[email protected]" },
"test6" : { "action" : "alias", "to" : "[email protected]" }
"test1": { "action": "drop" },
"test2": { "action": "drop" },
"test3": { "action": "alias", "to": "test3-works" },
"test4": { "action": "alias", "to": "test4" },
"test5": { "action": "alias", "to": "[email protected]" },
"test6": { "action": "alias", "to": "[email protected]" }
}
```

<!-- leave these buried at the bottom of the document -->
[ci-img]: https://travis-ci.org/haraka/haraka-plugin-aliases.svg
[ci-url]: https://travis-ci.org/haraka/haraka-plugin-aliases

[ci-img]: https://github.com/haraka/haraka-plugin-aliases/actions/workflows/ci.yml/badge.svg
[ci-url]: https://github.com/haraka/haraka-plugin-aliases/actions/workflows/ci.yml
[cov-img]: https://codecov.io/github/haraka/haraka-plugin-aliases/coverage.svg
[cov-url]: https://codecov.io/github/haraka/haraka-plugin-aliases
[clim-img]: https://codeclimate.com/github/haraka/haraka-plugin-aliases/badges/gpa.svg
Expand Down
2 changes: 0 additions & 2 deletions config/aliases

This file was deleted.

1 change: 1 addition & 0 deletions config/aliases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Loading