File size: 6,080 Bytes
d08ebea
4e5dfd3
 
 
d08ebea
26558fc
4e5dfd3
0238b3a
40f5e1f
740932b
489a7cb
 
26558fc
 
 
 
 
 
 
 
 
 
 
 
 
78e1e87
26558fc
 
 
 
42ae9bd
26558fc
 
 
 
 
69877fb
 
 
26558fc
 
 
 
 
 
 
 
 
a301c88
26558fc
 
cda6e45
034769e
26558fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e228770
26558fc
 
 
0cd836f
e228770
a825802
 
04208f4
 
e228770
a825802
 
 
0cd836f
e228770
a825802
 
 
26558fc
 
 
e228770
26558fc
 
 
 
e228770
26558fc
 
 
 
e228770
26558fc
 
 
8d262b6
26558fc
 
e228770
26558fc
 
 
 
 
 
 
e228770
26558fc
 
 
 
 
e228770
26558fc
 
 
 
 
 
e228770
26558fc
 
 
 
42ae9bd
 
 
 
 
 
 
26558fc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4e5dfd3
b685512
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# LLMGuardian

[CLICK HERE FOR THE FULL PROJECT](https://github.com/Finoptimize/LLMGuardian)

Comprehensive LLM protection toolset aligned to addressing OWASP vulnerabilities

Author: [DeWitt Gibson https://www.linkedin.com/in/dewitt-gibson/](https://www.linkedin.com/in/dewitt-gibson)

**Full Documentaion and Usage Instructions: [DOCS](docs/README.md)**

**Please see the Projects and Issues tab above for completion roadmap**

# Project Structure

LLMGuardian follows a modular and secure architecture designed to provide comprehensive protection for LLM applications. Below is the detailed project structure with explanations for each component:

## Directory Structure

```
LLMGuardian/
β”œβ”€β”€ .github/                      # GitHub specific configurations
β”‚   β”œβ”€β”€ workflows/                # GitHub Actions workflows
β”‚   β”œβ”€β”€ CODEOWNERS               # Repository ownership rules
β”‚   β”œβ”€β”€ ISSUE_TEMPLATE/          # Issue reporting templates
β”‚   └── PULL_REQUEST_TEMPLATE.md # PR guidelines
β”œβ”€β”€ .circleci/                   # config files for using CircleCI https://circleci.com/ 
β”‚
β”œβ”€β”€ src/                         # Source code
β”‚   └── llmguardian/            # Main package directory
β”‚       β”œβ”€β”€ cli/                # Command-line interface
β”‚       β”œβ”€β”€ dashboard/          # Streamlit dashboard
β”‚       β”œβ”€β”€ core/               # Core functionality
β”‚       β”œβ”€β”€ scanners/           # Security scanning modules
β”‚       β”œβ”€β”€ defenders/          # Defense mechanisms
β”‚       β”œβ”€β”€ monitors/           # Monitoring components
β”‚       β”œβ”€β”€ api/                # API integration
|       β”œβ”€β”€ vectors/            # Embeddings protection / supply chain vulnerabilities
|       β”œβ”€β”€ data/               # Sensive data exposure / data poisoning
|       β”œβ”€β”€ agency/             # Excessive agency protection
β”‚       └── utils/              # Utility functions
β”‚
β”œβ”€β”€ tests/                      # Test suite
β”‚   β”œβ”€β”€ unit/                  # Unit tests
β”‚   β”œβ”€β”€ integration/           # Integration tests
β”‚   └── security/              # Security-specific tests
β”‚
β”œβ”€β”€ docs/                      # Documentation
β”œβ”€β”€ scripts/                   # Utility scripts
β”œβ”€β”€ page/                      # Files for GitHub pages
β”œβ”€β”€ requirements/              # Dependencies
β”œβ”€β”€ docker/                    # Docker configurations
β”œβ”€β”€ config/                    # Various config files
└── app.py                     # Huggingface Space deployment
```

## Component Details

### Security Components

1. **Scanners (`src/llmguardian/scanners/`)**
   - Prompt injection detection
   - Data leakage scanning
   - Model security validation
   - Output validation checks

2. **Defenders (`src/llmguardian/defenders/`)**
   - Input sanitization
   - Output filtering
   - Rate limiting
   - Token validation

3. **Monitors (`src/llmguardian/monitors/`)**
   - Real-time usage tracking
   - Threat detection
   - Anomaly monitoring

4. **Vectors (`src/llmguardian/vectors/`)**
   - Embedding weaknesses
   - Supply chain vulnerabilities
   - Montior vector stores

5. **Data (`src/llmguardian/data/`)**
   - Sensitive information disclosure
   - Protection from data poisoning
   - Data sanitizing

6. **Agency (`src/llmguardian/agency/`)**
   - Permission management
   - Scope limitation
   - Safe execution

### Core Components

7. **CLI (`src/llmguardian/cli/`)**
   - Command-line interface
   - Interactive tools
   - Configuration management

8. **API (`src/llmguardian/api/`)**
   - RESTful endpoints
   - Middleware
   - Integration interfaces

9. **Core (`src/llmguardian/core/`)**
   - Configuration management
   - Logging setup
   - Core functionality
  
### Testing & Quality Assurance

10. **Tests (`tests/`)**
   - Unit tests for individual components
   - Integration tests for system functionality
   - Security-specific test cases
   - Vulnerability testing

### Documentation & Support

11. **Documentation (`docs/`)**
   - API documentation
   - Implementation guides
   - Security best practices
   - Usage examples

12. **Docker (`docker/`)**
   - Containerization support
   - Development environment
   - Production deployment

### Development Tools

13. **Scripts (`scripts/`)**
    - Setup utilities
    - Development tools
    - Security checking scripts

### Dashboard

14. **Dashboard(`src/llmguardian/dashboard/`)**
   - Streamlit app
   - Visualization 
   - Monitoring and control

## Key Files

- `pyproject.toml`: Project metadata and dependencies
- `setup.py`: Package setup configuration
- `requirements/*.txt`: Environment-specific dependencies
- `.pre-commit-config.yaml`: Code quality hooks
- `CONTRIBUTING.md`: Contribution guidelines
- `LICENSE`: MIT license terms

## Design Principles

The structure follows these key principles:

1. **Modularity**: Each component is self-contained and independently maintainable
2. **Security-First**: Security considerations are built into the architecture
3. **Scalability**: Easy to extend and add new security features
4. **Testability**: Comprehensive test coverage and security validation
5. **Usability**: Clear organization and documentation

## Getting Started with Development

To start working with this structure:

1. Fork the repository
2. Create and activate a virtual environment
3. Install dependencies from the appropriate requirements file
4. Run the test suite to ensure everything is working
5. Follow the contribution guidelines for making changes

## Huggingface

Huggingface Space Implementation:

https://huggingface.co/spaces/Safe-Harbor/LLMGuardian

1. Create FastAPI backend with:

   - Model scanning endpoints
   - Prompt injection detection
   - Input/output validation
   - Rate limiting middleware
   - Authentication checks


2. Gradio UI frontend with:

   - Model security testing interface
   - Vulnerability scanning dashboard
   - Real-time attack detection
   - Configuration settings