@triedotdev/mcp 1.0.3 → 1.0.5
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/README.md +80 -169
- package/dist/{chunk-E7CKHS3R.js → chunk-77JFVVWF.js} +218 -37
- package/dist/chunk-77JFVVWF.js.map +1 -0
- package/dist/cli/main.js +17 -9
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/yolo-daemon.js +1 -1
- package/dist/index.js +81 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-E7CKHS3R.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,35 +1,26 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Trie
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Customizable Agent Parallelization for AI Code Review**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
13 specialized agents scan your code for security, privacy, compliance, and bugs—all running in parallel. Create custom agents from any document.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- **AI coding tool** (Cursor, Claude Code, or VS Code with MCP support)
|
|
7
|
+
## Features
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
- **13 Built-in Agents** - Security, Privacy, SOC 2, Legal, Architecture, DevOps, and more
|
|
10
|
+
- **Parallel Execution** - All agents run simultaneously for fast scans
|
|
11
|
+
- **Custom Agents** - Create agents from PDFs, docs, or style guides
|
|
12
|
+
- **No API Key Required** - Uses your AI tool's built-in Claude
|
|
13
|
+
- **Smart Triaging** - Only activates relevant agents based on code context
|
|
11
14
|
|
|
12
|
-
|
|
15
|
+
## Quick Start
|
|
13
16
|
|
|
14
17
|
```bash
|
|
15
18
|
npm install -g @triedotdev/mcp
|
|
16
19
|
```
|
|
17
20
|
|
|
18
|
-
###
|
|
21
|
+
### Configure Cursor
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## Configuration
|
|
23
|
-
|
|
24
|
-
### For Claude Code
|
|
25
|
-
|
|
26
|
-
Use the `claude` CLI to add the MCP server:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
claude mcp add Trie -- npx @triedotdev/mcp
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Or add to `~/.claude/settings.json`:
|
|
23
|
+
Settings → MCP Servers → Add:
|
|
33
24
|
|
|
34
25
|
```json
|
|
35
26
|
{
|
|
@@ -42,194 +33,114 @@ Or add to `~/.claude/settings.json`:
|
|
|
42
33
|
}
|
|
43
34
|
```
|
|
44
35
|
|
|
45
|
-
###
|
|
46
|
-
|
|
47
|
-
1. Open Cursor Settings → MCP Servers
|
|
48
|
-
2. Add this configuration:
|
|
36
|
+
### Configure Claude Code
|
|
49
37
|
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
"mcpServers": {
|
|
53
|
-
"Trie": {
|
|
54
|
-
"command": "npx",
|
|
55
|
-
"args": ["@triedotdev/mcp"]
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### For VS Code
|
|
62
|
-
|
|
63
|
-
Add to your VS Code settings (`.vscode/settings.json` or user settings):
|
|
64
|
-
|
|
65
|
-
```json
|
|
66
|
-
{
|
|
67
|
-
"mcp.servers": {
|
|
68
|
-
"Trie": {
|
|
69
|
-
"command": "npx",
|
|
70
|
-
"args": ["@triedotdev/mcp"]
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
38
|
+
```bash
|
|
39
|
+
claude mcp add Trie -- npx @triedotdev/mcp
|
|
74
40
|
```
|
|
75
41
|
|
|
76
42
|
## Usage
|
|
77
43
|
|
|
78
|
-
|
|
44
|
+
Once configured, just ask your AI assistant:
|
|
79
45
|
|
|
80
|
-
Once configured, use Trie Agent in your AI coding tool:
|
|
81
|
-
|
|
82
|
-
**In Cursor/Claude Code:**
|
|
83
46
|
```
|
|
84
|
-
Scan this code with Trie
|
|
47
|
+
Scan this code with Trie
|
|
85
48
|
```
|
|
86
49
|
|
|
87
|
-
|
|
50
|
+
Or use specific agents:
|
|
51
|
+
|
|
88
52
|
```
|
|
89
|
-
|
|
53
|
+
Run trie_security on this file
|
|
54
|
+
Run trie_soc2 to check compliance
|
|
90
55
|
```
|
|
91
56
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
1. **Generate code** with your AI assistant
|
|
95
|
-
2. **Scan for issues:**
|
|
96
|
-
```
|
|
97
|
-
Scan this with Trie Agent
|
|
98
|
-
```
|
|
99
|
-
3. **Review results** - Trie will show:
|
|
100
|
-
- Risk level and activated agents
|
|
101
|
-
- Critical issues requiring review
|
|
102
|
-
- Auto-fixable issues
|
|
103
|
-
- Plain-language explanations
|
|
104
|
-
4. **Apply fixes:**
|
|
105
|
-
```
|
|
106
|
-
Auto-fix the high-confidence issues
|
|
107
|
-
```
|
|
108
|
-
5. **Generate tests:**
|
|
109
|
-
```
|
|
110
|
-
Generate tests for this code
|
|
111
|
-
```
|
|
57
|
+
## Built-in Agents
|
|
112
58
|
|
|
113
|
-
|
|
59
|
+
| Agent | Description |
|
|
60
|
+
|-------|-------------|
|
|
61
|
+
| `security` | Vulnerabilities, injection risks, hardcoded secrets |
|
|
62
|
+
| `privacy` | GDPR, CCPA, PII handling, data protection |
|
|
63
|
+
| `soc2` | SOC 2 Type II compliance: access controls, encryption, logging |
|
|
64
|
+
| `legal` | Consent patterns, data retention, compliance |
|
|
65
|
+
| `architecture` | SOLID principles, code organization, scalability |
|
|
66
|
+
| `bugs` | Null safety, edge cases, async issues |
|
|
67
|
+
| `types` | Type errors, missing annotations |
|
|
68
|
+
| `devops` | Config issues, logging, environment variables |
|
|
69
|
+
| `accessibility` | WCAG 2.1, keyboard nav, screen readers |
|
|
70
|
+
| `ux` | User flow testing, error states |
|
|
71
|
+
| `clean` | AI-generated code cleanup |
|
|
72
|
+
| `test` | Test generation and coverage |
|
|
73
|
+
| `comprehension` | Plain-language explanations |
|
|
114
74
|
|
|
115
|
-
|
|
116
|
-
- **`trie_fix`** - Apply high-confidence fixes automatically
|
|
117
|
-
- **`trie_explain`** - Get plain-language explanations of code/issues
|
|
118
|
-
- **`trie_test`** - Generate tests or check coverage
|
|
119
|
-
- **`trie_commit`** - Create smart commit messages
|
|
120
|
-
- **`trie_register_agent`** - Add custom agents
|
|
75
|
+
## Custom Agents
|
|
121
76
|
|
|
122
|
-
|
|
77
|
+
Create specialized agents from any document:
|
|
123
78
|
|
|
124
|
-
|
|
79
|
+
```
|
|
80
|
+
Use trie_create_agent with filePath:"./style-guide.pdf" agentName:"my-style"
|
|
81
|
+
```
|
|
125
82
|
|
|
126
|
-
|
|
127
|
-
|----------|-------------|
|
|
128
|
-
| `trie://agents` | List all available agents |
|
|
129
|
-
| `trie://config` | Current configuration |
|
|
130
|
-
| `trie://cache/stats` | Cache performance metrics |
|
|
131
|
-
| `trie://signatures` | Vulnerability signature counts |
|
|
132
|
-
| `trie://reports/{file}` | Access scan reports |
|
|
83
|
+
Custom agents automatically activate during scans based on their rules.
|
|
133
84
|
|
|
134
|
-
|
|
85
|
+
## Available Tools
|
|
86
|
+
|
|
87
|
+
| Tool | Description |
|
|
88
|
+
|------|-------------|
|
|
89
|
+
| `trie_scan` | Intelligent scan with automatic agent selection |
|
|
90
|
+
| `trie_fix` | Apply high-confidence fixes |
|
|
91
|
+
| `trie_explain` | Plain-language explanations |
|
|
92
|
+
| `trie_watch` | Continuous scanning mode |
|
|
93
|
+
| `trie_create_agent` | Create custom agent from document |
|
|
94
|
+
| `trie_list_agents` | List all available agents |
|
|
95
|
+
|
|
96
|
+
Plus individual agent tools: `trie_security`, `trie_privacy`, `trie_soc2`, `trie_bugs`, etc.
|
|
135
97
|
|
|
136
98
|
## Example Output
|
|
137
99
|
|
|
138
100
|
```
|
|
139
|
-
|
|
101
|
+
TRIE AGENT SCAN
|
|
140
102
|
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
141
103
|
|
|
142
104
|
Smart Triaging:
|
|
143
105
|
✓ Risk Level: high
|
|
144
|
-
✓
|
|
145
|
-
✓
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
Critical Issues Preview:
|
|
156
|
-
1. Password stored without hashing (auth/signup.ts:23)
|
|
157
|
-
Agent: Security | Confidence: 100%
|
|
158
|
-
2. PII stored in plain text (models/user.ts:15)
|
|
159
|
-
Agent: Privacy | Confidence: 95%
|
|
106
|
+
✓ Agents activated: security, soc2, privacy, architecture
|
|
107
|
+
✓ Execution time: 3.2s
|
|
108
|
+
|
|
109
|
+
Results: 72/100
|
|
110
|
+
|
|
111
|
+
🔴 2 Critical Issues
|
|
112
|
+
• Hardcoded API key (CC6.1) - src/api.ts:15
|
|
113
|
+
• SQL injection risk - src/db.ts:42
|
|
114
|
+
|
|
115
|
+
🟡 3 Serious Issues (auto-fixable)
|
|
116
|
+
🔵 2 Moderate Issues
|
|
160
117
|
```
|
|
161
118
|
|
|
162
|
-
## Configuration
|
|
119
|
+
## Configuration
|
|
163
120
|
|
|
164
|
-
Create `.trie/config.json`
|
|
121
|
+
Create `.trie/config.json` to customize:
|
|
165
122
|
|
|
166
123
|
```json
|
|
167
124
|
{
|
|
168
|
-
"version": "1.0",
|
|
169
|
-
"triaging": {
|
|
170
|
-
"enabled": true,
|
|
171
|
-
"riskThresholds": {
|
|
172
|
-
"critical": 70,
|
|
173
|
-
"high": 40,
|
|
174
|
-
"medium": 20
|
|
175
|
-
},
|
|
176
|
-
"autoFixConfidence": 0.95
|
|
177
|
-
},
|
|
178
125
|
"agents": {
|
|
179
126
|
"builtin": {
|
|
180
127
|
"security": { "enabled": true },
|
|
181
|
-
"
|
|
182
|
-
"
|
|
183
|
-
"design-engineer": { "enabled": true }
|
|
128
|
+
"soc2": { "enabled": true },
|
|
129
|
+
"privacy": { "enabled": true }
|
|
184
130
|
}
|
|
131
|
+
},
|
|
132
|
+
"compliance": {
|
|
133
|
+
"standards": ["GDPR", "CCPA", "SOC2"]
|
|
185
134
|
}
|
|
186
135
|
}
|
|
187
136
|
```
|
|
188
137
|
|
|
189
|
-
##
|
|
190
|
-
|
|
191
|
-
### Agent not found
|
|
192
|
-
|
|
193
|
-
**Problem:** Can't find the Trie Agent executable
|
|
194
|
-
|
|
195
|
-
**Solution:** Make sure you have Node.js 18+ installed and try:
|
|
196
|
-
```bash
|
|
197
|
-
npx @triedotdev/mcp --help
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
### No agents activating
|
|
201
|
-
|
|
202
|
-
**Problem:** Scan runs but no agents are triggered
|
|
203
|
-
|
|
204
|
-
**Solution:**
|
|
205
|
-
- Check that your code matches patterns (auth, payments, UI, etc.)
|
|
206
|
-
- Review the triaging logic in `.trie/config.json`
|
|
207
|
-
- Try scanning a file with known issues (auth, payments, etc.)
|
|
208
|
-
|
|
209
|
-
### MCP connection fails
|
|
210
|
-
|
|
211
|
-
**Problem:** Can't connect to Trie Agent server
|
|
212
|
-
|
|
213
|
-
**Solution:**
|
|
214
|
-
1. Verify Node.js is installed: `node --version` (should be 18+)
|
|
215
|
-
2. Check the path in MCP config is correct
|
|
216
|
-
3. Restart your AI coding tool
|
|
217
|
-
4. Check console/logs for error messages
|
|
218
|
-
|
|
219
|
-
## Next Steps
|
|
220
|
-
|
|
221
|
-
- **Try different code patterns** - Test with auth, payments, UI components
|
|
222
|
-
- **Explore agents** - See which agents activate for different code types
|
|
223
|
-
- **Use auto-fix** - Let Trie fix high-confidence issues automatically
|
|
224
|
-
- **Generate tests** - Create comprehensive test suites
|
|
225
|
-
- **Add custom agents** - Extend Trie with your own review logic
|
|
226
|
-
|
|
227
|
-
## Support
|
|
138
|
+
## Links
|
|
228
139
|
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
140
|
+
- [Documentation](https://trie.dev/docs)
|
|
141
|
+
- [GitHub](https://github.com/Trie-OS/mcp-agent)
|
|
142
|
+
- [Discord](https://discord.gg/trie-ai)
|
|
232
143
|
|
|
233
|
-
|
|
144
|
+
## License
|
|
234
145
|
|
|
235
|
-
|
|
146
|
+
MIT
|
|
@@ -670,10 +670,9 @@ import { basename as basename3 } from "path";
|
|
|
670
670
|
var PRIVACY_INDICATORS = {
|
|
671
671
|
high: [
|
|
672
672
|
{ pattern: /email|phone|ssn|social.*security|passport|driver.*license/i, reason: "PII fields" },
|
|
673
|
-
{ pattern: /patient|medical|diagnosis|medication|treatment|symptom/i, reason: "PHI/health data" },
|
|
674
673
|
{ pattern: /credit.*card|card.*number|cvv|expiry/i, reason: "payment data" },
|
|
675
674
|
{ pattern: /password|credential|secret|token/i, reason: "credentials" },
|
|
676
|
-
{ pattern: /gdpr|
|
|
675
|
+
{ pattern: /gdpr|ccpa|coppa|consent/i, reason: "compliance mentions" }
|
|
677
676
|
],
|
|
678
677
|
medium: [
|
|
679
678
|
{ pattern: /user.*data|personal.*info|profile/i, reason: "user data" },
|
|
@@ -713,17 +712,16 @@ var CRITICAL_PRIVACY_PATTERNS = [
|
|
|
713
712
|
];
|
|
714
713
|
var PrivacyAgent = class extends BaseAgent {
|
|
715
714
|
name = "privacy";
|
|
716
|
-
description = "AI-powered privacy analysis: GDPR,
|
|
715
|
+
description = "AI-powered privacy analysis: GDPR, CCPA, PCI-DSS compliance";
|
|
717
716
|
version = "2.0.0";
|
|
718
717
|
shouldActivate(context) {
|
|
719
|
-
const hasHealthSignals = context.touchesHealthData;
|
|
720
718
|
const hasUserDataSignals = context.touchesUserData && (context.touchesDatabase || context.touchesAuth || context.patterns?.hasFormHandling || context.patterns?.hasEmailHandling || context.touchesThirdPartyAPI);
|
|
721
719
|
const fileNameSignals = context.filePatterns.some(
|
|
722
|
-
(pattern) => ["profile", "account", "customer", "member", "identity"
|
|
720
|
+
(pattern) => ["profile", "account", "customer", "member", "identity"].some(
|
|
723
721
|
(keyword) => pattern.includes(keyword)
|
|
724
722
|
)
|
|
725
723
|
);
|
|
726
|
-
return
|
|
724
|
+
return hasUserDataSignals || fileNameSignals && context.touchesDatabase;
|
|
727
725
|
}
|
|
728
726
|
/**
|
|
729
727
|
* Check file relevance for privacy analysis
|
|
@@ -771,8 +769,6 @@ Analyze code for privacy violations and data protection issues.
|
|
|
771
769
|
KEY REGULATIONS:
|
|
772
770
|
- **GDPR**: EU data protection (consent, data minimization, right to erasure)
|
|
773
771
|
- **CCPA**: California privacy (disclosure, opt-out, data access)
|
|
774
|
-
- **HIPAA**: Health data protection (PHI encryption, access controls)
|
|
775
|
-
- **COPPA**: Children's privacy (parental consent for under 13)
|
|
776
772
|
- **PCI DSS**: Payment card data security
|
|
777
773
|
|
|
778
774
|
FOCUS ON:
|
|
@@ -820,15 +816,6 @@ ${content}
|
|
|
820
816
|
- Is PII encrypted in transit?
|
|
821
817
|
- Is there data minimization (only collecting what's needed)?
|
|
822
818
|
- Are there proper access controls?`;
|
|
823
|
-
}
|
|
824
|
-
if (relevance.indicators.includes("PHI/health data")) {
|
|
825
|
-
prompt += `
|
|
826
|
-
|
|
827
|
-
### HIPAA Compliance (Health Data)
|
|
828
|
-
- Is PHI encrypted with AES-256 or equivalent?
|
|
829
|
-
- Are there audit logs for PHI access?
|
|
830
|
-
- Is there access control based on roles?
|
|
831
|
-
- Is there a breach notification mechanism?`;
|
|
832
819
|
}
|
|
833
820
|
if (relevance.indicators.includes("payment data")) {
|
|
834
821
|
prompt += `
|
|
@@ -838,14 +825,6 @@ ${content}
|
|
|
838
825
|
- Is CVV NOT being stored?
|
|
839
826
|
- Are there access controls?
|
|
840
827
|
- Is data properly tokenized?`;
|
|
841
|
-
}
|
|
842
|
-
if (relevance.indicators.includes("age data (COPPA)")) {
|
|
843
|
-
prompt += `
|
|
844
|
-
|
|
845
|
-
### COPPA Compliance (Children's Data)
|
|
846
|
-
- Is age verified before data collection?
|
|
847
|
-
- Is parental consent obtained for under 13?
|
|
848
|
-
- Is data from children handled specially?`;
|
|
849
828
|
}
|
|
850
829
|
if (relevance.indicators.includes("tracking") || relevance.indicators.includes("client storage")) {
|
|
851
830
|
prompt += `
|
|
@@ -1377,7 +1356,7 @@ var LegalAgent = class extends BaseAgent {
|
|
|
1377
1356
|
description = "Compliance with GDPR, CCPA, data protection laws, and legal requirements";
|
|
1378
1357
|
version = "1.0.0";
|
|
1379
1358
|
shouldActivate(context) {
|
|
1380
|
-
return context.touchesUserData || context.
|
|
1359
|
+
return context.touchesUserData || context.touchesPayments || context.touchesAuth;
|
|
1381
1360
|
}
|
|
1382
1361
|
async analyzeFiles(files, _context) {
|
|
1383
1362
|
const issues = [];
|
|
@@ -2752,6 +2731,182 @@ var TrieCleanAgent = class extends BaseAgent {
|
|
|
2752
2731
|
}
|
|
2753
2732
|
};
|
|
2754
2733
|
|
|
2734
|
+
// src/agents/soc2.ts
|
|
2735
|
+
var SOC2_PATTERNS = {
|
|
2736
|
+
// CC6 - Logical Access Controls
|
|
2737
|
+
hardcodedSecrets: [
|
|
2738
|
+
{ pattern: /['"]sk_live_[A-Za-z0-9]{20,}['"]/, issue: "Hardcoded Stripe live key", regulation: "CC6.1" },
|
|
2739
|
+
{ pattern: /['"]AKIA[A-Z0-9]{16}['"]/, issue: "Hardcoded AWS access key", regulation: "CC6.1" },
|
|
2740
|
+
{ pattern: /['"]ghp_[A-Za-z0-9]{36}['"]/, issue: "Hardcoded GitHub token", regulation: "CC6.1" },
|
|
2741
|
+
{ pattern: /password\s*[:=]\s*['"][^'"]{8,}['"](?!.*example|test|placeholder)/i, issue: "Hardcoded password", regulation: "CC6.1" },
|
|
2742
|
+
{ pattern: /api[_-]?key\s*[:=]\s*['"][A-Za-z0-9]{20,}['"]/i, issue: "Hardcoded API key", regulation: "CC6.1" },
|
|
2743
|
+
{ pattern: /secret\s*[:=]\s*['"][^'"]{16,}['"]/i, issue: "Hardcoded secret value", regulation: "CC6.1" }
|
|
2744
|
+
],
|
|
2745
|
+
// Missing access control
|
|
2746
|
+
accessControl: [
|
|
2747
|
+
{ pattern: /\/\/\s*TODO:?\s*(add|implement)?\s*(auth|access|permission)/i, issue: "Missing access control (TODO)", regulation: "CC6.2" },
|
|
2748
|
+
{ pattern: /isAdmin\s*[:=]\s*true|role\s*[:=]\s*['"]admin['"]/i, issue: "Hardcoded admin privilege", regulation: "CC6.3" }
|
|
2749
|
+
],
|
|
2750
|
+
// CC7 - System Operations (Logging & Monitoring)
|
|
2751
|
+
logging: [
|
|
2752
|
+
{ pattern: /console\.(log|error|warn)\s*\([^)]*password/i, issue: "Password logged to console", regulation: "CC7.2" },
|
|
2753
|
+
{ pattern: /console\.(log|error|warn)\s*\([^)]*token/i, issue: "Token logged to console", regulation: "CC7.2" },
|
|
2754
|
+
{ pattern: /console\.(log|error|warn)\s*\([^)]*secret/i, issue: "Secret logged to console", regulation: "CC7.2" },
|
|
2755
|
+
{ pattern: /console\.(log|error|warn)\s*\([^)]*apiKey/i, issue: "API key logged to console", regulation: "CC7.2" }
|
|
2756
|
+
],
|
|
2757
|
+
// Error handling
|
|
2758
|
+
errorHandling: [
|
|
2759
|
+
{ pattern: /catch\s*\([^)]*\)\s*\{\s*\}/, issue: "Empty catch block - errors silently swallowed", regulation: "CC7.3" },
|
|
2760
|
+
{ pattern: /catch\s*\([^)]*\)\s*\{\s*\/\//, issue: "Catch block only has comments", regulation: "CC7.3" },
|
|
2761
|
+
{ pattern: /\.catch\s*\(\s*\(\s*\)\s*=>\s*\{\s*\}\s*\)/, issue: "Empty .catch() handler", regulation: "CC7.3" }
|
|
2762
|
+
],
|
|
2763
|
+
// CC8 - Change Management (implicit through code patterns)
|
|
2764
|
+
changeManagement: [
|
|
2765
|
+
{ pattern: /\/\/\s*HACK|\/\/\s*FIXME.*security|\/\/\s*XXX/i, issue: "Security-related HACK/FIXME comment", regulation: "CC8.1" },
|
|
2766
|
+
{ pattern: /\/\/\s*temporary|\/\/\s*remove\s*(before|in)\s*prod/i, issue: "Temporary code flagged for removal", regulation: "CC8.1" }
|
|
2767
|
+
],
|
|
2768
|
+
// Security - Encryption
|
|
2769
|
+
encryption: [
|
|
2770
|
+
{ pattern: /md5\s*\(|crypto\.createHash\s*\(\s*['"]md5['"]\s*\)/i, issue: "MD5 is cryptographically broken", regulation: "CC6.7" },
|
|
2771
|
+
{ pattern: /sha1\s*\(|crypto\.createHash\s*\(\s*['"]sha1['"]\s*\)/i, issue: "SHA1 is deprecated for security use", regulation: "CC6.7" },
|
|
2772
|
+
{ pattern: /DES|3DES|RC4|Blowfish/i, issue: "Weak/deprecated encryption algorithm", regulation: "CC6.7" },
|
|
2773
|
+
{ pattern: /Math\.random\s*\(\s*\).*(?:token|key|secret|password|id)/i, issue: "Math.random() used for security-sensitive value", regulation: "CC6.7" }
|
|
2774
|
+
],
|
|
2775
|
+
// Security - Input validation
|
|
2776
|
+
inputValidation: [
|
|
2777
|
+
{ pattern: /eval\s*\(\s*(?:req\.|request\.|params\.|query\.)/i, issue: "eval() with user input - code injection risk", regulation: "CC6.6" },
|
|
2778
|
+
{ pattern: /innerHTML\s*=\s*(?:req\.|request\.|params\.|data\.)/i, issue: "innerHTML with unescaped user input - XSS risk", regulation: "CC6.6" },
|
|
2779
|
+
{ pattern: /exec\s*\(\s*(?:req\.|request\.|params\.|`)/i, issue: "Command execution with user input", regulation: "CC6.6" },
|
|
2780
|
+
{ pattern: /\$\{.*\}.*(?:SELECT|INSERT|UPDATE|DELETE)/i, issue: "SQL query with string interpolation", regulation: "CC6.6" }
|
|
2781
|
+
],
|
|
2782
|
+
// Security - Authentication
|
|
2783
|
+
authentication: [
|
|
2784
|
+
{ pattern: /jwt\.sign\s*\([^)]*expiresIn:\s*['"]?\d{6,}['"]?/i, issue: "JWT with very long expiration", regulation: "CC6.1" },
|
|
2785
|
+
{ pattern: /verify\s*[:=]\s*false|rejectUnauthorized\s*[:=]\s*false/i, issue: "TLS/SSL verification disabled", regulation: "CC6.7" },
|
|
2786
|
+
{ pattern: /sameSite\s*[:=]\s*['"]none['"]/i, issue: "Cookie SameSite=None may enable CSRF", regulation: "CC6.1" },
|
|
2787
|
+
{ pattern: /httpOnly\s*[:=]\s*false/i, issue: "Cookie httpOnly disabled - XSS risk", regulation: "CC6.1" },
|
|
2788
|
+
{ pattern: /secure\s*[:=]\s*false.*cookie/i, issue: "Cookie secure flag disabled", regulation: "CC6.1" }
|
|
2789
|
+
]
|
|
2790
|
+
};
|
|
2791
|
+
var REGULATION_DESCRIPTIONS = {
|
|
2792
|
+
"CC6.1": "Logical Access Security - Access controls and authentication",
|
|
2793
|
+
"CC6.2": "Role-Based Access Control - Segregation of duties",
|
|
2794
|
+
"CC6.3": "Least Privilege - Minimal necessary access rights",
|
|
2795
|
+
"CC6.6": "Protection Against Threats - Input validation and injection prevention",
|
|
2796
|
+
"CC6.7": "Data Protection - Encryption and secure transmission",
|
|
2797
|
+
"CC7.2": "Monitoring - Security event logging without sensitive data exposure",
|
|
2798
|
+
"CC7.3": "Incident Detection - Proper error handling and alerting",
|
|
2799
|
+
"CC8.1": "Change Management - Controlled changes with proper review"
|
|
2800
|
+
};
|
|
2801
|
+
var SOC2Agent = class extends BaseAgent {
|
|
2802
|
+
name = "soc2";
|
|
2803
|
+
description = "SOC 2 Type II compliance: access controls, encryption, logging, change management";
|
|
2804
|
+
version = "1.0.0";
|
|
2805
|
+
shouldActivate(context) {
|
|
2806
|
+
return context.touchesAuth || context.touchesAPI || context.touchesDatabase || context.touchesUserData || context.touchesSecurityConfig || context.touchesLogging;
|
|
2807
|
+
}
|
|
2808
|
+
async analyzeFiles(files, _context) {
|
|
2809
|
+
const issues = [];
|
|
2810
|
+
for (const file of files) {
|
|
2811
|
+
if (/node_modules|\.d\.ts$|\.min\.|dist\/|build\/|\.test\.|\.spec\./i.test(file)) {
|
|
2812
|
+
continue;
|
|
2813
|
+
}
|
|
2814
|
+
try {
|
|
2815
|
+
const content = await this.readFile(file);
|
|
2816
|
+
const lines = content.split("\n");
|
|
2817
|
+
for (const [category, patterns] of Object.entries(SOC2_PATTERNS)) {
|
|
2818
|
+
for (const { pattern, issue, regulation } of patterns) {
|
|
2819
|
+
for (let i = 0; i < lines.length; i++) {
|
|
2820
|
+
const line = lines[i] || "";
|
|
2821
|
+
if (pattern.test(line)) {
|
|
2822
|
+
if (this.isTestOrExample(line, content)) {
|
|
2823
|
+
continue;
|
|
2824
|
+
}
|
|
2825
|
+
const severity = this.getSeverity(category, regulation);
|
|
2826
|
+
const regulationDesc = REGULATION_DESCRIPTIONS[regulation] || regulation;
|
|
2827
|
+
issues.push(this.createIssue(
|
|
2828
|
+
this.generateIssueId(),
|
|
2829
|
+
severity,
|
|
2830
|
+
`[SOC 2 ${regulation}] ${issue}`,
|
|
2831
|
+
this.getFix(category, issue),
|
|
2832
|
+
file,
|
|
2833
|
+
i + 1,
|
|
2834
|
+
this.getConfidence(category),
|
|
2835
|
+
`SOC 2 ${regulation}: ${regulationDesc}`,
|
|
2836
|
+
this.isAutoFixable(category)
|
|
2837
|
+
));
|
|
2838
|
+
break;
|
|
2839
|
+
}
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
}
|
|
2843
|
+
} catch (error) {
|
|
2844
|
+
console.error(`SOC2 Agent: Error reading file ${file}:`, error);
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
return issues;
|
|
2848
|
+
}
|
|
2849
|
+
isTestOrExample(line, content) {
|
|
2850
|
+
if (/example|test|mock|fake|dummy|placeholder|sample/i.test(line)) {
|
|
2851
|
+
return true;
|
|
2852
|
+
}
|
|
2853
|
+
if (/describe\s*\(|it\s*\(|test\s*\(|jest|mocha|vitest/i.test(content.slice(0, 500))) {
|
|
2854
|
+
return true;
|
|
2855
|
+
}
|
|
2856
|
+
return false;
|
|
2857
|
+
}
|
|
2858
|
+
getSeverity(category, regulation) {
|
|
2859
|
+
if (category === "hardcodedSecrets" || regulation === "CC6.6") {
|
|
2860
|
+
return "critical";
|
|
2861
|
+
}
|
|
2862
|
+
if (category === "encryption" || category === "logging" || category === "authentication") {
|
|
2863
|
+
return "serious";
|
|
2864
|
+
}
|
|
2865
|
+
if (category === "accessControl" || category === "errorHandling") {
|
|
2866
|
+
return "moderate";
|
|
2867
|
+
}
|
|
2868
|
+
return "low";
|
|
2869
|
+
}
|
|
2870
|
+
getConfidence(category) {
|
|
2871
|
+
switch (category) {
|
|
2872
|
+
case "hardcodedSecrets":
|
|
2873
|
+
return 0.95;
|
|
2874
|
+
case "logging":
|
|
2875
|
+
return 0.9;
|
|
2876
|
+
case "encryption":
|
|
2877
|
+
return 0.85;
|
|
2878
|
+
case "inputValidation":
|
|
2879
|
+
return 0.85;
|
|
2880
|
+
case "authentication":
|
|
2881
|
+
return 0.8;
|
|
2882
|
+
case "errorHandling":
|
|
2883
|
+
return 0.75;
|
|
2884
|
+
case "accessControl":
|
|
2885
|
+
return 0.7;
|
|
2886
|
+
case "changeManagement":
|
|
2887
|
+
return 0.6;
|
|
2888
|
+
default:
|
|
2889
|
+
return 0.7;
|
|
2890
|
+
}
|
|
2891
|
+
}
|
|
2892
|
+
isAutoFixable(category) {
|
|
2893
|
+
return category === "errorHandling";
|
|
2894
|
+
}
|
|
2895
|
+
getFix(category, issue) {
|
|
2896
|
+
const fixes = {
|
|
2897
|
+
hardcodedSecrets: "Move secrets to environment variables or a secrets manager (e.g., HashiCorp Vault, AWS Secrets Manager)",
|
|
2898
|
+
accessControl: "Implement proper RBAC with dynamic role checking. Never hardcode admin privileges.",
|
|
2899
|
+
logging: "Remove sensitive data from logs. Use structured logging with PII filtering.",
|
|
2900
|
+
errorHandling: "Add proper error handling: log the error, notify monitoring, and return safe error messages.",
|
|
2901
|
+
encryption: "Use strong algorithms: AES-256-GCM for encryption, SHA-256+ for hashing, crypto.randomBytes() for random values.",
|
|
2902
|
+
inputValidation: "Validate and sanitize all user input. Use parameterized queries for SQL. Escape HTML output.",
|
|
2903
|
+
authentication: "Use secure cookie settings (httpOnly, secure, sameSite). Set reasonable JWT expiration (15min-24h).",
|
|
2904
|
+
changeManagement: "Address security-related TODOs before deployment. Document in issue tracker if deferring."
|
|
2905
|
+
};
|
|
2906
|
+
return fixes[category] || "Review and fix according to SOC 2 requirements.";
|
|
2907
|
+
}
|
|
2908
|
+
};
|
|
2909
|
+
|
|
2755
2910
|
// src/agents/custom-agent.ts
|
|
2756
2911
|
var CustomAgent = class extends BaseAgent {
|
|
2757
2912
|
name;
|
|
@@ -2983,7 +3138,8 @@ var AgentRegistry = class {
|
|
|
2983
3138
|
new DevOpsAgent(),
|
|
2984
3139
|
new BugFindingAgent(),
|
|
2985
3140
|
new UserTestingAgent(),
|
|
2986
|
-
new TrieCleanAgent()
|
|
3141
|
+
new TrieCleanAgent(),
|
|
3142
|
+
new SOC2Agent()
|
|
2987
3143
|
];
|
|
2988
3144
|
console.error(`Loaded config for ${builtinAgents.length} built-in agents`);
|
|
2989
3145
|
for (const agent of builtinAgents) {
|
|
@@ -3870,10 +4026,6 @@ var Triager = class {
|
|
|
3870
4026
|
confidence += 0.5;
|
|
3871
4027
|
reasons.push("PII handling");
|
|
3872
4028
|
}
|
|
3873
|
-
if (context.touchesHealthData) {
|
|
3874
|
-
confidence += 0.6;
|
|
3875
|
-
reasons.push("PHI/HIPAA");
|
|
3876
|
-
}
|
|
3877
4029
|
if (context.touchesAuth) {
|
|
3878
4030
|
confidence += 0.3;
|
|
3879
4031
|
reasons.push("credentials");
|
|
@@ -3893,10 +4045,6 @@ var Triager = class {
|
|
|
3893
4045
|
}
|
|
3894
4046
|
if (agent.name === "legal") {
|
|
3895
4047
|
tier = 2;
|
|
3896
|
-
if (context.touchesHealthData) {
|
|
3897
|
-
confidence += 0.6;
|
|
3898
|
-
reasons.push("HIPAA compliance");
|
|
3899
|
-
}
|
|
3900
4048
|
if (context.touchesUserData) {
|
|
3901
4049
|
confidence += 0.4;
|
|
3902
4050
|
reasons.push("GDPR/CCPA");
|
|
@@ -4059,6 +4207,29 @@ var Triager = class {
|
|
|
4059
4207
|
reasons.push("React code");
|
|
4060
4208
|
}
|
|
4061
4209
|
}
|
|
4210
|
+
if (agent.name === "soc2") {
|
|
4211
|
+
tier = 2;
|
|
4212
|
+
if (context.touchesAuth) {
|
|
4213
|
+
confidence += 0.4;
|
|
4214
|
+
reasons.push("authentication");
|
|
4215
|
+
}
|
|
4216
|
+
if (context.touchesSecurityConfig) {
|
|
4217
|
+
confidence += 0.4;
|
|
4218
|
+
reasons.push("security config");
|
|
4219
|
+
}
|
|
4220
|
+
if (context.touchesLogging) {
|
|
4221
|
+
confidence += 0.3;
|
|
4222
|
+
reasons.push("logging");
|
|
4223
|
+
}
|
|
4224
|
+
if (context.touchesAPI) {
|
|
4225
|
+
confidence += 0.25;
|
|
4226
|
+
reasons.push("API endpoints");
|
|
4227
|
+
}
|
|
4228
|
+
if (context.touchesDatabase) {
|
|
4229
|
+
confidence += 0.2;
|
|
4230
|
+
reasons.push("data access");
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4062
4233
|
confidence = Math.min(1, confidence);
|
|
4063
4234
|
return { agent, confidence, reasons, tier, isCustom: false };
|
|
4064
4235
|
}
|
|
@@ -4121,7 +4292,6 @@ var Triager = class {
|
|
|
4121
4292
|
if (context.touchesPayments) reasons.push("payments");
|
|
4122
4293
|
if (context.touchesDatabase) reasons.push("database");
|
|
4123
4294
|
if (context.touchesUserData) reasons.push("user data");
|
|
4124
|
-
if (context.touchesHealthData) reasons.push("PHI");
|
|
4125
4295
|
if (context.touchesUI) reasons.push("UI");
|
|
4126
4296
|
if (context.touchesAPI) reasons.push("API");
|
|
4127
4297
|
if (context.isNewFeature) reasons.push("new feature");
|
|
@@ -6270,6 +6440,16 @@ var TrieScanTool = class {
|
|
|
6270
6440
|
agentRegistry = new AgentRegistry();
|
|
6271
6441
|
incrementalScanner = null;
|
|
6272
6442
|
progress = new ProgressReporter();
|
|
6443
|
+
customAgentsLoaded = false;
|
|
6444
|
+
/**
|
|
6445
|
+
* Ensure custom agents are loaded before using the registry
|
|
6446
|
+
*/
|
|
6447
|
+
async ensureCustomAgentsLoaded() {
|
|
6448
|
+
if (!this.customAgentsLoaded) {
|
|
6449
|
+
await this.agentRegistry.loadCustomAgents();
|
|
6450
|
+
this.customAgentsLoaded = true;
|
|
6451
|
+
}
|
|
6452
|
+
}
|
|
6273
6453
|
async execute(args) {
|
|
6274
6454
|
const startTime = Date.now();
|
|
6275
6455
|
try {
|
|
@@ -6328,6 +6508,7 @@ var TrieScanTool = class {
|
|
|
6328
6508
|
const riskLevel = this.riskAssessor.assessRisk(context);
|
|
6329
6509
|
this.logRiskAssessment(context, riskLevel);
|
|
6330
6510
|
this.progress.startPhase("ai-review", "Selecting AI agents...");
|
|
6511
|
+
await this.ensureCustomAgentsLoaded();
|
|
6331
6512
|
const selectedAgents = forceAgents ? this.agentRegistry.getAgentsByNames(forceAgents) : await this.triager.selectAgents(context, riskLevel);
|
|
6332
6513
|
const allAgentNames = this.agentRegistry.getAgentNames();
|
|
6333
6514
|
this.logTriaging(selectedAgents.map((a) => a.name), allAgentNames, context, riskLevel);
|
|
@@ -7612,4 +7793,4 @@ export {
|
|
|
7612
7793
|
getSystemPrompt,
|
|
7613
7794
|
TrieFixTool
|
|
7614
7795
|
};
|
|
7615
|
-
//# sourceMappingURL=chunk-
|
|
7796
|
+
//# sourceMappingURL=chunk-77JFVVWF.js.map
|