rack-proxy 0.7.7 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 888784aa8d1d28ae0dc2a1352aa44ba8e639d5cd604043facbb31da3fa1dc759
4
- data.tar.gz: 9ba49effcffcacb930ab08fe2f6a9fd08040b60800b8aa8e5ccc274053f36c4e
3
+ metadata.gz: c85038309db55ace1d7ad2de733dc4a539859cf585c2ffb69b73c13a914f1d47
4
+ data.tar.gz: e0328851b0d2a9698b05f356bbb0322c6f3cf4c760b10d93a91194df0849ce44
5
5
  SHA512:
6
- metadata.gz: 606ed720fb5b8c67cd1fc3058b9644e88fb2e7768d4fce4606ba0332fac24cadca11a36ab50d97cb7ff5767664864b1c1a2cf5108cd58a66fecfb3b93de37517
7
- data.tar.gz: a91cc8541d7af6c390fe1c0faa3c923942a14cce746eebc3d170b95b45aafc5871a04ad1ec9fee6f0c07500534755c794f76d0c14bccdcf5fdaad06e239aeb07
6
+ metadata.gz: 7bba2a24c71a1521a3d9f9d42d7bffd56b8545f05a8f060fb7236c76d0d5dccba4099015eb25f69e5d98d79b937a4e6d8b26fac5e69345a814222bc65cf3f3d9
7
+ data.tar.gz: 34502c66d9801a04d95849773d3dc8c43aa24629db6cb780bb06834054ffc41588ddd1610ec39e33f6b7c64b163311633a47bc988b48eacd7d3e0578bda2568f
data/CHANGELOG.md ADDED
@@ -0,0 +1,205 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented here. The format is based on
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project aims to
5
+ follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ Nothing yet.
10
+
11
+ ## [1.0.2] - 2026-09-01
12
+
13
+ Housekeeping — no library behavior changes. **No action is needed by users:**
14
+ the shipped gem does not depend on `json` and was never affected by the
15
+ advisory below.
16
+
17
+ ### Security
18
+
19
+ - Development dependency `json` bumped 2.21.1 → 2.21.2 to clear
20
+ CVE-2026-71847 / GHSA-9hj4-r449-hfvc (`JSON::ResumableParser#partial_value`
21
+ dereferences a freed input buffer on truncated duplicate-key streams).
22
+ `json` reaches this repo only transitively (`standard` → `rubocop` → `json`)
23
+ and lives solely in the development `Gemfile.lock`; the bump keeps the CI
24
+ `bundler-audit` gate green.
25
+
26
+ ### Changed
27
+
28
+ - Release workflow: the laggy rubygems full-index await was replaced with a
29
+ versions-API check, so a successful publish no longer fails the run. (#142)
30
+
31
+ ## [1.0.1] - 2026-07-23
32
+
33
+ Docs and housekeeping — no library behavior changes.
34
+
35
+ ### Changed
36
+
37
+ - README modernized: badges, quick start, a "How it works" pipeline overview,
38
+ grouped options, and tightened recipes.
39
+ - Removed the internal modernization roadmap document, completed by 1.0.0.
40
+ - Development dependencies refreshed (rake 13.4.2, test-unit 3.7.8,
41
+ rack-test 2.2.0) and CI bumped to `actions/checkout@v7`. (#136–#139)
42
+
43
+ ## [1.0.0] - 2026-07-18
44
+
45
+ The 2026 modernization + security-hardening release. From 1.0.0 on this
46
+ project follows SemVer strictly: breaking changes only in majors.
47
+
48
+ ### Breaking changes
49
+
50
+ Read this list before upgrading from 0.8.x; everything else below is additive
51
+ or a compatible fix. See the README's "Upgrading" section for migration steps.
52
+
53
+ - **Host-derived (dynamic) backends are refused by default.** With no
54
+ `:backend` and no `env["rack.backend"]`, requests now get `502` unless you
55
+ pass `allow_dynamic_backend: true`. A bare `Rack::Proxy.new` is no longer an
56
+ open proxy. Combine the opt-in with a `backend_allowed?` allowlist.
57
+ - **`net_http_hacked` is gone** — the file, `require "net_http_hacked"`, and
58
+ the `begin_request_hacked`/`end_request_hacked` methods (see Removed).
59
+ - **The bundled examples left the gem** — `require "rack_proxy_examples/..."`
60
+ raises `LoadError`; copy the snippets from `examples/` instead (see Removed).
61
+ - **Backend failures no longer raise.** `OpenSSL::SSL::SSLError`, `EOFError`,
62
+ timeouts, resets, and malformed backend responses now become a `502` triplet
63
+ instead of an exception — `rescue`-based error handling around `proxy.call`
64
+ must inspect the status instead.
65
+ - **Hop-by-hop request headers are no longer forwarded** (`Connection`, `TE`,
66
+ `Transfer-Encoding`, `Proxy-Authorization`, `Upgrade`, anything named by
67
+ `Connection`).
68
+ - **gzip backend bodies are forwarded verbatim in `streaming: false` mode**
69
+ (previously they were transparently inflated); `rewrite_response` hooks that
70
+ read body text must inflate it themselves.
71
+ - **Supported runtimes: Ruby >= 3.0 and Rack >= 2.0, < 4** (was Ruby >= 2.6,
72
+ rack unpinned).
73
+ - Smaller wire/API changes: body-less POST/PUT sends `Content-Length: 0` on
74
+ the streaming path; the streaming body is thread-affine (iterate it on the
75
+ thread that called the app, as mainstream servers do); `HttpStreamingResponse`
76
+ raises `IOError` on use-after-close; early termination closes the backend
77
+ connection instead of draining it.
78
+
79
+ ### Security
80
+
81
+ - Refuse Host-derived backends unless `allow_dynamic_backend: true` is set
82
+ (see Breaking changes) — closes the default open-proxy/SSRF pivot.
83
+ - Strip hop-by-hop headers from the **forwarded request** (Connection, TE,
84
+ Transfer-Encoding, Proxy-Authorization, …, plus any header named by the inbound
85
+ `Connection` header), closing a Content-Length/Transfer-Encoding request-smuggling
86
+ surface. Hop-by-hop headers were previously stripped only from the response.
87
+ - Add `backend_allowed?(backend)` — an overridable per-request allowlist hook,
88
+ consulted for every request (static backends included). A refused backend
89
+ responds `502`.
90
+ - Add `:max_response_length` to cap the backend response size (bounds memory
91
+ against a hostile/huge backend). Enforced incrementally while streaming.
92
+ - Add `:ca_file` / `:cert_store` so private-CA backends can be verified under the
93
+ default `VERIFY_PEER` instead of disabling verification.
94
+ - Add `:open_timeout` / `:write_timeout` to bound connect and per-write stalls
95
+ (previously only `:read_timeout` was configurable).
96
+
97
+ ### Added
98
+
99
+ - `:min_version` / `:max_version` TLS options (mapping to `Net::HTTP#min_version=`
100
+ / `#max_version=`). `:ssl_version` still works but is deprecated (it pins an
101
+ exact protocol and forbids TLS 1.3).
102
+ - `HttpStreamingResponse#close` so Rack servers release the backend connection on
103
+ early termination (HEAD, 304, client disconnect) instead of leaking it until GC.
104
+ - Opt-in request hardening: `strip_credentials: true` drops the client's
105
+ `Cookie`/`Authorization` headers from the forwarded request, and
106
+ `replace_x_forwarded_for: true` forwards only this hop's `REMOTE_ADDR`
107
+ instead of appending to the client-supplied `X-Forwarded-For` chain.
108
+ - Project scaffolding: `SECURITY.md`, `CHANGELOG.md`, `CONTRIBUTING.md`,
109
+ `CLAUDE.md`/`AGENTS.md`, GitHub Actions CI (Ruby 3.1–3.4 × Rack 2/3),
110
+ Dependabot, issue/PR templates, SimpleCov with a ratcheted coverage floor
111
+ (`COVERAGE=1`), and Standard (`standardrb`) + `bundler-audit` enforced by a
112
+ CI lint job.
113
+
114
+ ### Changed
115
+
116
+ - **The streaming path no longer monkey-patches `net/http`.**
117
+ `Rack::HttpStreamingResponse` now runs the public block form of
118
+ `Net::HTTP#request` inside a Fiber (pausing at the response head, resuming
119
+ per body chunk), replacing the 2010-era patch of private `net/http` internals
120
+ in `net_http_hacked.rb`. Behavioral notes: the streaming session sets
121
+ `max_retries = 0` so a transport error can never silently replay the request
122
+ mid-stream; early termination (client abort, HEAD, 204/304) now closes
123
+ the backend connection immediately instead of draining the remaining body;
124
+ and a body-less POST/PUT/PATCH on the streaming path now carries
125
+ `Content-Length: 0` (matching the non-streaming path and plain `Net::HTTP` —
126
+ the old patched path sent no `Content-Length` at all).
127
+ - Backend and construction failures now map to status codes instead of raising a
128
+ `500`: `400` (malformed request URI), `501` (unknown HTTP method), `502`
129
+ (broadened backend-error set incl. `ECONNRESET`, `EPIPE`, read/write timeouts,
130
+ `EOFError`, `OpenSSL::SSL::SSLError`, protocol errors, and malformed backend
131
+ responses — `Net::HTTPBadResponse` / `Net::HTTPHeaderSyntaxError`).
132
+ - gzip-encoded backend responses are forwarded verbatim (Content-Encoding and
133
+ Content-Length preserved) instead of being transparently inflated.
134
+ - Skip all `1xx` interim responses (including `103 Early Hints`) on the streaming
135
+ path, so a backend's `103` is no longer mistaken for the final response.
136
+ - `rack` dependency constrained to `>= 2.0, < 4`; the library now `require`s rack
137
+ itself.
138
+ - Test suite is fully offline (local WEBrick server); the previous live-host
139
+ tests are gated behind `LIVE=1`.
140
+
141
+ ### Deprecated
142
+
143
+ - `:ssl_version` — use `:min_version` / `:max_version`.
144
+
145
+ ### Removed
146
+
147
+ - `lib/net_http_hacked.rb` — the 2010-era monkey-patch of private `Net::HTTP`
148
+ internals. The library stopped using it when streaming moved to the public
149
+ `Net::HTTP` API (see Changed); `require "net_http_hacked"` and the
150
+ `begin_request_hacked` / `end_request_hacked` methods are gone. If external
151
+ code still depends on them, vendor the file from a 0.8.x release — and plan
152
+ to migrate; it breaks under modern net/http refactors.
153
+
154
+ - The bundled examples moved from the gem load path
155
+ (`lib/rack_proxy_examples/`) to [`examples/`](examples/) in the repository.
156
+ `require "rack_proxy_examples/..."` no longer works — copy the example class
157
+ into your app instead (they were never safe to require blindly: each one
158
+ installs itself into the Rails middleware stack when Rails is booted).
159
+
160
+ ## [0.8.3] - 2025
161
+
162
+ ### Fixed
163
+
164
+ - Handle non-rewindable request body streams (Rack 3 input streams need not
165
+ respond to `#rewind`). (#128)
166
+
167
+ ## [0.8.2] - 2025
168
+
169
+ ### Fixed
170
+
171
+ - Harden `build_header_hash` against a top-level `::Headers` constant defined by
172
+ the host app being picked up instead of `Rack::Headers`.
173
+
174
+ ## [0.8.1] - 2025
175
+
176
+ ### Added
177
+
178
+ - `:logger` option, wired to `Net::HTTP#set_debug_output` for wire-level debug
179
+ output. (#80)
180
+
181
+ ## [0.8.0] - 2025
182
+
183
+ ### Changed
184
+
185
+ - **BREAKING:** TLS certificate verification now defaults to `VERIFY_PEER`
186
+ (Ruby's `Net::HTTP` default). Previous versions silently used `VERIFY_NONE` for
187
+ HTTPS backends. Pass `ssl_verify_none: true` (or `verify_mode:`) to opt out. (#113)
188
+
189
+ ### Fixed
190
+
191
+ - Return `502` on backend connection errors instead of raising; correct body
192
+ handling for empty responses and no-entity-body statuses (1xx/204/304). (#58, #122, #123)
193
+
194
+ ---
195
+
196
+ Older releases (≤ 0.7.8) predate this changelog; see the git history and tags.
197
+
198
+ [Unreleased]: https://github.com/ncr/rack-proxy/compare/v1.0.2...HEAD
199
+ [1.0.2]: https://github.com/ncr/rack-proxy/compare/v1.0.1...v1.0.2
200
+ [1.0.1]: https://github.com/ncr/rack-proxy/compare/v1.0.0...v1.0.1
201
+ [1.0.0]: https://github.com/ncr/rack-proxy/compare/v0.8.3...v1.0.0
202
+ [0.8.3]: https://github.com/ncr/rack-proxy/compare/v0.8.2...v0.8.3
203
+ [0.8.2]: https://github.com/ncr/rack-proxy/compare/v0.8.1...v0.8.2
204
+ [0.8.1]: https://github.com/ncr/rack-proxy/compare/v0.8.0...v0.8.1
205
+ [0.8.0]: https://github.com/ncr/rack-proxy/compare/v0.7.8...v0.8.0
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013 Jacek Becela jacek.becela@gmail.com
3
+ Copyright (c) 2010-2026 Jacek Becela and contributors jacek.becela@gmail.com
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal