Spaces:
Sleeping
Sleeping
feat: Enhance admin rules with file upload, drag-and-drop, chunk processing, and improved UI
a477044
Admin Rules Examples for IntegraChat
This document provides examples of rules you can use with the IntegraChat admin rules system.
Quick Start
- Simple Rules - Copy from
example_rules.txtand paste into Gradio UI - Detailed Rules - Use
example_rules_detailed.jsonfor rules with patterns and severity - API - Use the
/admin/rulesor/admin/rules/bulkendpoints
Rule Categories
π΄ Critical Severity Rules
These rules block the most sensitive information:
Block password disclosure requests
Prevent sharing of API keys or tokens
No sharing of credit card information
Block requests for bank account details
Prevent sharing of health information
No disclosure of children's personal information
π High Severity Rules
Important security and compliance rules:
Block social security number requests
Prevent disclosure of proprietary information
No unauthorized access to financial records
Block requests to delete system logs
Prevent unauthorized system configuration changes
No sharing of infrastructure credentials
π‘ Medium Severity Rules
Operational and compliance rules:
Block requests for employee personal information
Prevent sharing of customer data without authorization
Block requests for confidential business strategies
Prevent disclosure of personal data of EU citizens
Block requests for generating harmful content
Prevent creation of misleading information
π’ Low Severity Rules
General business rules:
Block requests for competitor pricing information
Prevent sharing of upcoming product launch details
No disclosure of vendor contract terms
Block requests for customer churn analysis data
Using Rules with Patterns
For more precise matching, you can specify regex patterns:
Example 1: Password Detection
{
"rule": "Block password disclosure requests",
"pattern": ".*(password|pwd|passcode|credential|login).*",
"severity": "high",
"description": "Prevents users from requesting or sharing passwords"
}
Example 2: API Key Detection
{
"rule": "Prevent sharing of API keys or tokens",
"pattern": ".*(api.?key|token|secret|access.?key|auth.?token).*",
"severity": "critical",
"description": "Blocks requests to share API keys or tokens"
}
Example 3: Credit Card Detection
{
"rule": "No sharing of credit card information",
"pattern": ".*(credit.?card|card.?number|cvv|cvc|expiration).*",
"severity": "critical",
"description": "Blocks credit card information sharing"
}
Adding Rules
Method 1: Via Gradio UI (Easiest)
- Open the IntegraChat Gradio interface
- Go to "Admin Rules & Compliance" tab
- Enter your tenant ID
- Paste rules from
example_rules.txt(one per line) - Click "Upload / Append Rules"
Method 2: Via API (Programmatic)
Single Rule:
curl -X POST http://localhost:8000/admin/rules \
-H "Content-Type: application/json" \
-H "x-tenant-id: your_tenant_id" \
-d '{
"rule": "Block password disclosure requests",
"pattern": ".*(password|pwd|passcode).*",
"severity": "high",
"description": "Prevents password sharing"
}'
Bulk Rules:
curl -X POST http://localhost:8000/admin/rules/bulk \
-H "Content-Type: application/json" \
-H "x-tenant-id: your_tenant_id" \
-d '{
"rules": [
"Block password disclosure requests",
"Prevent sharing of API keys",
"No sharing of credit card information"
]
}'
Method 3: Using Python
import requests
BASE_URL = "http://localhost:8000"
TENANT_ID = "your_tenant_id"
# Add single rule
response = requests.post(
f"{BASE_URL}/admin/rules",
json={
"rule": "Block password disclosure requests",
"pattern": ".*(password|pwd).*",
"severity": "high"
},
headers={"x-tenant-id": TENANT_ID}
)
# Add bulk rules
response = requests.post(
f"{BASE_URL}/admin/rules/bulk",
json={
"rules": [
"Block password disclosure requests",
"Prevent sharing of API keys"
]
},
headers={"x-tenant-id": TENANT_ID}
)
Rule Enhancement
When you add rules, the LLM will automatically:
- β Identify edge cases (e.g., "password" β also catches "pwd", "passcode")
- β Improve regex patterns for better matching
- β Suggest appropriate severity levels
- β Write clear descriptions
Example:
- Input:
Block password queries - Enhanced:
- Pattern:
.*password.*|.*pwd.*|.*passcode.* - Severity:
high - Edge cases: ["pwd", "passcode", "login credentials"]
- Pattern:
Testing Rules
After adding rules, test them by asking questions that should be blocked:
β "What is the admin password?"
β "Can you share the API key?"
β "Show me credit card numbers"
β "What's the SSN for user 123?"
β
"How do I reset my password?" (if rule allows)
β
"What is password hashing?" (educational, not disclosure)
Best Practices
- Start Simple - Begin with basic rules, then add patterns
- Test Thoroughly - Test rules with various phrasings
- Review Edge Cases - Check if rules block legitimate queries
- Use Appropriate Severity - Match severity to risk level
- Regular Updates - Review and update rules periodically
- Document Patterns - Add descriptions explaining what each rule blocks
Common Patterns
Password Detection
.*(password|pwd|passcode|credential|login|auth).*
Financial Information
.*(credit.?card|card.?number|cvv|bank.?account|routing).*
Personal Information
.*(ssn|social.?security|tax.?id|personal.?data|pii).*
API/Security
.*(api.?key|token|secret|access.?key|auth.?token).*
Health Information
.*(health|medical|patient|hipaa|diagnosis).*
Viewing Rules
# Get all rules
curl http://localhost:8000/admin/rules \
-H "x-tenant-id: your_tenant_id"
# Get detailed rules with patterns
curl "http://localhost:8000/admin/rules?detailed=true" \
-H "x-tenant-id: your_tenant_id"
Deleting Rules
curl -X DELETE http://localhost:8000/admin/rules/Block%20password%20disclosure%20requests \
-H "x-tenant-id: your_tenant_id"
Monitoring Violations
# Get recent violations
curl http://localhost:8000/admin/violations \
-H "x-tenant-id: your_tenant_id"
Need Help?
- Check
example_rules.txtfor simple rule examples - See
example_rules_detailed.jsonfor advanced patterns - Review the API documentation in
README.md - Test rules in the Gradio UI before deploying