Skip to main content

Rule

Struct Rule 

Source
pub struct Rule {
Show 14 fields pub id: String, pub category: ThreatCategory, pub severity: Severity, pub confidence: f32, pub condition: RuleCondition, pub action: RecommendedAction, pub reason: String, pub shield: Option<ShieldHint>, pub enabled: bool, pub tags: Vec<String>, pub promptintel_threats: Vec<String>, pub requires_code_artifact: bool, pub downgrade_when_confirmation_gate: bool, pub downgrade_when_documentation_context: bool,
}
Expand description

A security detection rule

Rules define security patterns to detect in skill documents. Each rule specifies a condition to match, the threat category, severity level, and recommended action when matched.

Rules are typically defined in YAML format and loaded by the super::RuleEngine.

Fields§

§id: String

Unique rule identifier

§category: ThreatCategory

Threat category

§severity: Severity

Severity level

§confidence: f32

Confidence score (0.0 - 1.0)

§condition: RuleCondition

Condition that triggers the rule

§action: RecommendedAction

Recommended action

§reason: String

Human-readable reason

§shield: Option<ShieldHint>

Shield policy hint

§enabled: bool

Whether the rule is enabled

§tags: Vec<String>

Tags for filtering

§promptintel_threats: Vec<String>

Optional list of upstream PromptIntel threat names this rule covers (e.g. ["Jailbreak", "Hidden instruction in code or comments"]). Used by the promptintel coverage command to build a per-threat audit table; left empty for rules that do not target prompt-layer attacks. Validation against the canonical taxonomy happens in the CLI, not at parse time, so an upstream rename does not brick rule loading.

§requires_code_artifact: bool

When true, a regex match in the SKILL.md prose body that is NOT corroborated by an occurrence inside any markdown code block is downgraded from the rule’s natural action / signal-class to RequireApproval / ReviewSignal. Used for vocabulary-only rules (SKILL_PAYMENT_ACCESS, SKILL_TOKEN_SCAM, …) that legitimately fire on documentation or coaching skills which only DESCRIBE the pattern they detect. Cross-LLM triage on a 4000-skill VT-clean corpus confirmed prose-only matches drive ~30-50 FPs per affected rule.

Defaults to false — opt-in per rule, never global. The downgrade applies AFTER the regex matched; matches inside code blocks (or in any artifact whose MatchTarget is CodeBlock / ReferencedFile) keep full strength.

§downgrade_when_confirmation_gate: bool

When true, a finding is downgraded if the surrounding document contains explicit human-in-the-loop confirmation gate markers (e.g. confirmation_token, “user types YES”, “two-step gate”, “propose → user”). Used for autonomy / payment / deferred-execution rules whose risk model assumes no human gate. Cross-LLM triage on a 4000-skill VT-clean corpus showed okx-trading-style skills with strict propose→confirm workflows trip these rules even though the gate is exactly the safety control the rule was designed to require.

Defaults to false. Marker list lives in compiled::CONFIRMATION_GATE_MARKERS and is intentionally case-insensitive so authors don’t have to predict the exact phrasing.

§downgrade_when_documentation_context: bool

When true, a finding is downgraded if the document declares itself as an educational / detection / anti-pattern catalogue (e.g. ## What it checks, ## Anti-patterns, “this skill detects”, “examples of bad code”). Used for vocabulary rules whose patterns appear in security scanners that document the very behaviours they detect.

Defaults to false. Marker list lives in compiled::DOCUMENTATION_CONTEXT_MARKERS.

Trait Implementations§

Source§

impl Clone for Rule

Source§

fn clone(&self) -> Rule

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Rule

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Rule

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Rule

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Rule

§

impl RefUnwindSafe for Rule

§

impl Send for Rule

§

impl Sync for Rule

§

impl Unpin for Rule

§

impl UnsafeUnpin for Rule

§

impl UnwindSafe for Rule

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,