Skip to content

Commit

Permalink
prettier & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Apr 18, 2024
1 parent 12c6130 commit bd3a723
Show file tree
Hide file tree
Showing 15 changed files with 935 additions and 736 deletions.
8 changes: 4 additions & 4 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
engines:
eslint:
enabled: true
channel: "eslint-8"
channel: 'eslint-8'
config:
config: ".eslintrc.yaml"
config: '.eslintrc.yaml'

ratings:
paths:
- "**.js"
paths:
- '**.js'
2 changes: 1 addition & 1 deletion .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ env:
mocha: true
es2022: true

extends: ['@haraka']
extends: ['@haraka']
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
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
- package-ecosystem: 'npm'
directory: '/'
schedule:
interval: "weekly"
interval: 'weekly'
allow:
- dependency-type: production
9 changes: 4 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name: CI

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

env:
CI: true

jobs:

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

Expand All @@ -15,9 +14,9 @@ jobs:
# secrets: inherit

ubuntu:
needs: [ lint ]
needs: [lint]
uses: haraka/.github/.github/workflows/ubuntu.yml@master

windows:
needs: [ lint ]
uses: haraka/.github/.github/workflows/windows.yml@master
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
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ env:
jobs:
publish:
uses: haraka/.github/.github/workflows/publish.yml@master
secrets: inherit
secrets: inherit
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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-spf/commits?author=msimerson">13</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/82041?v=4"><br><a href="https://github.com/gramakri">gramakri</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=gramakri">1</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/918201?v=4"><br><a href="https://github.com/DoobleD">DoobleD</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=DoobleD">1</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/550490?v=4"><br><a href="https://github.com/smfreegard">smfreegard</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=smfreegard">1</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/8930018?v=4"><br><a href="https://github.com/ne4t0">ne4t0</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=ne4t0">1</a>)|
| :---: | :---: | :---: | :---: | :---: |
| <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-spf/commits?author=msimerson">13</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/82041?v=4"><br><a href="https://github.com/gramakri">gramakri</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=gramakri">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/918201?v=4"><br><a href="https://github.com/DoobleD">DoobleD</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=DoobleD">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/550490?v=4"><br><a href="https://github.com/smfreegard">smfreegard</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=smfreegard">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/8930018?v=4"><br><a href="https://github.com/ne4t0">ne4t0</a> (<a href="https://github.com/haraka/haraka-plugin-spf/commits?author=ne4t0">1</a>) |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ domain whilst preserving the original return-path.

## Configuration

-------------
---

This plugin uses spf.ini for configuration and the following options are
available:


```ini
[relay]
context=sender (default: sender)
Expand Down Expand Up @@ -64,27 +63,27 @@ openspf_text = true

### Things to Know

* Most senders do not publish SPF records for their mail server *hostname*,
- Most senders do not publish SPF records for their mail server _hostname_,
which means that the SPF HELO test rarely passes. During observation in 2014,
more spam senders have valid SPF HELO than ham senders. If you expect very
little from SPF HELO validation, you might still be disappointed.

* Enabling error deferrals will cause excessive delays and perhaps bounced
- Enabling error deferrals will cause excessive delays and perhaps bounced
mail for senders with broken DNS. Enable this only if you are willing to
delay and sometimes lose valid mail.

* Broken SPF records by valid senders are common. Keep that in mind when
- Broken SPF records by valid senders are common. Keep that in mind when
considering denial of SPF error results. If you deny on error, budget
time for instructing senders on how to correct their SPF records so they
can email you.

* The only deny option most sites should consider is `mfrom_fail`. That will
- The only deny option most sites should consider is `mfrom_fail`. That will
reject messages that explicitely fail SPF tests. SPF failures have a high
correlation with spam. However, up to 10% of ham transits forwarders and/or
email lists which frequently break SPF. SPF results are best used as inputs
to other plugins such as DMARC, [spamassassin](http://haraka.github.io/manual/plugins/spamassassin.html), and [karma](http://haraka.github.io/manual/plugins/karma.html).

* Heed well the implications of SPF, as described in [RFC 4408](http://tools.ietf.org/html/rfc4408#section-9.3)
- Heed well the implications of SPF, as described in [RFC 4408](http://tools.ietf.org/html/rfc4408#section-9.3)

### spf.ini default settings

Expand Down Expand Up @@ -140,9 +139,7 @@ mfrom_permerror=false
openspf_text=false
```


