pub struct NetworkPolicy {
pub enabled: bool,
pub allowed_url_prefixes: Vec<String>,
pub allowed_methods: HashSet<String>,
pub max_redirects: usize,
pub max_response_size: usize,
pub timeout: Duration,
}Expand description
Policy controlling network access for commands like curl.
Disabled by default — scripts have no network access unless the embedder explicitly enables it and configures an allow-list.
Fields§
§enabled: bool§allowed_url_prefixes: Vec<String>§allowed_methods: HashSet<String>§max_redirects: usize§max_response_size: usize§timeout: DurationImplementations§
Source§impl NetworkPolicy
impl NetworkPolicy
Sourcepub fn validate_url(&self, url: &str) -> Result<(), String>
pub fn validate_url(&self, url: &str) -> Result<(), String>
Validate that url matches at least one entry in allowed_url_prefixes.
The raw URL is first parsed and re-serialized via url::Url to
normalize it (resolve default ports, percent-encoding, etc.), and then
each allowed prefix is checked with a simple starts_with.
Prefixes are also normalized via url::Url when possible to prevent
subdomain confusion attacks (e.g. a prefix of "https://api.example.com"
without a trailing slash would otherwise match "https://api.example.com.evil.com/").
Trait Implementations§
Source§impl Clone for NetworkPolicy
impl Clone for NetworkPolicy
Source§fn clone(&self) -> NetworkPolicy
fn clone(&self) -> NetworkPolicy
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for NetworkPolicy
impl Debug for NetworkPolicy
Auto Trait Implementations§
impl Freeze for NetworkPolicy
impl RefUnwindSafe for NetworkPolicy
impl Send for NetworkPolicy
impl Sync for NetworkPolicy
impl Unpin for NetworkPolicy
impl UnsafeUnpin for NetworkPolicy
impl UnwindSafe for NetworkPolicy
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