pub struct UrlPolicy {
pub enabled: bool,
pub allow_private: bool,
pub allowed_domains: HashSet<String>,
pub blocked_domains: HashSet<String>,
}Expand description
Runtime URL safety policy for SSRF protection.
Controls which URLs the web fetch tool is allowed to access.
Constructed from super::config::UrlPolicyConfig at startup.
Note: the full URL validation logic (DNS resolution, CIDR checks) lives
in clawft-tools::url_safety::validate_url which depends on external
crates. This struct is the shared data container.
Fields§
§enabled: boolWhether URL safety checks are active.
allow_private: boolWhether to allow requests to private/reserved IP ranges.
allowed_domains: HashSet<String>Domains that bypass all safety checks.
blocked_domains: HashSet<String>Domains that are always blocked.
Implementations§
Source§impl UrlPolicy
impl UrlPolicy
Sourcepub fn new(
enabled: bool,
allow_private: bool,
allowed_domains: HashSet<String>,
blocked_domains: HashSet<String>,
) -> Self
pub fn new( enabled: bool, allow_private: bool, allowed_domains: HashSet<String>, blocked_domains: HashSet<String>, ) -> Self
Create a new policy with the given settings.
Sourcepub fn permissive() -> Self
pub fn permissive() -> Self
Create a permissive policy that disables all checks.
Intended for testing and development only.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UrlPolicy
impl RefUnwindSafe for UrlPolicy
impl Send for UrlPolicy
impl Sync for UrlPolicy
impl Unpin for UrlPolicy
impl UnsafeUnpin for UrlPolicy
impl UnwindSafe for UrlPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more