Skip to main content

RawRule

Struct RawRule 

Source
pub struct RawRule {
    pub find: Find,
    pub describe: &'static str,
    pub importance: u8,
    pub min_entropy: Option<f64>,
    pub before_assert: Option<Assertion>,
    pub after_assert: Option<Assertion>,
    pub is_and_assert: bool,
    pub check: Option<fn(&str, &str) -> bool>,
}
Expand description

原始规则定义。

包含了触发一次敏感信息扫描所需的所有静态配置(正则、描述、熵值要求、断言等)。 最终会被转换并装载进 AnyRule 的执行流中。

Fields§

§find: Find

基础匹配查找器(正则表达式或闭包)。

§describe: &'static str

规则的名称或描述。

§importance: u8

规则重要程度(0-100),用于计算最终的风险评分。

§min_entropy: Option<f64>

最低复合熵值要求,低于此值的命中将被过滤(用于过滤死板的测试数据)。

§before_assert: Option<Assertion>

向前断言 (Lookbehind):检查匹配文本之前的上下文。

§after_assert: Option<Assertion>

向后断言 (Lookahead):检查匹配文本之后的上下文。

§is_and_assert: bool

组合逻辑控制:true 表示必须同时满足前后断言 (AND),false 表示满足其一即可 (OR)。默认为 true。

§check: Option<fn(&str, &str) -> bool>

最终的自定义校验闭包,参数为 (&匹配片段, &完整文本),返回 true 表示校验通过。

Implementations§

Source§

impl RawRule

Source

pub fn check_custom(&self, state: &mut State<'_>)

执行自定义代码校验逻辑。

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.