API Reference¶
permission-auditor exposes one entry point — audit — plus the
PermissionRisk, HostRisk,
AuditReport, and RiskLevel types. No traits
to implement, no features to enable.
audit¶
Score a manifest's permissions and host_permissions for risk. Looks each
token up in the curated severity table, classifies each host match-pattern for
breadth, and rolls everything into an
AuditReport with an overall
RiskLevel. Deterministic and total.
use permission_auditor::{audit, RiskLevel};
let r = audit(&["activeTab", "cookies"], &["https://*.example.com/*"]);
assert!(r.overall >= RiskLevel::Medium);
PermissionRisk¶
pub struct PermissionRisk<'a> {
pub token: &'a str,
pub severity: Severity,
pub reason: &'static str,
}
| field | meaning |
|---|---|
token |
the permission string (e.g. "cookies") |
severity |
Low / Medium / High |
reason |
one-line explanation of what the token grants |
Look up a single permission without a full audit:
HostRisk¶
pub struct HostRisk<'a> {
pub pattern: &'a str,
pub breadth: HostBreadth,
pub reason: &'static str,
}
| field | meaning |
|---|---|
pattern |
the match-pattern (e.g. "https://*/*") |
breadth |
Specific / Wildcard / AllUrls |
reason |
one-line explanation of the access scope |
Severity¶
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum Severity {
Low, // local state / one tab on user click
Medium, // browsing metadata / clipboard
High, // accounts / intercept traffic / all sites
}
Per-permission severity. Derives Ord, so the worst severity in a list is a
.max() call.
HostBreadth¶
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum HostBreadth {
Specific, // https://example.com/*
Wildcard, // https://*.example.com/*
AllUrls, // <all_urls> / *://*/*
}
How broad a host grant is. Derives Ord; AllUrls is the maximum.
RiskLevel¶
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub enum RiskLevel {
Low,
Medium,
High,
Critical,
}
The overall risk of a manifest. Critical is reserved for combinations like a
High permission and AllUrls host access (the extension can both read
accounts and run on every site).
AuditReport¶
pub struct AuditReport<'a> {
pub permissions: Vec<PermissionRisk<'a>>,
pub hosts: Vec<HostRisk<'a>>,
pub overall: RiskLevel,
}
| field | meaning |
|---|---|
permissions |
per-token verdicts for every permissions entry |
hosts |
per-pattern verdicts for every host_permissions |
overall |
rolled-up RiskLevel |