Skip to content

OxideShield Guard SDK

The Guard SDK makes it easy to create custom security guards for OxideShield without deep knowledge of the internal crate structure.

What's Included

Component Description
#[derive(Guard)] Proc-macro that auto-implements the Guard trait
GuardBuilder Fluent API for building keyword-based guards
Template Guards Ready-to-use RegexGuard, KeywordGuard, CustomMLGuard, ApiGuard, CompositeGuard
Utilities tokenize(), normalize(), pattern_match(), similarity()
CLI Generator oxideshield generate guard --name MyGuard --type regex
Python SDK CustomGuard base class for Python-only guard development

Architecture

oxide-guard-derive   (proc-macro crate)
oxide-guard-sdk      (convenience SDK)
       ├── Re-exports core types (Guard, GuardAction, etc.)
       ├── GuardBuilder
       ├── Template guards
       └── Utility functions

Quick Start

Add to your Cargo.toml:

[dependencies]
oxide-guard-sdk = "0.1.6"

Then create a guard:

use oxide_guard_sdk::prelude::*;

#[derive(Guard)]
struct MyGuard {
    name: String,
    action: GuardAction,
}

impl MyGuard {
    fn guard_check(&self, content: &str) -> GuardCheckResult {
        if content.contains("danger") {
            GuardCheckResult::fail(&self.name, self.action, vec![], "Found danger")
        } else {
            GuardCheckResult::pass(&self.name)
        }
    }
}

References