Skip to main content

PostgresBackend

Struct PostgresBackend 

Source
pub struct PostgresBackend {
    pub config: &'static TextQueryConfig,
    pub table: String,
    pub timestamp_field: String,
    pub json_field: Option<String>,
    pub case_sensitive_re: bool,
    pub schema: Option<String>,
    pub database: Option<String>,
    pub timescaledb: bool,
}
Expand description

PostgreSQL/TimescaleDB backend for Sigma rule conversion.

Fields§

§config: &'static TextQueryConfig§table: String

Default table name (overridden by pipeline state table key).

§timestamp_field: String

Timestamp column name for time-windowed queries.

§json_field: Option<String>

If set, fields are accessed via JSONB extraction (metadata->>'fieldName').

§case_sensitive_re: bool

Use case-sensitive regex (~) instead of case-insensitive (~*).

§schema: Option<String>

PostgreSQL schema name (e.g. public).

§database: Option<String>

PostgreSQL database name (connection-level metadata, not used in queries).

§timescaledb: bool

Enable TimescaleDB-specific features.

Implementations§

Source§

impl PostgresBackend

Source

pub fn new() -> Self

Source

pub fn from_options(options: &HashMap<String, String>) -> Self

Create a backend from CLI-style key=value option pairs.

Recognized keys: table, schema, database, timestamp_field, json_field, case_sensitive_re (true/false). Unknown keys are silently ignored so forward-compatible options can be added without breaking existing invocations.

Trait Implementations§

Source§

impl Backend for PostgresBackend

Source§

fn name(&self) -> &str

Source§

fn formats(&self) -> &[(&str, &str)]

Source§

fn requires_pipeline(&self) -> bool

Source§

fn convert_rule( &self, rule: &SigmaRule, output_format: &str, pipeline_state: &PipelineState, ) -> Result<Vec<String>>

Source§

fn convert_condition( &self, expr: &ConditionExpr, detections: &HashMap<String, Detection>, state: &mut ConversionState, ) -> Result<String>

Source§

fn convert_condition_and(&self, exprs: &[String]) -> Result<String>

Source§

fn convert_condition_or(&self, exprs: &[String]) -> Result<String>

Source§

fn convert_condition_not(&self, expr: &str) -> Result<String>

Source§

fn convert_detection( &self, det: &Detection, state: &mut ConversionState, ) -> Result<String>

Source§

fn convert_detection_item( &self, item: &DetectionItem, state: &mut ConversionState, ) -> Result<String>

Source§

fn escape_and_quote_field(&self, field: &str) -> String

Source§

fn convert_value_str( &self, value: &SigmaString, _state: &ConversionState, ) -> String

Source§

fn convert_value_re(&self, regex: &str, _state: &ConversionState) -> String

Source§

fn convert_field_eq_str( &self, field: &str, value: &SigmaString, modifiers: &[Modifier], _state: &mut ConversionState, ) -> Result<ConvertResult>

Source§

fn convert_field_eq_str_case_sensitive( &self, field: &str, value: &SigmaString, modifiers: &[Modifier], state: &mut ConversionState, ) -> Result<ConvertResult>

Source§

fn convert_field_eq_num( &self, field: &str, value: f64, _state: &mut ConversionState, ) -> Result<String>

Source§

fn convert_field_eq_bool( &self, field: &str, value: bool, _state: &mut ConversionState, ) -> Result<String>

Source§

fn convert_field_eq_null( &self, field: &str, _state: &mut ConversionState, ) -> Result<String>

Source§

fn convert_field_eq_re( &self, field: &str, pattern: &str, flags: &[Modifier], _state: &mut ConversionState, ) -> Result<ConvertResult>

Source§

fn convert_field_eq_cidr( &self, field: &str, cidr: &str, _state: &mut ConversionState, ) -> Result<ConvertResult>

Source§

fn convert_field_compare( &self, field: &str, op: &Modifier, value: f64, _state: &mut ConversionState, ) -> Result<String>

Source§

fn convert_field_exists( &self, field: &str, exists: bool, _state: &mut ConversionState, ) -> Result<String>

Source§

fn convert_field_eq_query_expr( &self, field: &str, expr: &str, _id: &str, _state: &mut ConversionState, ) -> Result<String>

Source§

fn convert_field_ref( &self, field1: &str, field2: &str, _state: &mut ConversionState, ) -> Result<ConvertResult>

Source§

fn convert_keyword( &self, value: &SigmaValue, _state: &mut ConversionState, ) -> Result<String>

Source§

fn convert_condition_as_in_expression( &self, field: &str, values: &[&SigmaValue], is_or: bool, _state: &mut ConversionState, ) -> Result<String>

Source§

fn finish_query( &self, rule: &SigmaRule, query: String, state: &ConversionState, ) -> Result<String>

Source§

fn finalize_query( &self, rule: &SigmaRule, query: String, _index: usize, _state: &ConversionState, output_format: &str, ) -> Result<String>

Source§

fn finalize_output( &self, queries: Vec<String>, output_format: &str, ) -> Result<String>

Source§

fn supports_correlation(&self) -> bool

Source§

fn convert_correlation_rule( &self, rule: &CorrelationRule, output_format: &str, pipeline_state: &PipelineState, ) -> Result<Vec<String>>

Source§

fn default_format(&self) -> &str

Source§

impl Default for PostgresBackend

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.