permission_auditor/lib.rs
1//! # permission-auditor
2//!
3//! Audit a list of Chrome / **Manifest V3** extension permissions against a
4//! curated risk database and produce a per-extension [`AuditReport`]:
5//!
6//! - a **risk level** (`Low` / `Medium` / `High` / `Critical`) for each
7//! permission, plus a short plain-English description of what it grants,
8//! - recognition for **host-access patterns** (`<all_urls>`, scheme
9//! wildcards, scoped match-patterns) and broad-vs-scoped classification,
10//! - an **overall verdict** for the whole extension, with the count of each
11//! severity and the single highest permission driving it.
12//!
13//! This is a more comprehensive companion to
14//! [`ext-permission-risk`](https://crates.io/crates/ext-permission-risk):
15//! it covers the full MV3 permission surface, adds a `Critical` tier for the
16//! truly dangerous combinations (arbitrary host access + code injection),
17//! and returns a structured report rather than a single lookup.
18//!
19//! Pure Rust, **zero dependencies**, `#![forbid(unsafe_code)]`, fully tested.
20//!
21//! This is the audit engine behind the
22//! [**zovo.one**](https://zovo.one/) Chrome-extension privacy & security
23//! scanner.
24//!
25//! ## Quick example
26//!
27//! ```
28//! use permission_auditor::{audit, RiskLevel};
29//!
30//! let report = audit(&[
31//! "activeTab",
32//! "storage",
33//! "tabs",
34//! "<all_urls>",
35//! "scripting",
36//! "cookies",
37//! ]);
38//!
39//! // activeTab and storage are Low; tabs is Medium; <all_urls> is Critical;
40//! // scripting + cookies are High. The broad-host + code combo escalates to
41//! // Critical — this is the canonical surveillance capability set.
42//! assert_eq!(report.overall, RiskLevel::Critical);
43//! assert!(report.critical_count >= 1);
44//! assert!(report.high_count >= 2);
45//! assert_eq!(report.findings.len(), 6);
46//! assert!(report.findings.iter().any(|f| f.token == "<all_urls>"));
47//! ```
48
49#![forbid(unsafe_code)]
50
51mod db;
52mod host;
53mod report;
54
55pub use db::{PermissionEntry, RiskLevel, RISK_DATABASE, find_permission};
56pub use host::{HostScope, classify_host_pattern, is_host_access_pattern};
57pub use report::{Finding, FindingKind, AuditReport, audit, audit_with_manifest_version};