pub struct Shield {
pub config: ShieldConfig,
pub audit: Arc<AuditChain>,
pub rate_governor: Arc<RateGovernor>,
pub fingerprinter: Arc<Fingerprinter>,
pub email_limiter: Arc<EmailRateLimiter>,
pub endpoint: Option<Arc<EndpointEngine>>,
}Expand description
Core security engine that orchestrates all NexusShield components.
Fields§
§config: ShieldConfig§audit: Arc<AuditChain>§rate_governor: Arc<RateGovernor>§fingerprinter: Arc<Fingerprinter>§email_limiter: Arc<EmailRateLimiter>§endpoint: Option<Arc<EndpointEngine>>Implementations§
Source§impl Shield
impl Shield
pub fn new(config: ShieldConfig) -> Self
Sourcepub fn validate_sql(&self, sql: &str) -> Result<(), ShieldError>
pub fn validate_sql(&self, sql: &str) -> Result<(), ShieldError>
Validate a SQL query through the AST-based firewall.
Sourcepub fn validate_url(&self, url: &str) -> Result<(), ShieldError>
pub fn validate_url(&self, url: &str) -> Result<(), ShieldError>
Validate a URL through the SSRF guard.
Sourcepub fn validate_ip(&self, ip: &str) -> Result<(), ShieldError>
pub fn validate_ip(&self, ip: &str) -> Result<(), ShieldError>
Validate an IP address through the SSRF guard.
Sourcepub fn validate_connection_string(
&self,
conn_str: &str,
) -> Result<String, ShieldError>
pub fn validate_connection_string( &self, conn_str: &str, ) -> Result<String, ShieldError>
Validate and sanitize a database connection string.
Sourcepub fn validate_file_path(&self, path: &str) -> Result<(), ShieldError>
pub fn validate_file_path(&self, path: &str) -> Result<(), ShieldError>
Validate a file path (SQLite database path).
Sourcepub fn quarantine_csv(&self, content: &str) -> Result<(), ShieldError>
pub fn quarantine_csv(&self, content: &str) -> Result<(), ShieldError>
Run imported CSV data through quarantine validation.
Sourcepub fn quarantine_json(&self, json: &str) -> Result<(), ShieldError>
pub fn quarantine_json(&self, json: &str) -> Result<(), ShieldError>
Validate a JSON response from an external source.
Sourcepub fn validate_email_address(&self, addr: &str) -> Result<(), ShieldError>
pub fn validate_email_address(&self, addr: &str) -> Result<(), ShieldError>
Validate an email address for format, domain safety, and injection.
Sourcepub fn validate_email_header(
&self,
field_name: &str,
value: &str,
) -> Result<(), ShieldError>
pub fn validate_email_header( &self, field_name: &str, value: &str, ) -> Result<(), ShieldError>
Validate a header field (subject, name, ticket_id) for injection.
Sourcepub fn validate_email_content(
&self,
field_name: &str,
value: &str,
) -> Result<(), ShieldError>
pub fn validate_email_content( &self, field_name: &str, value: &str, ) -> Result<(), ShieldError>
Validate content that will be interpolated into an HTML email template.
Sourcepub fn check_email_rate(&self, recipient: &str) -> Result<(), ShieldError>
pub fn check_email_rate(&self, recipient: &str) -> Result<(), ShieldError>
Check per-recipient email rate limit (anti-bombing).
Sourcepub fn validate_outbound_email(
&self,
to: &[&str],
subject: &str,
body_fields: &[(&str, &str)],
) -> Result<(), ShieldError>
pub fn validate_outbound_email( &self, to: &[&str], subject: &str, body_fields: &[(&str, &str)], ) -> Result<(), ShieldError>
Full outbound email validation: addresses, headers, content, and rate limits.
Sourcepub fn escape_email_content(value: &str) -> String
pub fn escape_email_content(value: &str) -> String
HTML-escape user content for safe template interpolation.