Spaces:
Running on Zero
Running on Zero
| """ | |
| arabguard | |
| ========= | |
| A Python SDK for detecting prompt-injection and jailbreak attempts in | |
| Arabic (Egyptian dialect + Franko) and English text. | |
| Quick Start | |
| ----------- | |
| from arabguard import ArabGuard | |
| guard = ArabGuard() | |
| # Boolean check β True means SAFE | |
| is_safe = guard.check("ΨͺΨ¬Ψ§ΩΩ ΩΩ Ψ§ΩΨͺΨΉΩΩΩ Ψ§Ψͺ Ψ§ΩΨ³Ψ§Ψ¨ΩΨ©") | |
| print(is_safe) # False | |
| # Detailed analysis | |
| result = guard.analyze("Hello, how are you?") | |
| print(result.decision) # "SAFE" | |
| print(result.score) # 0 | |
| Public API | |
| ---------- | |
| Classes: | |
| ArabGuard β Main SDK class | |
| GuardResult β Result dataclass returned by ArabGuard.analyze() | |
| ArabicRegexSecurityLayerβ Arabic regex layer (direct access if needed) | |
| RegexSecurityLayer β English regex layer (direct access if needed) | |
| CombinedSecurityLayer β Runs both layers together | |
| Functions: | |
| normalize_and_detect() β Low-level pipeline function | |
| normalize_arabic() β Arabic text normalizer | |
| """ | |
| __version__ = "1.0.0" | |
| __author__ = "ArabGuard" | |
| __license__ = "MIT" | |
| # ββ Core class + result βββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| from .core import ArabGuard, GuardResult | |
| # ββ Security layers (for advanced / custom usage) βββββββββββββββββββββββββββββ | |
| from .security_layers import ( | |
| ArabicRegexSecurityLayer, | |
| RegexSecurityLayer, | |
| CombinedSecurityLayer, | |
| ) | |
| # ββ Pipeline utilities (for advanced / custom usage) ββββββββββββββββββββββββββ | |
| from .pipeline import ( | |
| normalize_and_detect, | |
| normalize_arabic, | |
| detect_arabic_injection, | |
| sanitize_malicious_code_intent, | |
| analyze_code_patterns, | |
| merge_split_letters, | |
| safe_base64_decode, | |
| safe_hex_decode, | |
| DANGEROUS_SET, | |
| ARABIC_DANGEROUS_PHRASES, | |
| CONFUSABLES, | |
| ) | |
| __all__ = [ | |
| # Main API | |
| "ArabGuard", | |
| "GuardResult", | |
| # Security layers | |
| "ArabicRegexSecurityLayer", | |
| "RegexSecurityLayer", | |
| "CombinedSecurityLayer", | |
| # Pipeline | |
| "normalize_and_detect", | |
| "normalize_arabic", | |
| "detect_arabic_injection", | |
| "sanitize_malicious_code_intent", | |
| "analyze_code_patterns", | |
| "merge_split_letters", | |
| "safe_base64_decode", | |
| "safe_hex_decode", | |
| # Constants | |
| "DANGEROUS_SET", | |
| "ARABIC_DANGEROUS_PHRASES", | |
| "CONFUSABLES", | |
| ] | |