Commit Graph
78 Commits
Author SHA1 Message Date
Adam Cooke 5eeed7c023 chore(deps): upgrade to Rails 7.2.3.2, Ruby 3.4.10 and latest gems
Upgrades Rails from 7.1.6 to 7.2.3.2, Ruby from 3.4.6 to 3.4.10, and
brings the rest of the bundle up to date.

Two things were broken by Rails 7.2 and are fixed here:

* MigrationWaiter called `ActiveRecord::Base.connection.migration_context`,
  which moved to the connection pool in 7.2. This raised NoMethodError on
  boot for any deployment with `migration_waiter.enabled` set, and had no
  test covering it.
* `config.action_dispatch.show_exceptions = false` was deprecated in 7.1
  and removed in 7.2. Now `:none`.

`json` is pinned to < 3. Active Support 7.2 passes `quirks_mode:` to both
`JSON.generate` and `JSON.parse`, and json 3.0 removed that option, so an
unpinned json resolves to 3.x and makes every `to_json` raise - webhook
payloads included. Nothing else in the bundle constrains it. The pin can go
when we reach Rails 8.1, which no longer passes the option.

`dynamic_form` is dropped. It is unmaintained and from 1.3.1 requires Ruby
< 3.4, so it could never be updated again. Ten views used it, so
`error_messages_for` now lives in ErrorMessagesHelper and `f.error_messages`
in a form builder extension. The rendered markup is unchanged apart from a
heading and description the stylesheet had always hidden; the rules that
hid them are removed too.

`execjs` is unpinned. The `< 2.8` constraint dated from the Rails 6.0
upgrade and asset output is byte-identical without it.

Notable gem majors: puma 8, haml 7, secure_headers 7, sentry 7, jwt 3,
prometheus-client 5, highline 3, omniauth-rails_csrf_protection 2,
rspec-rails 8, shoulda-matchers 8, rubocop 1.91. secure_headers 7 changes
X-XSS-Protection from "1; mode=block" to "0", which is the correct modern
default and matches Rails' own.

`config.load_defaults` deliberately stays at 7.0. The pending 7.1 and 7.2
options are listed, commented out, in new_framework_defaults_7_1.rb and
_7_2.rb so they can be adopted in stages - several change the signed cookie
and cache formats and need a staged deploy. The vestigial
new_framework_defaults_7_0.rb is removed, as `load_defaults 7.0` already
applies all of it.

Adds tests for the areas this touched, which were mostly uncovered:
MigrationWaiter, the serialized columns that gate a defaults bump, JSON
encoding, HAML template compilation for all 103 templates, page rendering,
form error rendering and security headers. The assets Gemfile group now
includes :test so the view layer can be exercised at all.
2026-09-15 10:27:16 +01:00
Adam Cooke 11c9814474 fix(http): prevent SSRF in outbound webhook and HTTP endpoint requests
Webhook and HTTP message endpoint deliveries both flow through
Postal::HTTP, which parsed the user-supplied URL and connected to its
host with no address validation. An authenticated user could point a
webhook or endpoint at a private, loopback or link-local address (e.g.
127.0.0.1, 169.254.169.254 cloud metadata, RFC1918 hosts) and make the
server issue requests into its own internal network.

Add Postal::HTTP::AddressGuard, which resolves the destination host and
rejects private/loopback/link-local/reserved/multicast IPv4 and IPv6
addresses, then pins the connection to the validated address so it cannot
be redirected via a DNS-rebinding race. Administrators can permit specific
destinations via the new postal.allowed_request_destinations config option
(hostnames or IP/CIDR ranges).

