SsrfGuard class
Security guard that protects outbound HTTP requests (URL inspector, crawler preview) against Server-Side Request Forgery (SSRF), internal network scanning, and cloud metadata access.
Constructors
Properties
-
allowedHosts
→ Set<
String> -
Optional strict hostname allowlist.
final
- allowLocalhostInDev → bool
-
Whether localhost/loopback is permitted for local development inspection.
This opt-in permits loopback only; private, link-local and special-purpose
ranges remain blocked.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
resolver
→ Future<
List< Function(String host)InternetAddress> > -
Resolver hook for deterministic tests and controlled server environments.
Every returned address is checked; an empty or mixed unsafe result fails closed.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createPinnedClient(
{Duration connectionTimeout = const Duration(seconds: 10)}) → Client -
Creates an
http.Clientthat pins every socket connection directly to an IP address that was validated against SSRF rules, preventing DNS rebinding. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolveAndValidate(
Uri uri) → Future< List< InternetAddress> > -
Resolves
uriand returns only after every candidate address passes policy. A pinned socket transport must connect directly to one of these returned addresses instead of resolving the hostname again. -
toString(
) → String -
A string representation of this object.
inherited
-
validateUri(
Uri uri) → Future< void> -
Validates
uriagainst SSRF boundaries before making any network connection. Throws SecurityException if the target violates security constraints.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited