Spaces:
Sleeping
Sleeping
Download utils/security.py from Dws321/spark_colony: direct link, hf CLI and curl.
- Browser
- Download file 509 Bytes
-
https://huggingface.co/spaces/Dws321/spark_colony/resolve/main/utils/security.py
- Command line
-
hf download hf://spaces/Dws321/spark_colony/utils/security.py
-
curl -L -o security.py https://huggingface.co/spaces/Dws321/spark_colony/resolve/main/utils/security.py
509 Bytes
| class SecurityEngine: | |
| """Sanitizes directives and validates actions against prompt injections and path traversal.""" | |
| def sanitize_input(user_input: str) -> str: | |
| dangerous_patterns = ["ignore previous instructions", "system override", "rm -rf", "drop table"] | |
| sanitized = user_input | |
| for p in dangerous_patterns: | |
| if p in sanitized.lower(): | |
| sanitized = sanitized.replace(p, f"[BLOCKED_PATTERN: {p}]") | |
| return sanitized.strip() | |