Address selection only uses families this server can actually reach so we
do not pin to an IPv6 address on a host without IPv6 connectivity; IPv4 is
preferred for predictability. HTTPEndpoint now validates that its URL is a
well-formed HTTP(S) URL with a host.
2026-06-03 15:09:18 +01:00
Adam Cooke ab6d4430ba chore: upgrade to rails 7.1 and ruby 3.4 (#3457) 2025-10-01 16:42:39 +01:00
Adam Cooke 3d208d632f test: add tests for the legacy API 2024-03-13 22:40:41 +00:00
Adam Cooke 5ed94f6f85 feat: openid connect support (#2873) 2024-03-12 17:40:07 +00:00
Adam Cooke d84152eb5d feat: automatically remove queued messages with stale locks (#2872) 2024-03-12 11:37:29 +00:00
Adam Cooke e2d642c0cb fix(message-dequeuer): ensure SMTP endpoints are sent to SMTP sender appropriately
closes #2853
2024-03-06 14:09:29 +00:00
Adam Cooke ce30c070bd refactor: switch to use SecureRandom for random strings 2024-03-04 17:33:25 +00:00
Adam Cooke 0163ac3d10 feat: new configuration system (and schema) (#2819) 2024-02-26 12:41:57 +00:00
Adam Cooke ecd09a2445 chore: upgrade rails to 7.0 and other dependencies 2024-02-23 22:51:37 +00:00
Adam Cooke e3bc9da253 refactor: move lib/postal/received_header to app/lib/received_header 2024-02-23 22:51:36 +00:00
Adam Cooke 05d2ec4d04 refactor: move Postal::BounceMessage to app/models/bounce_message 2024-02-23 22:51:35 +00:00
Adam Cooke 1a4158699c refactor: refactor DNS resolution
This commit also adds some of tests for the Domain model. It was during the writing of these tests that the DNS resolution refactoring requirement became apparent.
2024-02-23 22:51:34 +00:00
Adam Cooke 2023200d91 test: add tests for Server model 2024-02-23 22:51:34 +00:00
Adam Cooke 27b7ced3bc chore: remove non-breaking spaces from comments 2024-02-23 22:51:34 +00:00
Adam Cooke e0403ba641 refactor: refactor webhook deliveries 2024-02-23 22:51:33 +00:00
Adam Cooke dc8e895bfe feat: new background work process
This removes all previous dependencies on RabbitMQ and the need to run separate cron and requeueing processes.
2024-02-23 22:51:33 +00:00
Adam Cooke 044058d0f1 feat: more consistent logging 2024-02-23 22:51:32 +00:00
Adam Cooke 6214892710 chore: annotate models 2024-02-13 11:46:35 +00:00
Adam Cooke ec636661d5 style(rubocop): remaining offences 2024-02-12 09:55:20 +00:00
Adam Cooke bab6346239 style(rubocop): Lint/DuplicateMethods 2024-02-12 09:55:18 +00:00
Adam Cooke a1dc0f77ac style(rubocop): Lint/DuplicateBranch 2024-02-12 09:55:18 +00:00
Adam Cooke 9ce28a427f style(rubocop): Style/SelectByRegexp 2024-02-12 09:55:18 +00:00
Adam Cooke 4674e63b5f style(rubocop): Lint/MissingSuper 2024-02-12 09:55:15 +00:00
Adam Cooke 9563f30c96 style(rubocop): Naming/MemoizedInstanceVariableName 2024-02-12 09:40:34 +00:00
Adam Cooke 6ad56ee9c9 style(rubocop): Lint/IneffectiveAccessModifier 2024-02-10 23:03:28 +00:00
Adam Cooke c558f1c69c style(rubocop): Style/NumericPredicate 2024-02-10 22:59:30 +00:00
Adam Cooke bd85920565 style(rubocop): Style/WordArray 2024-02-10 22:39:43 +00:00
Adam Cooke 129dffab9e style(rubocop): Style/MutableConstant 2024-02-10 17:34:29 +00:00
Adam Cooke ee94e4e1a0 style(rubocop): Lint/UnusedBlockArgument 2024-02-10 17:20:13 +00:00
Adam Cooke 7590a46234 style(rubocop): Lint/UselessAssignment 2024-02-10 17:18:24 +00:00
Adam Cooke e142d0da5f style(rubocop): Layout/LineLength 2024-02-10 17:18:23 +00:00
Adam Cooke 0e4ed5ca03 style(rubocop): Layout/EmptyLineAfterMagicComment 2024-02-10 17:18:23 +00:00
Adam Cooke 6ab36c09c9 style(rubocop): Style/FrozenStringLiteralComment 2024-02-10 17:18:22 +00:00
Adam Cooke 15f9671b66 feat: privacy mode
Adds support for hiding IP addresses & hostnames associated with clients sending
authenticated mail in to Postal over SMTP and HTTP
2024-02-07 09:45:09 +00:00
Adam Cooke 957b784658 chore: Upgrade to Ruby 3.2.1 & Rails 6.0
* chore: upgrade to rails 6.0

* chore: upgrade ruby to 3.2.1

* chore: upgrade bundler

* chore: upgrade execjs

* chore: upgrade to rails 6.1

* chore: switch to sentry-ruby from raven

* chore: add extra platforms to gemfile
2023-04-06 11:40:45 +01:00
Charlie Smurthwaite c8d27b2963 Change retry and batching timing calculations (#2371)
This patch changes the requeue behaviour to requeue messages that are 30 seconds past their retry time.
Batching now includes messages that are any amount past their retry time.
This change avoids batching messages before theur graylisting time, but maintains efficient batching.
2023-03-22 14:02:28 +00:00
Charlie Smurthwaite 1e3622c49a Consistently treat tinyint(1) fields in message database as booleans (#2380)
* Update mysql2 query call to cast booleans

* Treat messages:held field as boolean

* Treat messages:inspected field as boolean

* Treat messages:spam field as boolean

* Treat messages:threat field as boolean

* Treat messages:bounce field as boolean

* Treat messages:received_with_ssl field as boolean

* Treat deliveries:sent_with_ssl field as boolean
2023-03-22 13:49:48 +00:00
Charlie Smurthwaite fd289c46fd style(rubocop): fix all safe auto correctable offenses 2023-03-16 15:50:53 +00:00
Will Power d0db1345a2 Message body parts should be a sub body (#376) 2023-03-13 13:27:39 +00:00
Adam Cooke c60c69db18 feat: allow @ and % in webhook urls 2022-02-14 16:12:47 +00:00
Adam Cooke 724325a1b9 feat: support for configuring the default spam threshold values for new servers 2021-08-02 16:17:18 +00:00
Adam Cooke 232c323121 docs: use a smaller logo on the readme 2021-07-29 19:59:39 +00:00
Adam Cooke 17dd7cc757 refactor: remove the fast server 2021-07-29 11:20:47 +00:00
Adam Cooke 21a8d89045 feat: add priorities to IP address assignment 2021-07-28 14:18:40 +00:00
Adam Cooke daf469ce7f refactor: user management 2021-07-28 14:17:59 +00:00
Charlie Smurthwaite 8d44c90188 do not find the original message when returning batchable messages (#1225) 2020-09-30 15:34:38 +01:00
Charlie Smurthwaite 9a3d568b27 Add IP-based SMTP authentication (#1149) 2020-07-17 11:43:51 +01:00
Charlie Smurthwaite bb27d8c8a1 Fix access to variable in check_dkim_record 2019-06-22 09:26:20 +01:00
Morne Lotze 7ca7b43fda add semicolon to DKIM record data (#825)
* add semicolon to dkim record data

Addresses https://github.com/atech/postal/issues/812

As the semicolon at the end of a DKIM record is optional, some DNS software removes it.
The above change sanitizes the DKIM record before it gets checked

* fixed method typo

fixed a typo caused by my US spelling checker

* typo fix v2

a proper fix for the typo
2019-06-11 10:41:39 +01:00