Skip to content

SusPatterns

The SusPatterns class manages suspicious patterns for security threat detection.

Class Definition

class SusPatterns:
    """
    A singleton class that manages suspicious patterns
    for security checks.
    """

Class Methods

add_pattern

@classmethod
async def add_pattern(
    cls,
    pattern: str,
    custom: bool = False
) -> None:
    """
    Add a new pattern to the detection system.
    """

remove_pattern

@classmethod
async def remove_pattern(
    cls,
    pattern: str,
    custom: bool = False
) -> None:
    """
    Remove a pattern from the detection system.
    """

get_all_patterns

@classmethod
async def get_all_patterns(cls) -> List[str]:
    """
    Get all registered patterns.
    """

Usage Example

from guard.sus_patterns import SusPatterns

# Add custom pattern
await SusPatterns.add_pattern(
    r"malicious_pattern.*",
    custom=True
)

# Get all patterns
patterns = await SusPatterns.get_all_patterns()

# Remove pattern
await SusPatterns.remove_pattern(
    r"malicious_pattern.*",
    custom=True
)