Skip to main content

ApiHandler

Struct ApiHandler 

Source
pub struct ApiHandler { /* private fields */ }
Expand description

API endpoint handlers.

Implementations§

Source§

impl ApiHandler

Source

pub fn builder() -> ApiHandlerBuilder

Creates a new API handler builder.

Source

pub fn access_lists(&self) -> Arc<RwLock<AccessListManager>>

Source

pub fn dlp_scanner(&self) -> Option<Arc<DlpScanner>>

Returns the DLP scanner (if configured).

Source

pub fn signal_dispatcher(&self) -> Arc<SignalDispatcher>

Signal dispatcher facade (labs-pdb2)

Source

pub async fn report_signal(&self, signal: ThreatSignal) -> Result<(), String>

Report a threat signal to Signal Horizon (Phase 6).

Source

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.

Source

pub async fn sync_horizon_blocklist(&self) -> Result<(), String>

Force a blocklist sync with Signal Horizon.

Source

pub async fn dispatch_horizon_signal( &self, signal: ThreatSignal, ) -> Result<(), String>

Dispatch a signal to Signal Horizon without exposing the client.

Source

pub fn handle_health(&self) -> ApiResponse<HealthResponse>

Handles GET /health request.

Source

pub fn handle_metrics(&self) -> String

Handles GET /metrics request. Returns Prometheus exposition format.

Source

pub fn handle_reload(&self) -> ApiResponse<ReloadResultResponse>

Handles POST /reload request.

Source

pub fn handle_list_sites(&self) -> ApiResponse<SiteListResponse>

Handles GET /sites request.

Source

pub fn handle_stats(&self) -> ApiResponse<StatsResponse>

Handles GET /stats request.

Source

pub fn handle_waf_stats(&self) -> ApiResponse<WafStatsResponse>

Handles GET /waf/stats request.

Source

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.

Source

pub fn handle_reset_profiles(&self)

Handles POST /api/profiles/reset request. Clears all learned endpoint behavioral baselines.

Source

pub fn handle_reset_schemas(&self)

Handles POST /api/schemas/reset request. Clears all learned API schemas from the schema learner.

Source

pub fn handle_create_site( &self, request: CreateSiteRequest, ) -> ApiResponse<MutationResult>

Handles POST /sites request - creates a new site.

Source

pub fn handle_get_site(&self, hostname: &str) -> ApiResponse<SiteDetailResponse>

Handles GET /sites/:hostname request - gets site details.

Source

pub fn handle_update_site( &self, hostname: &str, request: UpdateSiteRequest, ) -> ApiResponse<MutationResult>

Handles PUT /sites/:hostname request - updates site configuration.

Source

pub fn handle_delete_site(&self, hostname: &str) -> ApiResponse<MutationResult>

Handles DELETE /sites/:hostname request - deletes a site.

Source

pub fn handle_update_site_waf( &self, hostname: &str, request: SiteWafRequest, ) -> ApiResponse<MutationResult>

Handles PUT /sites/:hostname/waf request - updates WAF configuration.

Source

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.

Source

pub fn handle_update_site_access_list( &self, hostname: &str, request: AccessListRequest, ) -> ApiResponse<MutationResult>

Handles PUT /sites/:hostname/access-list request - updates access list.

Source

pub fn handle_get_config(&self) -> ApiResponse<ConfigFile>

Handles GET /config request - retrieves full configuration.

Source

pub fn handle_update_config( &self, config: ConfigFile, ) -> ApiResponse<MutationResult>

Handles POST /config request - updates full configuration.

Source

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.

Source

pub fn metrics(&self) -> Arc<MetricsRegistry>

Returns the metrics registry for recording.

Source

pub fn health(&self) -> Arc<HealthChecker>

Returns the health checker.

Source

pub fn entity_manager(&self) -> Option<Arc<EntityManager>>

Returns the entity manager (if configured).

Source

pub fn block_log(&self) -> Option<Arc<BlockLog>>

Returns the block log (if configured).

Source

pub fn config_manager(&self) -> Option<&Arc<ConfigManager>>

Returns the config manager (if configured).

Source

pub fn campaign_manager(&self) -> Option<&Arc<CampaignManager>>

Returns the campaign manager (if configured).

Source

pub fn actor_manager(&self) -> Option<Arc<ActorManager>>

Returns the actor manager (if configured).

Source

pub fn session_manager(&self) -> Option<Arc<SessionManager>>

Returns the session manager (if configured).

Source

pub fn signal_manager(&self) -> Option<Arc<SignalManager>>

Returns the signal manager (if configured).

Source

pub fn synapse_engine(&self) -> Option<Arc<RwLock<Synapse>>>

Returns the synapse engine (if configured).

Source

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.

Source

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.

Source

pub fn handle_list_actors(&self, limit: usize) -> Vec<ActorState>

Handles GET /_sensor/actors request - returns actors (most recently seen first).

Source

pub fn handle_actor_stats(&self) -> Option<ActorStatsSnapshot>

Handles GET /_sensor/actors/stats request - returns actor statistics.

Source

pub fn handle_list_sessions(&self, limit: usize) -> Vec<SessionState>

Handles GET /_sensor/sessions request - returns active sessions.

Source

pub fn handle_session_stats(&self) -> Option<SessionStatsSnapshot>

Handles GET /_sensor/sessions/stats request - returns session statistics.

Source

pub fn handle_list_entities(&self, limit: usize) -> Vec<EntitySnapshot>

Handles GET /_sensor/entities request - returns top entities by risk.

Source

pub fn handle_list_blocks(&self, limit: usize) -> Vec<BlockEvent>

Handles GET /_sensor/blocks request - returns recent block events.

Source

pub fn handle_payload_stats(&self) -> ApiResponse<PayloadSummaryResponse>

Handles GET /_sensor/payload/stats - returns payload profiling summary.

Source

pub fn handle_payload_endpoints( &self, limit: usize, ) -> ApiResponse<Vec<EndpointPayloadSummary>>

Handles GET /_sensor/payload/endpoints - returns top endpoints by traffic.

Source

pub fn handle_payload_anomalies( &self, limit: usize, ) -> ApiResponse<Vec<PayloadAnomalyResponse>>

Handles GET /_sensor/payload/anomalies - returns recent payload anomalies.

Handles GET /_sensor/trends/summary - returns trends summary.

Handles GET /_sensor/trends/anomalies - returns detected anomalies.

Source

pub fn handle_signals( &self, options: SignalQueryOptions, ) -> ApiResponse<SignalListResponse>

Handles GET /_sensor/signals - returns recent intelligence signals.

Source

pub fn handle_crawler_stats(&self) -> ApiResponse<CrawlerStatsResponse>

Handles GET /_sensor/crawler/stats - returns crawler detection stats.

Source

pub fn handle_horizon_stats(&self) -> ApiResponse<HorizonStatsResponse>

Handles GET /_sensor/horizon/stats - returns Signal Horizon connection stats.

Source

pub fn handle_horizon_blocklist( &self, limit: usize, ) -> ApiResponse<Vec<BlocklistEntryResponse>>

Handles GET /_sensor/horizon/blocklist - returns blocklist entries.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &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
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,