pub struct TrainingResult { /* private fields */ }
Expand description

The result of “training” the fuzzer on a set of web pages. Contains the selectors for each attribute, as well as the original settings used. If training for a particular attribute failed, the attribute/selector pair will be not present in this object.

This result can also be used to extract data from previously unseen documents, for example:

let mut dom = result.parse(&new_page).expect("parse");
let attribute_1 = result.get_value(&dom, "attribute_1_name").expect("get_value");
let attribute_2 = result.get_value(&dom, "attribute_2_name").expect("get_value");
// ...

Enable the “serde” feature to enable serialization/deserialization using serde. This can be useful for reusing previously computed training results.

Implementations§

source§

impl TrainingResult

source

pub fn selectors(&self) -> &HashMap<String, Selector>

source

pub fn attributes<'a>(&'a self) -> Box<dyn Iterator<Item = &'a str> + 'a>

source

pub fn parse<'s>(&self, document: &'s str) -> Result<VDom<'s>>

Parse a document and return the DOM object. Calling this and reusing the DOM object is more efficient than calling TrainingResult::parse_and_get_value multiple times.

source

pub fn parse_and_get_value( &self, document: &str, attribute_name: &str ) -> Result<Option<String>>

Parse a document and return the value of the given attribute. This is equivalent to calling TrainingResult::parse and then TrainingResult::get_value.

source

pub fn get_value<'a>( &self, dom: &'a VDom<'a>, attribute_name: &str ) -> Result<Option<String>>

Get the value of the given attribute from the given DOM object.

source

pub fn get_selector<'a>(&'a self, attribute_name: &str) -> Option<&'a str>

Get the best selector for the given attribute.

source

pub fn highlight_selections_with_red_border(&self, dom: &mut VDom<'_>) -> String

Highlight the selected elements for the given attribute in the given DOM object by adding a red border around them.

This will both alter the input DOM and return the resulting HTML as String, which, as I realize writing this, may be a poor design choice. TODO.

Example: ´´´ let out_html = training_result.highlight_selections_with_red_border(&mut dom); fs::write(“out.html”, out_html).expect(“write”); ´´´

Trait Implementations§

source§

impl Debug for TrainingResult

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V