IntegraChat / RULES_EXAMPLES.md
nothingworry's picture
feat: Enhance admin rules with file upload, drag-and-drop, chunk processing, and improved UI
a477044
|
raw
history blame
6.59 kB

Admin Rules Examples for IntegraChat

This document provides examples of rules you can use with the IntegraChat admin rules system.

Quick Start

  1. Simple Rules - Copy from example_rules.txt and paste into Gradio UI
  2. Detailed Rules - Use example_rules_detailed.json for rules with patterns and severity
  3. API - Use the /admin/rules or /admin/rules/bulk endpoints

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)

  1. Open the IntegraChat Gradio interface
  2. Go to "Admin Rules & Compliance" tab
  3. Enter your tenant ID
  4. Paste rules from example_rules.txt (one per line)
  5. 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"]

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

  1. Start Simple - Begin with basic rules, then add patterns
  2. Test Thoroughly - Test rules with various phrasings
  3. Review Edge Cases - Check if rules block legitimate queries
  4. Use Appropriate Severity - Match severity to risk level
  5. Regular Updates - Review and update rules periodically
  6. 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.txt for simple rule examples
  • See example_rules_detailed.json for advanced patterns
  • Review the API documentation in README.md
  • Test rules in the Gradio UI before deploying