Send Enable Banking a PSU IP only when it is a public address #4304
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 524 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.375
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4304"
general
weight: 0.35
jaysbeekay
Closes #4296
Fork pre-flight: https://github.com/jaysbeekay/sure/pull/482 (same branch), where its CI and review history live. It merged at
fe32b9a39; the two commits since (234010352,cf0454a11) answer the review here.Problem
On a self-hosted instance reached over a LAN or VPN,
last_psu_ipholds the browser's private address (Rails trusts private ranges as proxies, sorequest.remote_ipis the LAN address).EnableBankingItem#build_psu_headersforwarded it asPsu-Ip-Addressto banks that require that header, and HypoVereinsbank rejects it withFORMAT_ERROR: PSU IP Address field not valid. Every balance and transaction fetch failed.Change
build_psu_headerssends the header only whenlast_psu_ipis a public address. It leaves it out for:IPAddr#private?does not cover;An IPv6 address that carries an IPv4 one (IPv4-mapped, IPv4-compatible, NAT64, 6to4) is checked as that IPv4 address. Leaving the header out is what the reporter's workaround (NULLing
last_psu_ip) already does, and HVB accepts it. Filtering where the header is built also fixes rows already stored, with no migration.The check is
NetworkAddress.public?, in a newapp/models/network_address.rb.Provider::Simplefin#embedded_ipv4moved there unchanged, and SimpleFIN delegates to it, so the unwrapping is written once (review feedback). SimpleFIN's blocked-network lists stay its own: which hosts it may connect to depends on the app mode, which isn't the question here. SimpleFIN's tests for each IPv6 encoding pass unchanged.Blast radius:
build_psu_headershas one caller,EnableBankingItem::Importer, which uses it for the balance, booked-transaction and pending-transaction fetches.{}, the same value already sent whenlast_psu_ipis NULL.Left alone: the other readers of
last_psu_ip(with_stale_psu_ip,DataCleanerJob,revoke_session) only clear it. The two controller writes are unchanged.Validation
upstream/mainat its first case (192.168.1.20 is sent) and passes after. It covers private, Docker bridge, CGNAT, IPv4/IPv6 loopback, ULA, IPv4/IPv6 link-local, mapped CGNAT, unspecified and unparseable values, an address from each special-purpose range, and a private address written as NAT64, 6to4 and IPv4-compatible.- a public IPv4 and IPv6 address, and a public address written as NAT64, are still sent;
- nothing is sent when the bank also requires a header Sure can't supply.
- full suite: 12,302 runs, 0 failures, 36 skips, at
cf0454a11;- RuboCop and Brakeman: clean;
- no UI change, no migration, no new dependency.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
Bug Fixes
PSU IP addresses are now sent only when they are valid public IPv4 or IPv6 addresses. Private, reserved, special-purpose, or invalid addresses are omitted.
PSU headers are omitted when required header information cannot be provided.
Address handling now consistently recognizes IPv4 addresses embedded in supported IPv6 formats, improving validation accuracy.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->