Testing
-------
## Testing

This plugin also provides a command-line test tool that can be used to debug SPF issues or to check results.

Expand All @@ -167,8 +164,8 @@ You can add `--debug` to the option arguments to see a full trace of the SPF pro
Node does not support the SPF DNS Resource Record type. Only TXT records are
checked. This is a non-issue as < 1% (as of 2014) of SPF records use the SPF RR type. Due to lack of adoption, SPF has deprecated the SPF RR type.


<!-- leave these buried at the bottom of the document -->

[ci-img]: https://github.com/haraka/haraka-plugin-spf/actions/workflows/ci.yml/badge.svg
[ci-url]: https://github.com/haraka/haraka-plugin-spf/actions/workflows/ci.yml
[clim-img]: https://codeclimate.com/github/haraka/haraka-plugin-spf/badges/gpa.svg
Expand Down
71 changes: 40 additions & 31 deletions bin/spf
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,55 @@

// SPF test tool

const nopt = require('nopt');
const path = require('path');
const base_path = path.join(__dirname, '..');
const SPF = require(`${base_path}/lib/spf`).SPF;
const spf = new SPF();

const parsed = nopt({ 'debug': Boolean, 'ip': String, 'helo': String, 'domain': String });

function print_usage () {
console.log('Usage: spf [--debug] --ip <ip> --helo <helo> --domain <domain>');
process.exit(1);
const nopt = require('nopt')
const path = require('path')
const base_path = path.join(__dirname, '..')
const SPF = require(`${base_path}/lib/spf`).SPF
const spf = new SPF()

const parsed = nopt({
debug: Boolean,
ip: String,
helo: String,
domain: String,
})

function print_usage() {
console.log('Usage: spf [--debug] --ip <ip> --helo <helo> --domain <domain>')
process.exit(1)
}

if (!parsed.ip || (parsed.ip && (!parsed.domain && !parsed.helo))) {
print_usage();
if (!parsed.ip || (parsed.ip && !parsed.domain && !parsed.helo)) {
print_usage()
}

if (!parsed.debug) {
SPF.prototype.log_debug = function (str) {}
SPF.prototype.log_debug = function () {}
}

let domain;
let domain
if (parsed.domain) {
domain = /@(.+)$/.exec(parsed.domain);
domain = /@(.+)$/.exec(parsed.domain)
if (domain) {
domain = domain[1];
}
else {
domain = parsed.domain;
domain = domain[1]
} else {
domain = parsed.domain
}
}

spf.check_host(parsed.ip, (domain ? domain : parsed.helo)).then((result) => {
console.log([
`ip=${parsed.ip}`,
`helo="${(parsed.helo ? parsed.helo : '')}"`,
`domain="${(domain ? domain : '')}"`,
`result=${spf.result(result)}`
].join(' '));
}).catch((err) => {
console.error(`Error: ${err.message}`);
process.exit(1);
});
spf
.check_host(parsed.ip, domain ? domain : parsed.helo)
.then((result) => {
console.log(
[
`ip=${parsed.ip}`,
`helo="${parsed.helo ? parsed.helo : ''}"`,
`domain="${domain ? domain : ''}"`,
`result=${spf.result(result)}`,
].join(' '),
)
})
.catch((err) => {
console.error(`Error: ${err.message}`)
process.exit(1)
})
Loading

0 comments on commit bd3a723

Please sign in to comment.