Skip to main content

ScriptPolicy

Struct ScriptPolicy 

Source
pub struct ScriptPolicy {
    pub shell: bool,
    pub python: bool,
    pub lua: bool,
    pub timeout_ms: u64,
    pub total_timeout_s: u64,
    pub trusted: Vec<String>,
}
Expand description

What external scripts may do on one request. The daemon builds it from the settings (rewrite.external_scripts, the timeouts) and the repository’s trust store, and replaces whatever a client sent: a frontend cannot grant itself anything. The default is the safe one a bare backend (a test) sees: shell scripts allowed, Python and external Lua off, nothing trusted.

Fields§

§shell: bool§python: bool§lua: bool§timeout_ms: u64

Per-request timeout in milliseconds.

§total_timeout_s: u64

Whole-pass timeout in seconds.

§trusted: Vec<String>

Content hashes (script_hash) the user trusted, plus the ones the caller vouched for on this request (a script the user typed).

Implementations§

Source§

impl ScriptPolicy

Source

pub fn is_default(&self) -> bool

Source

pub fn allows(&self, language: ScriptLanguage) -> bool

Whether the settings allow language (the embedded Lua always).

Source

pub fn trusts(&self, hash: &str) -> bool

Source

pub fn from_settings( enabled: &[String], timeout_ms: u64, total_timeout_s: u64, ) -> Self

The policy for a rewrite.external_scripts list (shell, python, lua) and the two timeouts (0 reads as the default).

Trait Implementations§

Source§

impl Clone for ScriptPolicy

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScriptPolicy

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ScriptPolicy

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ScriptPolicy

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ScriptPolicy

Source§

impl PartialEq for ScriptPolicy

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ScriptPolicy

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ScriptPolicy

Auto Trait Implementations§

§

impl Forget for ScriptPolicy

§

impl Freeze for ScriptPolicy

§

impl Move for ScriptPolicy

§

impl RefUnwindSafe for ScriptPolicy

§

impl Send for ScriptPolicy
where RawVecInner: Send,

§

impl Sync for ScriptPolicy
where RawVecInner: Sync,

§

impl Unpin for ScriptPolicy
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for ScriptPolicy

§

impl UnwindSafe for ScriptPolicy
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.