pub struct DetectionResult {
pub attack_type: String,
pub category: AttackCategory,
pub severity: Severity,
pub matched_pattern: String,
pub offset: usize,
pub message: String,
}Expand description
一条命中:字段是只读快照,切片、告警、审计日志都从这里取,库自身不解释处置动作。
两个对调用方有实际后果的契约:
- 每个检测器对同一输入至多产出一条:同一个
attack_type不会重复出现。 有强弱两档的检测器先试强档,未中再试弱档,两档共用同一个attack_type, 只有severity不同。 - 弱信号固定报
Severity::Low,单独不足以构成拒绝理由,详见severity字段。
Fields§
§attack_type: String检测器名,与 Detector::name 逐字相等
(tests/invariants.rs 对 32 个检测器逐一核验);同时是
Scanner::scan_with 的过滤键。
category: AttackCategory四大类之一:注入 / 协议 / 数据 / 文件。
severity: Severity严重度。弱信号(weak signal)固定为 Severity::Low(5 分):
Low 不单是“轻“,更是“该形态单独出现是正常内容的常态“—— 正常网页里的
<script src=...>、源码里的单级 ../ 都落这一档,因此
单条弱信号不得构成拒绝理由(参考流水线的拒绝线是
risk.level >= RiskLevel::High,40 分)。弱信号仍然被检出、照常计入
Scanner::assess 的累加,要不要拒绝看聚合分:
多条弱信号叠加会升级(3×Low = 15 → Medium,8×Low = 40 → High)。
matched_pattern: String命中的具体片段,恰好是 &input[offset..offset + matched_pattern.len()],
调用方可直接用它给用户标红。
offset: usizematched_pattern 在输入中的字节偏移(UTF-8 字节下标,不是字符数)。
message: String人类可读说明(英文,供日志直接打印)。
Trait Implementations§
Source§impl Clone for DetectionResult
impl Clone for DetectionResult
Source§impl Debug for DetectionResult
impl Debug for DetectionResult
impl Eq for DetectionResult
Source§impl PartialEq for DetectionResult
impl PartialEq for DetectionResult
impl StructuralPartialEq for DetectionResult
Auto Trait Implementations§
impl Freeze for DetectionResult
impl RefUnwindSafe for DetectionResult
impl Send for DetectionResult
impl Sync for DetectionResult
impl Unpin for DetectionResult
impl UnsafeUnpin for DetectionResult
impl UnwindSafe for DetectionResult
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
Mutably borrows from an owned value. Read more