Skip to main content

HttpEnricher

Struct HttpEnricher 

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

One HTTP enricher instance.

Constructed by the daemon config loader. The Arc<reqwest::Client> is shared across all HTTP enrichers in the same daemon process so connection pooling works at the process level rather than per-config-block.

Implementations§

Source§

impl HttpEnricher

Source

pub fn new( id: String, kind: EnricherKind, inject_field: String, method: String, url: String, headers: Vec<(String, String)>, body: Option<String>, timeout: Duration, on_error: OnError, scope: Scope, extract: Option<ExtractExpr>, client: HttpEnricherClient, cache: HttpResponseCache, ) -> Self

Build a new enricher.

client is shared at the process level. cache may be a disabled cache (HttpResponseCache::new(Duration::from_secs(0))) when cache_ttl is unset; the lookup path treats that as “always miss”.

Source

pub fn with_max_response_bytes(self, max_bytes: usize) -> Self

Override the maximum response-body size this enricher will read.

The default is DEFAULT_ENRICHER_MAX_RESPONSE_BYTES. Setting a smaller value can help when consuming many small enrichment payloads concurrently and tightening the per-call memory bound is worth the rejection risk on the occasional larger response.

Source

pub fn with_metrics(self, metrics: Arc<dyn MetricsHook>) -> Self

Replace the metrics hook this enricher reports cache events into.

Pre-registers the three HTTP-cache counter label sets for this enricher’s id so rsigma_enrichment_http_cache_{hits,misses, expirations}_total{...} are emitted on /metrics from the first scrape, even before the enricher has run.

Source

pub fn cache(&self) -> &HttpResponseCache

Read-only view of the response cache. Used by the metrics layer to expose cache hit/miss/expiration counters.

Trait Implementations§

Source§

impl Enricher for HttpEnricher

Source§

fn kind(&self) -> EnricherKind

The kind of result this enricher applies to. Fixed at config load.
Source§

fn id(&self) -> &str

Stable identifier for this enricher instance. Used as a metric label and in structured log fields. Conventionally something like asset_lookup_det or enrich_hash_virustotal.
Source§

fn inject_field(&self) -> &str

Field name under RuleHeader::enrichments that this enricher writes to.
Source§

fn timeout(&self) -> Duration

Per-enricher timeout. The pipeline wraps each enrich() call in tokio::time::timeout using this value. Defaults to 5 seconds.
Source§

fn scope(&self) -> &Scope

Optional scope filter. Applied after the kind-vs-body filter and before enrich() runs. Default is Scope::default (always fires).
Source§

fn on_error(&self) -> OnError

Behavior when this enricher fails (timeout, fetch error, …). Defaults to OnError::Skip.
Source§

fn enrich<'life0, 'life1, 'async_trait>( &'life0 self, result: &'life1 mut EvaluationResult, ) -> Pin<Box<dyn Future<Output = Result<(), EnrichError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Run the enrichment. Read more

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> AnyExt for T
where T: Any + ?Sized,

Source§

fn downcast_ref<T>(this: &Self) -> Option<&T>
where T: Any,

Attempts to downcast this to T behind reference
Source§

fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>
where T: Any,

Attempts to downcast this to T behind mutable reference
Source§

fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>
where T: Any,

Attempts to downcast this to T behind Rc pointer
Source§

fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>
where T: Any,

Attempts to downcast this to T behind Arc pointer
Source§

fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>
where T: Any,

Attempts to downcast this to T behind Box pointer
Source§

fn downcast_move<T>(this: Self) -> Option<T>
where T: Any, Self: Sized,

Attempts to downcast owned Self to T, useful only in generic context as a workaround for specialization
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, X> CoerceTo<T> for X
where T: CoerceFrom<X> + ?Sized,

Source§

fn coerce_rc_to(self: Rc<X>) -> Rc<T>

Source§

fn coerce_box_to(self: Box<X>) -> Box<T>

Source§

fn coerce_ref_to(&self) -> &T

Source§

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

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<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