contextguard 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +57 -0
- package/CONTRIBUTING.md +532 -0
- package/LICENSE +21 -0
- package/README.md +163 -0
- package/SECURITY.md +254 -0
- package/dist/mcp-security-wrapper.js +398 -0
- package/eslint.config.mts +23 -0
- package/mcp_security.log +2 -0
- package/package.json +46 -0
- package/security.json +12 -0
- package/src/mcp-security-wrapper.ts +527 -0
- package/src/test-server.ts +295 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug Report
|
|
3
|
+
about: Report a bug to help us improve
|
|
4
|
+
title: '[BUG] '
|
|
5
|
+
labels: bug
|
|
6
|
+
assignees: ''
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 🐛 Bug Description
|
|
10
|
+
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
## 📋 To Reproduce
|
|
14
|
+
|
|
15
|
+
Steps to reproduce the behavior:
|
|
16
|
+
1. Run command '...'
|
|
17
|
+
2. Use MCP tool '...'
|
|
18
|
+
3. See error
|
|
19
|
+
|
|
20
|
+
## ✅ Expected Behavior
|
|
21
|
+
|
|
22
|
+
A clear description of what you expected to happen.
|
|
23
|
+
|
|
24
|
+
## 📸 Screenshots / Logs
|
|
25
|
+
|
|
26
|
+
If applicable, add screenshots or logs to help explain your problem.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
Paste relevant logs from mcp_security.log here
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 💻 Environment
|
|
33
|
+
|
|
34
|
+
**System:**
|
|
35
|
+
- OS: [e.g., macOS 14.0, Ubuntu 22.04, Windows 11]
|
|
36
|
+
- Node version: [e.g., 18.17.0]
|
|
37
|
+
- npm version: [e.g., 9.6.7]
|
|
38
|
+
|
|
39
|
+
**ContextGuard:**
|
|
40
|
+
- Version: [e.g., 0.1.0]
|
|
41
|
+
- Installation method: [npm global / local / from source]
|
|
42
|
+
|
|
43
|
+
**MCP Setup:**
|
|
44
|
+
- MCP server type: [e.g., filesystem, database, custom]
|
|
45
|
+
- MCP client: [e.g., Claude Desktop, custom client]
|
|
46
|
+
- Transport: [stdio / SSE / HTTP]
|
|
47
|
+
|
|
48
|
+
## 🔍 Additional Context
|
|
49
|
+
|
|
50
|
+
Add any other context about the problem here.
|
|
51
|
+
|
|
52
|
+
## ✔️ Checklist
|
|
53
|
+
|
|
54
|
+
- [ ] I have searched existing issues to avoid duplicates
|
|
55
|
+
- [ ] I have included all relevant logs
|
|
56
|
+
- [ ] I have tested with the latest version
|
|
57
|
+
- [ ] I can reproduce this consistently
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
# Contributing to ContextGuard
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to ContextGuard! 🎉
|
|
4
|
+
|
|
5
|
+
We welcome contributions of all kinds: bug reports, feature requests, documentation improvements, and code contributions.
|
|
6
|
+
|
|
7
|
+
## 📋 Table of Contents
|
|
8
|
+
|
|
9
|
+
- [Code of Conduct](#code-of-conduct)
|
|
10
|
+
- [How Can I Contribute?](#how-can-i-contribute)
|
|
11
|
+
- [Development Setup](#development-setup)
|
|
12
|
+
- [Coding Standards](#coding-standards)
|
|
13
|
+
- [Submitting Changes](#submitting-changes)
|
|
14
|
+
- [Adding Detection Rules](#adding-detection-rules)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 📜 Code of Conduct
|
|
19
|
+
|
|
20
|
+
This project follows a Code of Conduct that all contributors are expected to adhere to. Please be respectful and constructive.
|
|
21
|
+
|
|
22
|
+
**In short:**
|
|
23
|
+
|
|
24
|
+
- Be respectful and inclusive
|
|
25
|
+
- Focus on what's best for the community
|
|
26
|
+
- Show empathy towards other contributors
|
|
27
|
+
- Accept constructive criticism gracefully
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 🤝 How Can I Contribute?
|
|
32
|
+
|
|
33
|
+
### Reporting Bugs
|
|
34
|
+
|
|
35
|
+
**Before submitting a bug report:**
|
|
36
|
+
|
|
37
|
+
- Check existing issues to avoid duplicates
|
|
38
|
+
- Collect relevant information (OS, Node version, MCP server type)
|
|
39
|
+
|
|
40
|
+
**When submitting:**
|
|
41
|
+
|
|
42
|
+
```markdown
|
|
43
|
+
**Describe the bug**
|
|
44
|
+
A clear description of what the bug is.
|
|
45
|
+
|
|
46
|
+
**To Reproduce**
|
|
47
|
+
Steps to reproduce the behavior:
|
|
48
|
+
|
|
49
|
+
1. Run command '...'
|
|
50
|
+
2. Use MCP tool '...'
|
|
51
|
+
3. See error
|
|
52
|
+
|
|
53
|
+
**Expected behavior**
|
|
54
|
+
What you expected to happen.
|
|
55
|
+
|
|
56
|
+
**Logs**
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Paste relevant logs from mcp_security.log
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Environment:**
|
|
64
|
+
- OS: [e.g., macOS 14.0]
|
|
65
|
+
- Node version: [e.g., 18.17.0]
|
|
66
|
+
- ContextGuard version: [e.g., 0.1.0]
|
|
67
|
+
- MCP server: [e.g., filesystem, database]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Suggesting Features
|
|
71
|
+
|
|
72
|
+
We love new ideas! Before suggesting a feature:
|
|
73
|
+
|
|
74
|
+
- Check if it's already been suggested
|
|
75
|
+
- Explain **why** this feature would be useful
|
|
76
|
+
- Provide examples of how it would work
|
|
77
|
+
|
|
78
|
+
**Template:**
|
|
79
|
+
|
|
80
|
+
```markdown
|
|
81
|
+
**Feature Description**
|
|
82
|
+
Clear description of the feature.
|
|
83
|
+
|
|
84
|
+
**Use Case**
|
|
85
|
+
Who would use this and why?
|
|
86
|
+
|
|
87
|
+
**Proposed Implementation**
|
|
88
|
+
Technical approach (if you have ideas).
|
|
89
|
+
|
|
90
|
+
**Alternatives Considered**
|
|
91
|
+
Other solutions you've thought about.
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Improving Documentation
|
|
95
|
+
|
|
96
|
+
Documentation improvements are always welcome:
|
|
97
|
+
|
|
98
|
+
- Fix typos or unclear explanations
|
|
99
|
+
- Add examples
|
|
100
|
+
- Improve API documentation
|
|
101
|
+
- Create tutorials
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 💻 Development Setup
|
|
106
|
+
|
|
107
|
+
### Prerequisites
|
|
108
|
+
|
|
109
|
+
- Node.js 18+
|
|
110
|
+
- npm or yarn
|
|
111
|
+
- TypeScript knowledge
|
|
112
|
+
|
|
113
|
+
### Setup Steps
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# 1. Fork the repository on GitHub
|
|
117
|
+
|
|
118
|
+
# 2. Clone your fork
|
|
119
|
+
git clone https://github.com/amironi/contextguard.git
|
|
120
|
+
cd ContextGuard
|
|
121
|
+
|
|
122
|
+
# 3. Add upstream remote
|
|
123
|
+
git remote add upstream https://github.com/amironi/contextguard.git
|
|
124
|
+
|
|
125
|
+
# 4. Install dependencies
|
|
126
|
+
npm install
|
|
127
|
+
|
|
128
|
+
# 5. Build the project
|
|
129
|
+
npm run build
|
|
130
|
+
|
|
131
|
+
# 6. Run tests
|
|
132
|
+
npm test
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Running Locally
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
# Run in development mode
|
|
139
|
+
npm run dev -- --server "npx ts-node src/test-server.ts"
|
|
140
|
+
|
|
141
|
+
# Test with your own MCP server
|
|
142
|
+
npm run dev -- --server "node /path/to/your-server.js" --config security.json
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Project Structure
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
ContextGuard/
|
|
149
|
+
├── src/
|
|
150
|
+
│ ├── mcp-security-wrapper.ts # Main security wrapper
|
|
151
|
+
│ ├── test-server.ts # Test MCP server
|
|
152
|
+
│ └── types/ # TypeScript types
|
|
153
|
+
├── dist/ # Compiled JavaScript
|
|
154
|
+
├── examples/ # Example configurations
|
|
155
|
+
├── docs/ # Documentation
|
|
156
|
+
├── tests/ # Test files
|
|
157
|
+
└── package.json
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## 📝 Coding Standards
|
|
163
|
+
|
|
164
|
+
### TypeScript Style
|
|
165
|
+
|
|
166
|
+
We follow standard TypeScript conventions:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
// Good: Use descriptive variable names
|
|
170
|
+
const detectionPatterns = [/pattern1/, /pattern2/];
|
|
171
|
+
|
|
172
|
+
// Bad: Single letter variables (except loops)
|
|
173
|
+
const p = [/pattern1/, /pattern2/];
|
|
174
|
+
|
|
175
|
+
// Good: Use interfaces for complex types
|
|
176
|
+
interface SecurityEvent {
|
|
177
|
+
timestamp: string;
|
|
178
|
+
severity: "LOW" | "MEDIUM" | "HIGH" | "CRITICAL";
|
|
179
|
+
details: Record<string, any>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Good: Add JSDoc comments for public functions
|
|
183
|
+
/**
|
|
184
|
+
* Checks if the text contains prompt injection patterns
|
|
185
|
+
* @param text - The text to analyze
|
|
186
|
+
* @returns Array of detected violations
|
|
187
|
+
*/
|
|
188
|
+
function checkPromptInjection(text: string): string[] {
|
|
189
|
+
// implementation
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### Code Quality
|
|
194
|
+
|
|
195
|
+
- **Write tests** for new features
|
|
196
|
+
- **Keep functions small** (< 50 lines ideally)
|
|
197
|
+
- **Use meaningful names** for variables and functions
|
|
198
|
+
- **Comment complex logic** but avoid obvious comments
|
|
199
|
+
- **Handle errors gracefully** with try-catch
|
|
200
|
+
- **Log important events** for debugging
|
|
201
|
+
|
|
202
|
+
### Linting
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
# Run ESLint
|
|
206
|
+
npm run lint
|
|
207
|
+
|
|
208
|
+
# Fix auto-fixable issues
|
|
209
|
+
npm run lint:fix
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## 🔄 Submitting Changes
|
|
215
|
+
|
|
216
|
+
### Branch Naming
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Features
|
|
220
|
+
git checkout -b feature/add-ml-detection
|
|
221
|
+
|
|
222
|
+
# Bug fixes
|
|
223
|
+
git checkout -b fix/path-traversal-false-positive
|
|
224
|
+
|
|
225
|
+
# Documentation
|
|
226
|
+
git checkout -b docs/improve-readme
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Commit Messages
|
|
230
|
+
|
|
231
|
+
Follow [Conventional Commits](https://www.conventionalcommits.org/):
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Features
|
|
235
|
+
feat: add ML-based anomaly detection
|
|
236
|
+
|
|
237
|
+
# Bug fixes
|
|
238
|
+
fix: resolve false positive in prompt injection detection
|
|
239
|
+
|
|
240
|
+
# Documentation
|
|
241
|
+
docs: update installation instructions
|
|
242
|
+
|
|
243
|
+
# Performance
|
|
244
|
+
perf: optimize regex matching for large payloads
|
|
245
|
+
|
|
246
|
+
# Tests
|
|
247
|
+
test: add tests for rate limiting
|
|
248
|
+
|
|
249
|
+
# Refactoring
|
|
250
|
+
refactor: simplify SecurityPolicy class
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Pull Request Process
|
|
254
|
+
|
|
255
|
+
1. **Update your fork**
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
git fetch upstream
|
|
259
|
+
git rebase upstream/main
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
2. **Create a pull request**
|
|
263
|
+
|
|
264
|
+
- Write a clear title and description
|
|
265
|
+
- Reference related issues (e.g., "Fixes #123")
|
|
266
|
+
- Include screenshots for UI changes
|
|
267
|
+
- Add tests for new features
|
|
268
|
+
|
|
269
|
+
3. **PR Description Template**
|
|
270
|
+
|
|
271
|
+
```markdown
|
|
272
|
+
## Description
|
|
273
|
+
|
|
274
|
+
Brief description of changes.
|
|
275
|
+
|
|
276
|
+
## Related Issues
|
|
277
|
+
|
|
278
|
+
Fixes #123
|
|
279
|
+
|
|
280
|
+
## Type of Change
|
|
281
|
+
|
|
282
|
+
- [ ] Bug fix
|
|
283
|
+
- [ ] New feature
|
|
284
|
+
- [ ] Documentation update
|
|
285
|
+
- [ ] Performance improvement
|
|
286
|
+
|
|
287
|
+
## Testing
|
|
288
|
+
|
|
289
|
+
How has this been tested?
|
|
290
|
+
|
|
291
|
+
## Checklist
|
|
292
|
+
|
|
293
|
+
- [ ] Tests added/updated
|
|
294
|
+
- [ ] Documentation updated
|
|
295
|
+
- [ ] No breaking changes
|
|
296
|
+
- [ ] Lint passes
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
4. **Code Review**
|
|
300
|
+
|
|
301
|
+
- Address reviewer feedback
|
|
302
|
+
- Be open to suggestions
|
|
303
|
+
- Keep discussions professional
|
|
304
|
+
|
|
305
|
+
5. **Merge**
|
|
306
|
+
- Maintainers will merge after approval
|
|
307
|
+
- Delete your branch after merge
|
|
308
|
+
|
|
309
|
+
---
|
|
310
|
+
|
|
311
|
+
## 🔍 Adding Detection Rules
|
|
312
|
+
|
|
313
|
+
### Creating a New Detection Pattern
|
|
314
|
+
|
|
315
|
+
Want to help catch more threats? Here's how to add new detection rules:
|
|
316
|
+
|
|
317
|
+
#### 1. Identify the Pattern
|
|
318
|
+
|
|
319
|
+
Example: Detecting SQL injection attempts in tool parameters
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
// Bad SQL injection patterns
|
|
323
|
+
"'; DROP TABLE users; --";
|
|
324
|
+
"1' OR '1'='1";
|
|
325
|
+
"admin'--";
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
#### 2. Create the Regex
|
|
329
|
+
|
|
330
|
+
```typescript
|
|
331
|
+
const sqlInjectionPatterns = [
|
|
332
|
+
/('|(\\'))(;|(\s+)|(\\s+))(drop|delete|insert|update)/gi,
|
|
333
|
+
/(\d+|\w+)('\s+)(or|and)(\s+)('\d+|\w+')(\s*)=(\s*)('\d+|\w+')/gi,
|
|
334
|
+
/(--|#|\/\*|\*\/)/g,
|
|
335
|
+
];
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
#### 3. Add to Detection Engine
|
|
339
|
+
|
|
340
|
+
Edit `src/mcp-security-wrapper.ts`:
|
|
341
|
+
|
|
342
|
+
```typescript
|
|
343
|
+
class SecurityPolicy {
|
|
344
|
+
private sqlInjectionPatterns: RegExp[];
|
|
345
|
+
|
|
346
|
+
constructor(config: SecurityConfig) {
|
|
347
|
+
// ... existing code ...
|
|
348
|
+
|
|
349
|
+
this.sqlInjectionPatterns = [
|
|
350
|
+
/('|(\\'))(;|(\s+)|(\\s+))(drop|delete|insert|update)/gi,
|
|
351
|
+
/(\d+|\w+)('\s+)(or|and)(\s+)('\d+|\w+')(\s*)=(\s*)('\d+|\w+')/gi,
|
|
352
|
+
];
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
checkSqlInjection(text: string): string[] {
|
|
356
|
+
const violations: string[] = [];
|
|
357
|
+
|
|
358
|
+
for (const pattern of this.sqlInjectionPatterns) {
|
|
359
|
+
const matches = text.match(pattern);
|
|
360
|
+
if (matches) {
|
|
361
|
+
violations.push(
|
|
362
|
+
`SQL injection attempt detected: ${matches[0].substring(0, 50)}...`
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
return violations;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
#### 4. Add Tests
|
|
373
|
+
|
|
374
|
+
Create `tests/sql-injection.test.ts`:
|
|
375
|
+
|
|
376
|
+
```typescript
|
|
377
|
+
import { SecurityPolicy } from "../src/mcp-security-wrapper";
|
|
378
|
+
|
|
379
|
+
describe("SQL Injection Detection", () => {
|
|
380
|
+
let policy: SecurityPolicy;
|
|
381
|
+
|
|
382
|
+
beforeEach(() => {
|
|
383
|
+
policy = new SecurityPolicy({});
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it("should detect DROP TABLE injection", () => {
|
|
387
|
+
const malicious = "'; DROP TABLE users; --";
|
|
388
|
+
const violations = policy.checkSqlInjection(malicious);
|
|
389
|
+
expect(violations.length).toBeGreaterThan(0);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
it("should detect OR 1=1 injection", () => {
|
|
393
|
+
const malicious = "admin' OR '1'='1";
|
|
394
|
+
const violations = policy.checkSqlInjection(malicious);
|
|
395
|
+
expect(violations.length).toBeGreaterThan(0);
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
it("should not flag legitimate SQL-like text", () => {
|
|
399
|
+
const legitimate = "Please drop me an email";
|
|
400
|
+
const violations = policy.checkSqlInjection(legitimate);
|
|
401
|
+
expect(violations.length).toBe(0);
|
|
402
|
+
});
|
|
403
|
+
});
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
#### 5. Document the Pattern
|
|
407
|
+
|
|
408
|
+
Add to README.md:
|
|
409
|
+
|
|
410
|
+
````markdown
|
|
411
|
+
### SQL Injection Detection
|
|
412
|
+
|
|
413
|
+
ContextGuard detects SQL injection attempts in tool parameters:
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
// Detected patterns include:
|
|
417
|
+
"'; DROP TABLE users; --";
|
|
418
|
+
"admin' OR '1'='1";
|
|
419
|
+
"1' UNION SELECT * FROM passwords";
|
|
420
|
+
```
|
|
421
|
+
````
|
|
422
|
+
|
|
423
|
+
````
|
|
424
|
+
|
|
425
|
+
#### 6. Submit PR
|
|
426
|
+
|
|
427
|
+
Title: `feat: add SQL injection detection`
|
|
428
|
+
|
|
429
|
+
Description:
|
|
430
|
+
```markdown
|
|
431
|
+
## Description
|
|
432
|
+
Adds detection for SQL injection attempts in MCP tool parameters.
|
|
433
|
+
|
|
434
|
+
## Patterns Detected
|
|
435
|
+
- DROP/DELETE/INSERT/UPDATE with quotes
|
|
436
|
+
- OR/AND boolean injections
|
|
437
|
+
- SQL comments (--, #, /* */)
|
|
438
|
+
|
|
439
|
+
## Testing
|
|
440
|
+
- Added 10 test cases
|
|
441
|
+
- Tested against known SQL injection payloads
|
|
442
|
+
- False positive rate: < 1%
|
|
443
|
+
|
|
444
|
+
## Related Issues
|
|
445
|
+
Fixes #45
|
|
446
|
+
````
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## 🎨 Best Practices for Detection Rules
|
|
451
|
+
|
|
452
|
+
### 1. Minimize False Positives
|
|
453
|
+
|
|
454
|
+
```typescript
|
|
455
|
+
// Bad: Too broad, catches legitimate use
|
|
456
|
+
/password/gi
|
|
457
|
+
|
|
458
|
+
// Good: More specific pattern
|
|
459
|
+
/password\s*[:=]\s*['"]?[\w\-\.]+['"]?/gi
|
|
460
|
+
```
|
|
461
|
+
|
|
462
|
+
### 2. Performance Matters
|
|
463
|
+
|
|
464
|
+
```typescript
|
|
465
|
+
// Bad: Expensive regex
|
|
466
|
+
/(a+)+b/
|
|
467
|
+
|
|
468
|
+
// Good: Efficient pattern
|
|
469
|
+
/a+b/
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
### 3. Document Your Patterns
|
|
473
|
+
|
|
474
|
+
```typescript
|
|
475
|
+
/**
|
|
476
|
+
* Detects AWS access keys in format AKIA[0-9A-Z]{16}
|
|
477
|
+
*
|
|
478
|
+
* Example matches:
|
|
479
|
+
* - AKIAIOSFODNN7EXAMPLE
|
|
480
|
+
*
|
|
481
|
+
* False positives:
|
|
482
|
+
* - Very rare, AWS format is specific
|
|
483
|
+
*/
|
|
484
|
+
const awsKeyPattern = /AKIA[0-9A-Z]{16}/g;
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
### 4. Test Edge Cases
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
describe("Edge cases", () => {
|
|
491
|
+
it("should handle empty string", () => {
|
|
492
|
+
expect(detect("")).toEqual([]);
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
it("should handle very long strings", () => {
|
|
496
|
+
const longString = "a".repeat(1000000);
|
|
497
|
+
expect(() => detect(longString)).not.toThrow();
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it("should handle special characters", () => {
|
|
501
|
+
expect(detect("!@#$%^&*()")).toEqual([]);
|
|
502
|
+
});
|
|
503
|
+
});
|
|
504
|
+
```
|
|
505
|
+
|
|
506
|
+
---
|
|
507
|
+
|
|
508
|
+
## 🏆 Recognition
|
|
509
|
+
|
|
510
|
+
Contributors who make significant improvements will be:
|
|
511
|
+
|
|
512
|
+
- Listed in README.md contributors section
|
|
513
|
+
- Mentioned in release notes
|
|
514
|
+
- Given credit in documentation
|
|
515
|
+
|
|
516
|
+
---
|
|
517
|
+
|
|
518
|
+
## 📞 Getting Help
|
|
519
|
+
|
|
520
|
+
- **Questions?** Open a GitHub Discussion
|
|
521
|
+
- **Stuck?** Ask in Discord (coming soon)
|
|
522
|
+
- **Security concern?** Email security@ContextGuard.io
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## 📜 License
|
|
527
|
+
|
|
528
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
529
|
+
|
|
530
|
+
---
|
|
531
|
+
|
|
532
|
+
**Thank you for contributing to ContextGuard! Together we're making MCP safer for everyone.** 🛡️
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 [Amir Mironi]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|