Skip to main content

FindingBuilder

Struct FindingBuilder 

Source
pub struct FindingBuilder { /* private fields */ }
Expand description

Builder for constructing findings with a fluent API.

Required fields are set in Finding::builder. Optional fields are added via chained methods.

Implementations§

Source§

impl FindingBuilder

Source

pub fn title(self, title: impl Into<String>) -> Self

Set the finding title.

Examples found in repository?
examples/serialize_json.rs (line 9)
7fn main() {
8    let finding = Finding::builder("my-scanner", "192.168.1.100", Severity::Critical)
9        .title("Default Credentials")
10        .detail("Admin interface uses admin:admin")
11        .tag("auth")
12        .build();
13
14    let json = serde_json::to_string_pretty(&finding).expect("Failed to serialize");
15    println!("Serialized Finding:\n{}", json);
16}
More examples
Hide additional examples
examples/basic.rs (line 5)
3fn main() {
4    let finding = Finding::builder("basic-scanner", "https://example.com", Severity::High)
5        .title("Potential command injection")
6        .detail("Untrusted input reaches shell execution")
7        .tag("rce")
8        .evidence(secfinding::Evidence::http_status(500).unwrap())
9        .build()
10        .unwrap();
11
12    println!("{finding}");
13
14    let json = serde_json::to_string_pretty(&finding).unwrap();
15    println!("{json}");
16}
Source

pub fn detail(self, detail: impl Into<String>) -> Self

Set the finding detail/description.

Examples found in repository?
examples/serialize_json.rs (line 10)
7fn main() {
8    let finding = Finding::builder("my-scanner", "192.168.1.100", Severity::Critical)
9        .title("Default Credentials")
10        .detail("Admin interface uses admin:admin")
11        .tag("auth")
12        .build();
13
14    let json = serde_json::to_string_pretty(&finding).expect("Failed to serialize");
15    println!("Serialized Finding:\n{}", json);
16}
More examples
Hide additional examples
examples/basic.rs (line 6)
3fn main() {
4    let finding = Finding::builder("basic-scanner", "https://example.com", Severity::High)
5        .title("Potential command injection")
6        .detail("Untrusted input reaches shell execution")
7        .tag("rce")
8        .evidence(secfinding::Evidence::http_status(500).unwrap())
9        .build()
10        .unwrap();
11
12    println!("{finding}");
13
14    let json = serde_json::to_string_pretty(&finding).unwrap();
15    println!("{json}");
16}
Source

pub fn kind(self, kind: FindingKind) -> Self

Set the finding kind.

Source

pub fn evidence(self, ev: Evidence) -> Self

Add a piece of evidence.

Examples found in repository?
examples/basic.rs (line 8)
3fn main() {
4    let finding = Finding::builder("basic-scanner", "https://example.com", Severity::High)
5        .title("Potential command injection")
6        .detail("Untrusted input reaches shell execution")
7        .tag("rce")
8        .evidence(secfinding::Evidence::http_status(500).unwrap())
9        .build()
10        .unwrap();
11
12    println!("{finding}");
13
14    let json = serde_json::to_string_pretty(&finding).unwrap();
15    println!("{json}");
16}
Source

pub fn tag(self, tag: impl Into<String>) -> Self

Add a tag.

Examples found in repository?
examples/serialize_json.rs (line 11)
7fn main() {
8    let finding = Finding::builder("my-scanner", "192.168.1.100", Severity::Critical)
9        .title("Default Credentials")
10        .detail("Admin interface uses admin:admin")
11        .tag("auth")
12        .build();
13
14    let json = serde_json::to_string_pretty(&finding).expect("Failed to serialize");
15    println!("Serialized Finding:\n{}", json);
16}
More examples
Hide additional examples
examples/basic.rs (line 7)
3fn main() {
4    let finding = Finding::builder("basic-scanner", "https://example.com", Severity::High)
5        .title("Potential command injection")
6        .detail("Untrusted input reaches shell execution")
7        .tag("rce")
8        .evidence(secfinding::Evidence::http_status(500).unwrap())
9        .build()
10        .unwrap();
11
12    println!("{finding}");
13
14    let json = serde_json::to_string_pretty(&finding).unwrap();
15    println!("{json}");
16}
Source

pub fn cve(self, cve: impl Into<String>) -> Self

Add a CVE identifier.

Source

pub fn reference(self, url: impl Into<String>) -> Self

Add a reference URL.

Source

pub fn confidence(self, score: f64) -> Self

Set the confidence score (0.0 to 1.0).

Source

pub fn exploit_hint(self, hint: impl Into<String>) -> Self

Set a ready-to-run exploit/PoC command.

Source

pub fn matched_value(self, value: impl Into<String>) -> Self

Add a matched value (payload, string, etc.).

Source

pub fn build(self) -> Result<Finding, &'static str>

Build the finding.

Examples found in repository?
examples/serialize_json.rs (line 12)
7fn main() {
8    let finding = Finding::builder("my-scanner", "192.168.1.100", Severity::Critical)
9        .title("Default Credentials")
10        .detail("Admin interface uses admin:admin")
11        .tag("auth")
12        .build();
13
14    let json = serde_json::to_string_pretty(&finding).expect("Failed to serialize");
15    println!("Serialized Finding:\n{}", json);
16}
More examples
Hide additional examples
examples/basic.rs (line 9)
3fn main() {
4    let finding = Finding::builder("basic-scanner", "https://example.com", Severity::High)
5        .title("Potential command injection")
6        .detail("Untrusted input reaches shell execution")
7        .tag("rce")
8        .evidence(secfinding::Evidence::http_status(500).unwrap())
9        .build()
10        .unwrap();
11
12    println!("{finding}");
13
14    let json = serde_json::to_string_pretty(&finding).unwrap();
15    println!("{json}");
16}

Trait Implementations§

Source§

impl Clone for FindingBuilder

Source§

fn clone(&self) -> FindingBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for FindingBuilder

Source§

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

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

impl PartialEq for FindingBuilder

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for FindingBuilder

Auto Trait Implementations§

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