pub struct ApiHandler { /* private fields */ }Expand description
API endpoint handlers.
Implementations§
Source§impl ApiHandler
impl ApiHandler
Sourcepub fn builder() -> ApiHandlerBuilder
pub fn builder() -> ApiHandlerBuilder
Creates a new API handler builder.
pub fn access_lists(&self) -> Arc<RwLock<AccessListManager>>
Sourcepub fn dlp_scanner(&self) -> Option<Arc<DlpScanner>>
pub fn dlp_scanner(&self) -> Option<Arc<DlpScanner>>
Returns the DLP scanner (if configured).
Sourcepub fn signal_dispatcher(&self) -> Arc<SignalDispatcher>
pub fn signal_dispatcher(&self) -> Arc<SignalDispatcher>
Signal dispatcher facade (labs-pdb2)
Sourcepub async fn report_signal(&self, signal: ThreatSignal) -> Result<(), String>
pub async fn report_signal(&self, signal: ThreatSignal) -> Result<(), String>
Report a threat signal to Signal Horizon (Phase 6).
Sourcepub fn is_horizon_blocked(
&self,
ip: Option<&str>,
fingerprint: Option<&str>,
) -> bool
pub fn is_horizon_blocked( &self, ip: Option<&str>, fingerprint: Option<&str>, ) -> bool
Check if an IP or fingerprint is blocked by Signal Horizon blocklist.
Sourcepub async fn sync_horizon_blocklist(&self) -> Result<(), String>
pub async fn sync_horizon_blocklist(&self) -> Result<(), String>
Force a blocklist sync with Signal Horizon.
Sourcepub async fn dispatch_horizon_signal(
&self,
signal: ThreatSignal,
) -> Result<(), String>
pub async fn dispatch_horizon_signal( &self, signal: ThreatSignal, ) -> Result<(), String>
Dispatch a signal to Signal Horizon without exposing the client.
Sourcepub fn handle_health(&self) -> ApiResponse<HealthResponse>
pub fn handle_health(&self) -> ApiResponse<HealthResponse>
Handles GET /health request.
Sourcepub fn handle_metrics(&self) -> String
pub fn handle_metrics(&self) -> String
Handles GET /metrics request. Returns Prometheus exposition format.
Sourcepub fn handle_reload(&self) -> ApiResponse<ReloadResultResponse>
pub fn handle_reload(&self) -> ApiResponse<ReloadResultResponse>
Handles POST /reload request.
Sourcepub fn handle_list_sites(&self) -> ApiResponse<SiteListResponse>
pub fn handle_list_sites(&self) -> ApiResponse<SiteListResponse>
Handles GET /sites request.
Sourcepub fn handle_stats(&self) -> ApiResponse<StatsResponse>
pub fn handle_stats(&self) -> ApiResponse<StatsResponse>
Handles GET /stats request.
Sourcepub fn handle_waf_stats(&self) -> ApiResponse<WafStatsResponse>
pub fn handle_waf_stats(&self) -> ApiResponse<WafStatsResponse>
Handles GET /waf/stats request.
Sourcepub fn handle_get_profiles(&self) -> ApiResponse<Vec<EndpointProfile>>
pub fn handle_get_profiles(&self) -> ApiResponse<Vec<EndpointProfile>>
Handles GET /debug/profiles request. Note: This requires the profiles_getter callback to be set; returns empty vec if not available. In the full binary context, profiles are retrieved via DetectionEngine which uses thread-local storage.
Sourcepub fn handle_reset_profiles(&self)
pub fn handle_reset_profiles(&self)
Handles POST /api/profiles/reset request. Clears all learned endpoint behavioral baselines.
Sourcepub fn handle_reset_schemas(&self)
pub fn handle_reset_schemas(&self)
Handles POST /api/schemas/reset request. Clears all learned API schemas from the schema learner.
Sourcepub fn handle_create_site(
&self,
request: CreateSiteRequest,
) -> ApiResponse<MutationResult>
pub fn handle_create_site( &self, request: CreateSiteRequest, ) -> ApiResponse<MutationResult>
Handles POST /sites request - creates a new site.
Sourcepub fn handle_get_site(&self, hostname: &str) -> ApiResponse<SiteDetailResponse>
pub fn handle_get_site(&self, hostname: &str) -> ApiResponse<SiteDetailResponse>
Handles GET /sites/:hostname request - gets site details.
Sourcepub fn handle_update_site(
&self,
hostname: &str,
request: UpdateSiteRequest,
) -> ApiResponse<MutationResult>
pub fn handle_update_site( &self, hostname: &str, request: UpdateSiteRequest, ) -> ApiResponse<MutationResult>
Handles PUT /sites/:hostname request - updates site configuration.
Sourcepub fn handle_delete_site(&self, hostname: &str) -> ApiResponse<MutationResult>
pub fn handle_delete_site(&self, hostname: &str) -> ApiResponse<MutationResult>
Handles DELETE /sites/:hostname request - deletes a site.
Sourcepub fn handle_update_site_waf(
&self,
hostname: &str,
request: SiteWafRequest,
) -> ApiResponse<MutationResult>
pub fn handle_update_site_waf( &self, hostname: &str, request: SiteWafRequest, ) -> ApiResponse<MutationResult>
Handles PUT /sites/:hostname/waf request - updates WAF configuration.
Sourcepub fn handle_update_site_rate_limit(
&self,
hostname: &str,
request: RateLimitRequest,
) -> ApiResponse<MutationResult>
pub fn handle_update_site_rate_limit( &self, hostname: &str, request: RateLimitRequest, ) -> ApiResponse<MutationResult>
Handles PUT /sites/:hostname/rate-limit request - updates rate limit configuration.
Sourcepub fn handle_update_site_access_list(
&self,
hostname: &str,
request: AccessListRequest,
) -> ApiResponse<MutationResult>
pub fn handle_update_site_access_list( &self, hostname: &str, request: AccessListRequest, ) -> ApiResponse<MutationResult>
Handles PUT /sites/:hostname/access-list request - updates access list.
Sourcepub fn handle_get_config(&self) -> ApiResponse<ConfigFile>
pub fn handle_get_config(&self) -> ApiResponse<ConfigFile>
Handles GET /config request - retrieves full configuration.
Sourcepub fn handle_update_config(
&self,
config: ConfigFile,
) -> ApiResponse<MutationResult>
pub fn handle_update_config( &self, config: ConfigFile, ) -> ApiResponse<MutationResult>
Handles POST /config request - updates full configuration.
Sourcepub fn validate_auth(&self, token: Option<&str>) -> bool
pub fn validate_auth(&self, token: Option<&str>) -> bool
Validates the API authentication token using constant-time comparison.
Uses subtle::ConstantTimeEq to prevent timing attacks that could
allow attackers to guess valid tokens character-by-character.
Sourcepub fn metrics(&self) -> Arc<MetricsRegistry>
pub fn metrics(&self) -> Arc<MetricsRegistry>
Returns the metrics registry for recording.
Sourcepub fn health(&self) -> Arc<HealthChecker>
pub fn health(&self) -> Arc<HealthChecker>
Returns the health checker.
Sourcepub fn entity_manager(&self) -> Option<Arc<EntityManager>>
pub fn entity_manager(&self) -> Option<Arc<EntityManager>>
Returns the entity manager (if configured).
Sourcepub fn config_manager(&self) -> Option<&Arc<ConfigManager>>
pub fn config_manager(&self) -> Option<&Arc<ConfigManager>>
Returns the config manager (if configured).
Sourcepub fn campaign_manager(&self) -> Option<&Arc<CampaignManager>>
pub fn campaign_manager(&self) -> Option<&Arc<CampaignManager>>
Returns the campaign manager (if configured).
Sourcepub fn actor_manager(&self) -> Option<Arc<ActorManager>>
pub fn actor_manager(&self) -> Option<Arc<ActorManager>>
Returns the actor manager (if configured).
Sourcepub fn session_manager(&self) -> Option<Arc<SessionManager>>
pub fn session_manager(&self) -> Option<Arc<SessionManager>>
Returns the session manager (if configured).
Sourcepub fn signal_manager(&self) -> Option<Arc<SignalManager>>
pub fn signal_manager(&self) -> Option<Arc<SignalManager>>
Returns the signal manager (if configured).
Sourcepub fn synapse_engine(&self) -> Option<Arc<RwLock<Synapse>>>
pub fn synapse_engine(&self) -> Option<Arc<RwLock<Synapse>>>
Returns the synapse engine (if configured).
Sourcepub fn evaluate_request(
&self,
method: &str,
uri: &str,
headers: &[(String, String)],
body: Option<&[u8]>,
client_ip: &str,
) -> Option<EvaluateResult>
pub fn evaluate_request( &self, method: &str, uri: &str, headers: &[(String, String)], body: Option<&[u8]>, client_ip: &str, ) -> Option<EvaluateResult>
Evaluates a request against the WAF rules (dry-run mode). Returns the detection result without actually blocking.
Sourcepub fn evaluate_request_trace(
&self,
method: &str,
uri: &str,
headers: &[(String, String)],
body: Option<&[u8]>,
client_ip: &str,
trace: &mut dyn TraceSink,
) -> Option<EvaluateResult>
pub fn evaluate_request_trace( &self, method: &str, uri: &str, headers: &[(String, String)], body: Option<&[u8]>, client_ip: &str, trace: &mut dyn TraceSink, ) -> Option<EvaluateResult>
Evaluates a request against the WAF rules and streams trace events.
Sourcepub fn handle_list_actors(&self, limit: usize) -> Vec<ActorState>
pub fn handle_list_actors(&self, limit: usize) -> Vec<ActorState>
Handles GET /_sensor/actors request - returns actors (most recently seen first).
Sourcepub fn handle_actor_stats(&self) -> Option<ActorStatsSnapshot>
pub fn handle_actor_stats(&self) -> Option<ActorStatsSnapshot>
Handles GET /_sensor/actors/stats request - returns actor statistics.
Sourcepub fn handle_list_sessions(&self, limit: usize) -> Vec<SessionState>
pub fn handle_list_sessions(&self, limit: usize) -> Vec<SessionState>
Handles GET /_sensor/sessions request - returns active sessions.
Sourcepub fn handle_session_stats(&self) -> Option<SessionStatsSnapshot>
pub fn handle_session_stats(&self) -> Option<SessionStatsSnapshot>
Handles GET /_sensor/sessions/stats request - returns session statistics.
Sourcepub fn handle_list_entities(&self, limit: usize) -> Vec<EntitySnapshot>
pub fn handle_list_entities(&self, limit: usize) -> Vec<EntitySnapshot>
Handles GET /_sensor/entities request - returns top entities by risk.
Sourcepub fn handle_list_blocks(&self, limit: usize) -> Vec<BlockEvent>
pub fn handle_list_blocks(&self, limit: usize) -> Vec<BlockEvent>
Handles GET /_sensor/blocks request - returns recent block events.
Sourcepub fn handle_payload_stats(&self) -> ApiResponse<PayloadSummaryResponse>
pub fn handle_payload_stats(&self) -> ApiResponse<PayloadSummaryResponse>
Handles GET /_sensor/payload/stats - returns payload profiling summary.
Sourcepub fn handle_payload_endpoints(
&self,
limit: usize,
) -> ApiResponse<Vec<EndpointPayloadSummary>>
pub fn handle_payload_endpoints( &self, limit: usize, ) -> ApiResponse<Vec<EndpointPayloadSummary>>
Handles GET /_sensor/payload/endpoints - returns top endpoints by traffic.
Sourcepub fn handle_payload_anomalies(
&self,
limit: usize,
) -> ApiResponse<Vec<PayloadAnomalyResponse>>
pub fn handle_payload_anomalies( &self, limit: usize, ) -> ApiResponse<Vec<PayloadAnomalyResponse>>
Handles GET /_sensor/payload/anomalies - returns recent payload anomalies.
Sourcepub fn handle_trends_summary(&self) -> ApiResponse<TrendsSummaryResponse>
pub fn handle_trends_summary(&self) -> ApiResponse<TrendsSummaryResponse>
Handles GET /_sensor/trends/summary - returns trends summary.
Sourcepub fn handle_trends_anomalies(
&self,
limit: usize,
) -> ApiResponse<Vec<TrendsAnomalyResponse>>
pub fn handle_trends_anomalies( &self, limit: usize, ) -> ApiResponse<Vec<TrendsAnomalyResponse>>
Handles GET /_sensor/trends/anomalies - returns detected anomalies.
Sourcepub fn handle_signals(
&self,
options: SignalQueryOptions,
) -> ApiResponse<SignalListResponse>
pub fn handle_signals( &self, options: SignalQueryOptions, ) -> ApiResponse<SignalListResponse>
Handles GET /_sensor/signals - returns recent intelligence signals.
Sourcepub fn handle_crawler_stats(&self) -> ApiResponse<CrawlerStatsResponse>
pub fn handle_crawler_stats(&self) -> ApiResponse<CrawlerStatsResponse>
Handles GET /_sensor/crawler/stats - returns crawler detection stats.
Sourcepub fn handle_horizon_stats(&self) -> ApiResponse<HorizonStatsResponse>
pub fn handle_horizon_stats(&self) -> ApiResponse<HorizonStatsResponse>
Handles GET /_sensor/horizon/stats - returns Signal Horizon connection stats.
Sourcepub fn handle_horizon_blocklist(
&self,
limit: usize,
) -> ApiResponse<Vec<BlocklistEntryResponse>>
pub fn handle_horizon_blocklist( &self, limit: usize, ) -> ApiResponse<Vec<BlocklistEntryResponse>>
Handles GET /_sensor/horizon/blocklist - returns blocklist entries.
Auto Trait Implementations§
impl Freeze for ApiHandler
impl !RefUnwindSafe for ApiHandler
impl Send for ApiHandler
impl Sync for ApiHandler
impl Unpin for ApiHandler
impl UnsafeUnpin for ApiHandler
impl !UnwindSafe for ApiHandler
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more