Skip to main content

Detector

Struct Detector 

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

The ambient authority detector.

Holds the built-in authority registry plus any user-defined custom authorities from .capsec.toml. Create one with Detector::new, optionally extend it with add_custom_authorities, then call analyse on each parsed file.

§Example

use cargo_capsec::parser::parse_source;
use cargo_capsec::detector::Detector;

let source = r#"
    use std::fs;
    fn load() { let _ = fs::read("data.bin"); }
"#;

let parsed = parse_source(source, "example.rs").unwrap();
let detector = Detector::new();
let findings = detector.analyse(&parsed, "my-crate", "0.1.0");
assert_eq!(findings.len(), 1);

Implementations§

Source§

impl Detector

Source

pub fn new() -> Self

Creates a new detector with the built-in authority registry.

Source

pub fn add_custom_authorities(&mut self, customs: &[CustomAuthority])

Extends the detector with custom authority patterns from .capsec.toml.

Source

pub fn analyse( &self, file: &ParsedFile, crate_name: &str, crate_version: &str, ) -> Vec<Finding>

Analyses a parsed file and returns all ambient authority findings.

Expands call paths using the file’s use imports, matches against the authority registry (built-in + custom), and deduplicates by call site.

Trait Implementations§

Source§

impl Default for Detector

Source§

fn default() -> Self

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

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