The live webhook transport used reqwest::Client::new(): any address, default redirects, and its own DNS lookup at connect time. - New shared crate apps/rago/crates/egress-guard (also used by rithub), a port of product-analytics net-guard.ts: blocked IPv4 ranges (this network, private, CGNAT incl. 100.100.100.200, loopback, link-local incl. 169.254.169.254, IETF, documentation, 6to4 relay, benchmarking, multicast, reserved); IPv6 judged on the IPv4 it carries (mapped, compatible, 6to4), otherwise only global unicast 2000::/3 outside 2001::/23, 2001:db8::/32 and 3fff::/20 (so ::1, ULA incl. fd00:ec2::254, fe80::/10, NAT64 are refused). check_url uses the WHATWG parser, so decimal, octal, hex and short IPv4 spellings are judged as the address they name. resolve_pinned resolves once and refuses if any answer is internal; pinned_client connects only to those addresses (resolve_to_addrs), follows no redirect, ignores proxies. - HttpTransport gains post_external (default: post); ReqwestTransport overrides it with the guard. Provider and Mint calls are unchanged. - webhooks::deliver checks the endpoint first (refused: failed, no retry, nothing sent) and posts through post_external. RAGO_WEBHOOK_ALLOW_PRIVATE=1 lifts the address rule for self-hosted receivers (still pinned). Tests: cargo test -p egress-guard 7/7 (address spellings incl. 2130706433, 0177.0.0.1, 0x7f.1, [::ffff:127.0.0.1], metadata; mixed answers refused; rebinding: one lookup and the pinned client reaches a host that has no DNS record; redirect to 127.0.0.1 not followed); cargo test -p rago-integrations (+ --features live) all green incl. tests/webhook_egress.rs; rago-jobs tests green; rago-api/rago-jobs check with live. Clippy -D warnings clean on egress-guard and rago-integrations (with and without live). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
946 B
TOML
29 lines
946 B
TOML
[package]
|
|
name = "egress-guard"
|
|
version = "0.1.0"
|
|
edition = "2021"
|
|
license = "MIT"
|
|
rust-version = "1.80"
|
|
description = "Outbound requests to user-chosen URLs reach public addresses only: one resolution, validated, pinned; no redirects"
|
|
# Shared by rago (outbound webhooks) and rithub (repository webhooks); rithub
|
|
# depends on it by path. No workspace inheritance so either workspace can
|
|
# build it as a path dependency.
|
|
|
|
[features]
|
|
# The pinned reqwest client. On by default so `cargo test` covers it; rago
|
|
# turns it on only with its `live` transport.
|
|
default = ["reqwest"]
|
|
reqwest = ["dep:reqwest"]
|
|
|
|
[[test]]
|
|
name = "guard"
|
|
required-features = ["reqwest"]
|
|
|
|
[dependencies]
|
|
url = "2"
|
|
tokio = { version = "1", features = ["net"] }
|
|
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"], optional = true }
|
|
|
|
[dev-dependencies]
|
|
tokio = { version = "1", features = ["net", "rt-multi-thread", "macros", "io-util", "time"] }
|