Engine

Struct Engine 

Source
pub struct Engine { /* private fields */ }

Implementations§

Source§

impl Engine

Source

pub fn new() -> Engine

Create a new engine

Create a new engine, using default values, and no scores or vulnerabilities.

Source

pub fn add_file_vuln<F, S>(&mut self, name: S, f: F)
where F: FnMut(&mut Self, Option<&mut File>) -> bool + Send + Sync + 'static, S: ToString,

Register a file vulnerability

Register a file vulnerability. This takes the form of a function/closure that takes an &mut Engine, and a Option<&mut File>, and returns a bool.

If the closure returns true, the vulnerability is interpreted as being completed, it is incomplete. More on that in Engine::update and Engine::enter

Source

pub fn add_app_vuln<F, S>( &mut self, name: S, install_method: InstallMethod, f: F, )
where F: FnMut(&mut Self, AppData) -> bool + Send + Sync + 'static, S: ToString,

Register a package/app vulnerability

Register a package/app vulnerability. This takes the form of a function/closure that takes an &mut Engine, and an AppData, and returns a bool.

If the closure returns true, the vulnerability is interpreted as being completed, it is incomplete. More on that in Engine::update and Engine::enter

Source

pub fn add_user_vuln<F, S>(&mut self, name: S, f: F)
where F: FnMut(&mut Self, &str) -> bool + Send + Sync + 'static, S: ToString,

Register a user vulnerability

Register a user vulnerability. This takes the form of a function/closure that takes a &mut Engine, and a str, and returns a bool.

If the closure returns true, the vulnerability is interpreted as being completed, it is incomplete. More on that in Engine::update and Engine::enter

Source

pub fn add_misc_vuln<F>(&mut self, f: F)
where F: FnMut(&mut Self) -> bool + Send + Sync + 'static,

Register a miscellaneous vulnerability

Register a miscellaneous vulnerability. This takes the form of a function/closure that takes only a &mut Engine, and returns a bool.

If the closure returns true, the vulnerability is interpreted as being completed, it is incomplete. More on that in Engine::update and Engine::enter

Source

pub fn add_hook<F, T>(&mut self, f: F)
where F: FnMut(&mut Self) -> T + Send + Sync + 'static,

Register a hook vulnerability

Register a hook vulnerability, which takes the form of a closure that takes a &mut Engine as it’s only parameter. In reality this registers a miscellaneous vulnerability (see Engine::add_misc_vuln). This miscellaneous vulnerability is literally just a call to the hook that discards it’s return, and returns false.

Source

pub fn set_freq(&mut self, frequency: u64)

Sets the frequency in seconds at which the engine is updated.

Sets the frequency in seconds at which Engine::update is called, if using Engine::enter.

This is handled as a private variable called incomplete_freq

Source

pub fn set_completed_freq(&mut self, frequency: u64)

Sets the frequency in iterations of engine updates that completed vulnerabilities are reviewed.

Sets the frequency in iterations of engine updates that completed vulnerabilities are re-executed. This value is important even if you don’t use Engine::enter because of the way it is interpreted by Engine::update

Internally this is handled as a variable called complete_freq

Source

pub fn add_score(&mut self, id: u64, add: i32, reason: String)

Adds an entry to the score report, with an ID, a score value, and an explanation

Adds an entry to the score report, with an ID, a score value, and an explanation. If an entry exists with the same ID, it instead changes the score and explanation

Source

pub fn remove_score(&mut self, id: u64) -> Result<(), ()>

Removes the entry identified

Source

pub fn generate_score_report(&mut self) -> Vec<(String, i32)>

Generates a list of score entries Generates a vector containing the explanation and value of each score entry in order

Source

pub fn update(&mut self)

Executes vulnerabilites

Incomplete vulnerabilites are excuted each time the function is executed. Complete vulnerabilites are excuted only if the number of iterations mod complete_freq is 0

Source

pub fn enter(&mut self)

Start engine execution on this thread

This enters an loop that calls Engine::update incomplete_freq times per second.

This state of execution only takes control of one thread, and other threads can generally continue without issue, however, new vulnerabilities cannot be added.

Source

pub fn stop(&mut self, blocking: bool)

Tells the engine to exit.

This stops engine execution if Engine::enter was called. Otherwise does nothing, unless if blocking is set to true. If blocking is set, it will wait until the current running update stops to return.

Source

pub fn calc_total_score(&self) -> i32

Calculate a total score

Calculate the total score for the current engine.

Source

pub fn get_entry(&self, id: u64) -> Option<(u64, i32, String)>

Get the entry identified by id, if it exists.

Source

pub fn entry_exists(&self, id: u64) -> bool

Checks if the entry identified by id exists

Auto Trait Implementations§

§

impl !Freeze for Engine

§

impl RefUnwindSafe for Engine

§

impl Send for Engine

§

impl Sync for Engine

§

impl Unpin for Engine

§

impl UnwindSafe for Engine

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.