Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
184 commits
Select commit Hold shift + click to select a range
aa95b43
test(host): cover execution location reporting
senamakel Oct 23, 2026
0c53ae8
feat(runtime): add HostExecutionLocation capability to Host
senamakel Oct 23, 2026
d86fa6d
feat(local): report local execution location
senamakel Oct 23, 2026
6ef019d
feat(ssh): report remote execution location for ssh hosts
senamakel Oct 23, 2026
171879c
test(sandbox): cover egress controller prepare and cleanup ordering
senamakel Oct 23, 2026
62771b9
feat(docker): expose native linux egress controller
senamakel Oct 23, 2026
a259425
feat(docker): add pluggable egress controller to sandbox
senamakel Oct 23, 2026
261a654
refactor(sandbox): simplify container removal command construction
senamakel Oct 23, 2026
efeba54
feat(egress): add host validation hook to docker egress controller
senamakel Oct 23, 2026
fac41f0
feat(sandbox): route docker commands through the egress controller
senamakel Oct 23, 2026
72d08de
feat(sandbox): support allowlist network policy in docker backend
senamakel Oct 23, 2026
548863d
style: format egress enforcement and sandbox code
senamakel Oct 23, 2026
1b7ea68
fix(egress): return owned stdout from firewall output
senamakel Oct 23, 2026
7a460fc
fix(sandbox): roll back egress state when container creation fails
senamakel Oct 23, 2026
ad3750c
test(sandbox): cover native controller rejecting hosts without local …
senamakel Oct 23, 2026
bcce19b
test(sandbox): use std::io::Result in egress resolver stub
senamakel Oct 23, 2026
8acafa7
test(docker): add egress controller imports to live tests
senamakel Oct 23, 2026
40399c2
test(docker): cover native egress allowlist against raw tcp
senamakel Oct 23, 2026
8025f57
test(docker): cover egress rollback and host-gateway allowlist denial
senamakel Oct 23, 2026
67c9073
docs(specs): document docker allowlist enforcement
senamakel Oct 23, 2026
2692fff
test(sandbox): cover unknown and remote host locations
senamakel Oct 23, 2026
a08371e
test(sandbox): reformat imports and loop array
senamakel Oct 23, 2026
71fe942
test(tinybox-docker): unset proxy vars in live allowlist probes
senamakel Oct 23, 2026
7be9921
test(docker): run pinned allowlist proof in hosted live lane
senamakel Oct 23, 2026
c5b304f
test(egress): wire up egress enforcement test module
senamakel Oct 23, 2026
7e95600
fix(egress): verify docker forward hook is first in the chain
senamakel Oct 23, 2026
6172539
refactor(sandbox): extract create rollback and network policy helpers
senamakel Oct 23, 2026
01e03ea
refactor(sandbox): extract egress and failed-create helpers
senamakel Oct 23, 2026
8b38bda
test(tinybox-ssh): bind inner host in name test
senamakel Oct 23, 2026
360aa64
test: construct test ip addresses without parsing strings
senamakel Oct 23, 2026
6b0e24f
chore(deps): update tokio and pin windows-sys to 0.52.0
senamakel Oct 23, 2026
043b362
test(sandbox): cover destroy refusal for persisted allowlist without …
senamakel Oct 23, 2026
3af991c
fix(sandbox): reject destroy for allowlist boxes without egress contr…
senamakel Oct 23, 2026
d5b1cda
fix(limited): silence deprecation warning for async pipe registration
senamakel Oct 23, 2026
06e16f0
fix(egress): verify docker bridge link before installing firewall
senamakel Oct 23, 2026
5ce2df0
test(egress): compare allowlist protocols by slice
senamakel Oct 23, 2026
6e3226e
fix(egress): restrict allowlist protocols to tcp
senamakel Oct 23, 2026
b538f11
test: tighten host trait signatures and live docker test setup
senamakel Oct 23, 2026
c92d250
test(sandbox): annotate empty command vector type in assertion
senamakel Oct 23, 2026
5e4efd2
test(egress): cover native controller allowlist prepare and cleanup
senamakel Oct 23, 2026
9a91319
test(egress): assert prepare succeeds before unwrapping
senamakel Oct 23, 2026
9ec20d5
test(egress): match docker subcommands by position-independent search
senamakel Oct 23, 2026
1098304
fix(egress): route network inspect through rootful docker helper
senamakel Oct 23, 2026
2feec32
test(sandbox): cover controller host forwarding and egress rollback
senamakel Oct 23, 2026
f3025bc
test(sandbox): tidy host capability assertions and egress rollback check
senamakel Oct 23, 2026
bd643a4
test(egress): rename docker args binding in fake host
senamakel Oct 23, 2026
9cc4e45
feat(docker): pin egress hostnames via /etc/hosts
senamakel Oct 23, 2026
4097e7a
feat(tinybox-docker): expose prepared egress network from sandbox
senamakel Oct 23, 2026
ad65298
test(egress): cover pinned host mappings and dns blocking
senamakel Oct 23, 2026
83f0a58
docs(tinybox-docker): describe egress plan as consumed by the native …
senamakel Oct 23, 2026
a7fbda7
fix(sandbox): skip egress cleanup for non-allowlist boxes
senamakel Oct 23, 2026
6b08860
test(sandbox): cover allowlist run args pinning resolved addresses
senamakel Oct 23, 2026
fa5d1a4
fix(egress): skip firewall cleanup when network creation fails
senamakel Oct 23, 2026
276c2d7
refactor(sandbox): drop dns pinning and host mappings from docker args
senamakel Oct 23, 2026
5aa6143
fix(sandbox): pin allowlist network dns to loopback
senamakel Oct 23, 2026
af47a8d
docs(specs): clarify docker dns upstream rationale
senamakel Oct 23, 2026
2e00f4a
fix(egress): roll back network setup and allow IPv6 neighbour discovery
senamakel Oct 23, 2026
cf45605
test(docker): assert firewall rule ordering and published-port reacha…
senamakel Oct 23, 2026
e76e1eb
test(docker): cover ipv6 allowlist egress in live test
senamakel Oct 23, 2026
c6193aa
test(docker): fix live egress allowlist probe cleanup
senamakel Oct 23, 2026
735bcae
docs: document allowlist bridge-to-host exceptions
senamakel Oct 23, 2026
076be2d
refactor(tinybox-docker): extract pinned destination rules into helper
senamakel Oct 23, 2026
c5d229b
test(sandbox): assert rollback failure reports its own operation
senamakel Oct 23, 2026
4f79487
test(sandbox): cover failed create cleanup retaining the record
senamakel Oct 23, 2026
e78512e
test(sandbox): update insert_new call in cleanup retry test
senamakel Oct 23, 2026
505fdfb
test(sandbox): recover poisoned lock in failed create cleanup test
senamakel Oct 23, 2026
d1d3c9f
test(tinybox-docker): fix escaped quotes in live network inspect format
senamakel Oct 23, 2026
e310460
test(tinybox-docker): extract ipv6 inspect template helper
senamakel Oct 23, 2026
f48aeb9
test(tinybox-docker): read a single line from the published port
senamakel Oct 23, 2026
8d39638
test(tinybox-docker): drop unused mut in live docker test
senamakel Oct 23, 2026
9dd619d
test(live-docker): serve published port over http
senamakel Oct 23, 2026
11a2901
test(tinybox-docker): make stream binding mutable in live test
senamakel Oct 23, 2026
535cbd1
test(tinybox-docker): read published-port response incrementally
senamakel Oct 23, 2026
cbe0bc0
test(tinybox-docker): tolerate read timeouts while polling published …
senamakel Oct 23, 2026
5c86897
test(tinybox-docker): collapse match arm onto one line
senamakel Oct 23, 2026
27e867b
test(limited): cover local execution location reporting
senamakel Oct 23, 2026
f509d91
feat(limited): report execution location for limited local host
senamakel Oct 23, 2026
9d758b9
test(egress): cover ipv4-mapped ipv6 answers
senamakel Oct 23, 2026
c256479
fix(egress): normalize ipv4-mapped addresses in allowlist
senamakel Oct 23, 2026
87e7362
test(egress): cover ipv4-mapped answers in native controller
senamakel Oct 23, 2026
b697808
fix(egress): make ipv4 arm of normalize_ip_address exhaustive
senamakel Oct 23, 2026
94f4bc3
test(docker): assert established input rule precedes drop rules
senamakel Oct 23, 2026
6127f90
fix(egress): allow established return traffic to the host
senamakel Oct 23, 2026
c54c060
test(egress): extract input rule assertions into a helper
senamakel Oct 23, 2026
50d033d
docs: clarify egress enforcement comments and contract wording
senamakel Oct 23, 2026
704000d
test(tinybox-docker): retry reads on connection reset in live test
senamakel Oct 23, 2026
f75425b
test(tinybox-docker): start published-port httpd detached via docker …
senamakel Oct 23, 2026
0ffed93
test(tinybox-docker): fix stderr_lossy ownership in live test
senamakel Oct 23, 2026
e3c2f8c
test(live-docker): serve published port with nc loop
senamakel Oct 23, 2026
1eedbc9
test(tinybox-docker): simplify published-port probe payload
senamakel Oct 23, 2026
a292574
test(tinybox-docker): cover both listener probe ports in allowlist
senamakel Oct 23, 2026
40e98f7
test(tinybox-docker): cover additional allowlist probe port
senamakel Oct 23, 2026
42a115b
test(docker): cover cleanup refusing a foreign network owner
senamakel Oct 23, 2026
8445400
test(egress): cover network scope and chain owner tokens
senamakel Oct 23, 2026
510a171
fix(egress): scope firewall chain cleanup to the owning box
senamakel Oct 23, 2026
3c8a1a5
test(docker): track deleted iptables chains in egress test host
senamakel Oct 23, 2026
b75f26c
test(egress): track created firewall chains in prepared host
senamakel Oct 23, 2026
d46f959
fix(tinybox-docker): scope owner tokens and tighten egress deny rules
senamakel Oct 23, 2026
8ce6b3c
test(tinybox-docker): track firewall chains per iptables variant
senamakel Oct 23, 2026
6fc2345
test(egress): import deny_rules in enforcement tests
senamakel Oct 23, 2026
973d525
test(egress): simplify destination assertions in metadata deny test
senamakel Oct 23, 2026
cd2dfd5
test(egress): cover scope token sha256 identity
senamakel Oct 23, 2026
e3e777a
style: fix indentation and import ordering
senamakel Oct 23, 2026
c613673
refactor(egress): build scope tokens and fake output without intermed…
senamakel Oct 23, 2026
4c0db33
refactor(egress): replace fmt::Write hex formatting with direct push
senamakel Oct 23, 2026
96cd674
refactor(egress): hoist hex table to module scope
senamakel Oct 23, 2026
8fe4d5c
test(tinybox-docker): cover busybox nc ipv6 flag handling
senamakel Oct 23, 2026
69b5a7d
test(live-docker): drop ipv6 flag from listener probe
senamakel Oct 23, 2026
9a1af48
test(egress): cover chain marker install failure rollback
senamakel Oct 23, 2026
46b0dd1
test(egress): fix chain owner token comparison in native host
senamakel Oct 23, 2026
2f39145
fix(egress): track chains created during a failed setup attempt
senamakel Oct 23, 2026
4381551
test(docker): track owner-marked chains in egress enforcement fake
senamakel Oct 23, 2026
14f9e9a
test(egress): clone firewall when removing chain in test host
senamakel Oct 23, 2026
8c9ab9d
fix(egress): use cleanup_native on setup failure
senamakel Oct 23, 2026
2b5bc49
fix(egress): clean up only chains owned by the failed attempt
senamakel Oct 23, 2026
11c48e2
test(egress): gate native controller tests to linux
senamakel Oct 23, 2026
c6f01d0
chore(egress): allow too_many_lines on install_family
senamakel Oct 23, 2026
67eb415
test(egress): gate linux-only helpers behind cfg
senamakel Oct 23, 2026
51f20dc
fix(docker): reject IPv6 link-local egress targets and reconcile ambi…
senamakel Oct 23, 2026
bbc20ec
test(egress): cover ambiguous network create with absent or foreign n…
senamakel Oct 23, 2026
95dcde9
test(tinybox-docker): model network create outcomes with an enum
senamakel Oct 23, 2026
1e317f5
test(egress): reformat network create failure check
senamakel Oct 23, 2026
da175d8
test(egress): cover network inspect outcomes in rollback tests
senamakel Oct 23, 2026
0995ddc
fix(egress): reconcile failed docker network creation
senamakel Oct 23, 2026
800c922
fix(egress): report docker stderr when network inspection fails
senamakel Oct 23, 2026
ded8757
fix(egress): require the final drop rule in each chain
senamakel Oct 23, 2026
42161c9
test(sandbox): cover docker argv rewriting for non-idempotent control…
senamakel Oct 23, 2026
eab6f87
refactor(sandbox): drop unused docker argv rewriting
senamakel Oct 23, 2026
5473691
test(egress): cover pinned targets inside auto-selected subnets
senamakel Oct 23, 2026
2407dd9
fix(egress): reject allowlist targets inside the docker network subnet
senamakel Oct 23, 2026
4df125e
test(egress): tighten assertion for iptables rule commands
senamakel Oct 23, 2026
281cc29
test(tinybox-docker): silence dead code warnings on non-linux
senamakel Oct 23, 2026
48382a6
test(sandbox): use assert_ne for docker command count
senamakel Oct 23, 2026
7706604
docs(egress): document ipam subnet refusal for pinned destinations
senamakel Oct 23, 2026
aa97407
test(egress): cover owner marker restore when chain delete fails
senamakel Oct 23, 2026
c30bcce
test(egress): guard fail_chain_delete_once with a mutex
senamakel Oct 23, 2026
27fea97
fix(egress): restore ownership marker when chain deletion fails
senamakel Oct 23, 2026
877357c
test(egress): fix host mutability in enforcement tests
senamakel Oct 23, 2026
3d88625
style(tinybox-docker): reformat egress enforcement code
senamakel Oct 23, 2026
fb45030
test(egress): gate chain delete retry test to linux
senamakel Oct 23, 2026
fed0596
chore: add rustc ice reports
senamakel Oct 23, 2026
7a33ef7
chore: remove rustc ice dump files
senamakel Oct 23, 2026
1035a75
chore: add rustc ice report
senamakel Oct 23, 2026
234e47b
chore: remove stray rustc ICE dump file
senamakel Oct 23, 2026
8b01db2
test(limited): cover jailed local host execution location
senamakel Oct 23, 2026
68ce742
feat(host): report local execution location for jailed host
senamakel Oct 23, 2026
df370e8
test(egress): assert same-owner network conflict is not removed
senamakel Oct 23, 2026
74f7388
fix(egress): return original error on network create failure
senamakel Oct 23, 2026
302ab4a
test(egress): capture iptables-restore scripts in prepared host
senamakel Oct 23, 2026
1ec263e
test(egress): cover atomic chain creation and restart-safe cleanup
senamakel Oct 23, 2026
8de0a4e
fix(egress): create firewall chains atomically with owner marker
senamakel Oct 23, 2026
d138253
fix(egress): append owner marker without flushing the chain
senamakel Oct 23, 2026
88a2343
test(egress): assert per-chain restore scripts and binaries
senamakel Oct 23, 2026
dbcccc6
test(egress): reformat restore program assertion
senamakel Oct 23, 2026
d435d30
test(egress): assert no inspect runs on network name conflict
senamakel Oct 23, 2026
a7d4238
test(egress): reformat inspect assertion to match rustfmt
senamakel Oct 23, 2026
d517027
refactor(egress): key firewall chains by per-attempt token
senamakel Oct 23, 2026
d9fa023
fix(egress): label egress networks with the attempt token
senamakel Oct 23, 2026
f82ebf6
fix(egress): include attempt label in network inspect format
senamakel Oct 23, 2026
c15a250
fix(docker): verify egress network ownership before cleanup
senamakel Oct 23, 2026
1efe331
refactor(egress): remove redundant network existence check
senamakel Oct 23, 2026
087c771
test(egress): split restart cleanup coverage into empty and nonempty …
senamakel Oct 23, 2026
2df862a
fix(egress): match attempt label when reconciling ambiguous network c…
senamakel Oct 23, 2026
39fec21
test(egress): cover ambiguous create preserving older attempt network
senamakel Oct 23, 2026
87febd7
test(egress): inline attempt label and mark prepared hosts mutable
senamakel Oct 23, 2026
68d7897
test(egress): fix mutability of prepared host bindings
senamakel Oct 23, 2026
d19c9fd
test(egress): fix mutability of prepared host bindings in tests
senamakel Oct 23, 2026
484de6d
docs(egress_enforcement): describe per-attempt chain ownership
senamakel Oct 23, 2026
a87f185
test(docker): track chains with rules in egress enforcement fake host
senamakel Oct 23, 2026
813a341
test(egress): reuse resolved firewall binary in chain bookkeeping
senamakel Oct 23, 2026
dc13f6a
test(egress): reuse firewall value when clearing chain state
senamakel Oct 23, 2026
9e089c6
style(tinybox-docker): reformat egress enforcement code
senamakel Oct 23, 2026
ab87d25
test(egress): remove duplicate firewall lookup in prepared host
senamakel Oct 23, 2026
df474af
test(egress): mark chains as owned in cleanup ownership test
senamakel Oct 23, 2026
fd6b891
test(egress): rename marker failure test to describe rollback
senamakel Oct 23, 2026
f60d878
test(egress): cover cleanup when no orphaned chains exist
senamakel Oct 23, 2026
c51b031
test(egress): relax iptables chain count assertion
senamakel Oct 23, 2026
e8023a0
test(egress): cover rollback failure when owned network removal fails
senamakel Oct 23, 2026
a2566e9
test(egress): inject one-shot network removal failure
senamakel Oct 23, 2026
ff5bbd6
test(egress): report prepare result and commands on rollback failure
senamakel Oct 23, 2026
a7daa81
test(egress): match simulated lost response in rollback assertion
senamakel Oct 23, 2026
aece4b6
test(egress): gate network removal assertion to linux
senamakel Oct 23, 2026
3bd7f10
test(egress): fix indentation of linux cfg attribute
senamakel Oct 23, 2026
1923fef
test(egress): gate no_matching_hooks field to linux
senamakel Oct 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/tinybox-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub use identity::{BoxId, HostRef, ProcessId, SandboxRef, SnapshotId, TemplateNa
pub use passthrough::PassthroughSandbox;
pub use runtime::{
BoxInfo, BoxState, ExecOutput, ExecRequest, ExecutionObserver, Forward, ForwardGuard, Host,
OutputStream, Sandbox, WorkspaceFileReader, WorkspaceFileWriter,
HostExecutionLocation, OutputStream, Sandbox, WorkspaceFileReader, WorkspaceFileWriter,
};
pub use spec::{
BoxSpec, EgressAllowlist, Lifecycle, NetworkPolicy, Placement, PortMapping, Resources,
Expand Down
24 changes: 24 additions & 0 deletions crates/tinybox-core/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ mod types;
pub use forward::{Forward, ForwardGuard};
pub use types::{BoxInfo, BoxState, ExecOutput, ExecRequest};

/// Where a host executes commands relative to the tinybox process.
///
/// Security-sensitive controllers use this explicit capability instead of
/// guessing from a host's registration name. Custom hosts default to
/// [`Unknown`](Self::Unknown) until they can state their location.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum HostExecutionLocation {
/// Commands execute in this process's operating-system environment.
Local,
/// Commands execute on another machine.
Remote,
/// The host cannot make a trustworthy locality claim.
Unknown,
}

/// A readable file opened beneath a host- or sandbox-mounted workspace.
#[async_trait]
pub trait WorkspaceFileReader: std::fmt::Debug + Send + Sync {
Expand Down Expand Up @@ -90,6 +105,15 @@ pub trait Host: std::fmt::Debug + Send + Sync + 'static {
/// [`HostRef`](crate::identity::HostRef).
fn name(&self) -> &str;

/// The machine on which commands run.
///
/// This defaults to [`HostExecutionLocation::Unknown`]; a controller that
/// requires local machine access must refuse hosts that do not explicitly
/// attest to it.
fn execution_location(&self) -> HostExecutionLocation {
HostExecutionLocation::Unknown
Comment thread
senamakel marked this conversation as resolved.
}
Comment thread
senamakel marked this conversation as resolved.

/// Run a command to completion and collect its output.
///
/// # Errors
Expand Down
4 changes: 4 additions & 0 deletions crates/tinybox-docker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ publish = false
[dependencies]
tinybox-core.workspace = true
async-trait.workspace = true
# Parse Docker-assigned CIDRs and reject pinned destinations within them.
ipnet = "2.12"
serde_json.workspace = true
# SHA-256 keeps firewall cleanup ownership markers collision-resistant.
sha2 = "0.10.9"
Comment thread
senamakel marked this conversation as resolved.
# `DockerCli` runs the local `docker` client; one-shot runs need process spawning
# and a deadline.
tokio = { workspace = true, features = ["process"] }
Expand Down
49 changes: 40 additions & 9 deletions crates/tinybox-docker/src/egress.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//! Planning helpers for future network allowlist enforcement.
//! Resolve and pin network allowlist destinations for the Docker firewall.
//!
//! These types pin resolver answers for a later proxy or firewall to consume.
//! They do not enforce traffic and do not make `NetworkPolicy::Allowlist`
//! available in [`DockerSandbox`](crate::DockerSandbox).
//! The native Linux controller consumes pinned answers for firewall rules and
//! container `/etc/hosts` entries. Planning alone does not enforce traffic.

use std::{
collections::{BTreeMap, BTreeSet},
Expand All @@ -23,6 +22,9 @@ pub trait EgressResolver: std::fmt::Debug + Send + Sync {
}

/// A resolved allowlist plan whose destinations no longer depend on DNS.
///
/// The native Linux Docker controller uses each target both to install a
/// destination rule and to create a static hostname mapping for the workload.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PinnedEgressPlan {
targets: Vec<PinnedEgressTarget>,
Expand Down Expand Up @@ -76,16 +78,18 @@ impl PinnedEgressTarget {
/// is a cloud metadata or loopback address, the whole plan is rejected. Safe
/// private addresses are retained because this policy does not forbid them.
///
/// This function only prepares data for an enforcing proxy or firewall. It does
/// not apply network rules and does not enable allowlists in `DockerSandbox`.
/// This function only prepares pinned data. It does not apply network rules;
/// the native Linux Docker controller consumes the result during preparation.
/// The resolver must answer in the environment where the eventual enforcer will
/// use the plan, which may be remote from the caller for an SSH-backed host.
///
/// # Errors
///
/// Returns [`Error::InvalidNetworkPolicy`] for a malformed allowlist, an empty
/// DNS answer, or any resolved metadata or loopback address. Resolver errors
/// are returned as [`Error::Backend`].
/// DNS answer, or any resolved metadata or loopback address. Returns
/// [`Error::ConstraintNotEnforced`] when an IPv6 link-local target needs an
/// interface scope that this backend cannot preserve. Resolver errors are
/// returned as [`Error::Backend`].
pub fn plan_egress_allowlist(
allowlist: &EgressAllowlist,
resolver: &dyn EgressResolver,
Expand All @@ -112,12 +116,23 @@ pub fn plan_egress_allowlist(
reason: "allowlist host resolved to no addresses",
});
}
let addresses = addresses
.into_iter()
.map(normalize_ip_address)
.collect::<BTreeSet<_>>();
if addresses.iter().any(is_forbidden_address) {
return Err(Error::InvalidNetworkPolicy {
reason: "allowlist host resolves to a metadata or loopback address",
});
}
addresses_by_host.insert(host, addresses.into_iter().collect());
if addresses.iter().any(is_ipv6_link_local) {
return Err(Error::ConstraintNotEnforced {
sandbox: "docker".to_owned(),
constraint: tinybox_core::Constraint::Network,
enforcement: tinybox_core::Enforcement::Unsupported,
});
}
addresses_by_host.insert(host, addresses);
}

let ports: BTreeSet<_> = allowlist.ports.iter().copied().collect();
Expand All @@ -141,6 +156,15 @@ fn normalize_host(host: &str) -> String {
host.trim().trim_matches(['[', ']']).to_ascii_lowercase()
}

fn normalize_ip_address(address: IpAddr) -> IpAddr {
match address {
IpAddr::V6(address) => address
.to_ipv4_mapped()
.map_or(IpAddr::V6(address), IpAddr::V4),
IpAddr::V4(address) => IpAddr::V4(address),
}
}

fn is_forbidden_address(address: &IpAddr) -> bool {
if EgressAllowlist::is_metadata_host(&address.to_string()) {
return true;
Expand All @@ -157,6 +181,13 @@ fn is_forbidden_address(address: &IpAddr) -> bool {
}
}

fn is_ipv6_link_local(address: &IpAddr) -> bool {
match address {
IpAddr::V4(_) => false,
IpAddr::V6(address) => address.segments()[0] & 0xffc0 == 0xfe80,
}
}

#[cfg(test)]
#[path = "egress_tests.rs"]
mod tests;
Loading
Loading