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
impl Detector
Extends the detector with custom authority patterns from .capsec.toml.
Sourcepub fn analyse(
&self,
file: &ParsedFile,
crate_name: &str,
crate_version: &str,
) -> Vec<Finding>
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§
Auto Trait Implementations§
impl Freeze for Detector
impl RefUnwindSafe for Detector
impl Send for Detector
impl Sync for Detector
impl Unpin for Detector
impl UnsafeUnpin for Detector
impl UnwindSafe for Detector
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more