@sliday/tamp 0.4.7 → 0.4.8
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/compress.js +25 -1
- package/package.json +1 -1
package/compress.js
CHANGED
|
@@ -140,11 +140,25 @@ async function textpressCompress(text, config) {
|
|
|
140
140
|
// Try Ollama first (local, free, no rate limits)
|
|
141
141
|
const ollamaUrl = config.textpressOllamaUrl || 'http://localhost:11434'
|
|
142
142
|
const ollamaModel = config.textpressOllamaModel || 'qwen3.5:0.8b'
|
|
143
|
+
|
|
144
|
+
// SSRF protection: only allow localhost URLs
|
|
145
|
+
let validatedUrl
|
|
146
|
+
try {
|
|
147
|
+
const parsed = new URL(ollamaUrl)
|
|
148
|
+
const hostname = parsed.hostname.toLowerCase()
|
|
149
|
+
if (hostname !== 'localhost' && hostname !== '127.0.0.1' && hostname !== '::1' && !hostname.startsWith('127.')) {
|
|
150
|
+
return null
|
|
151
|
+
}
|
|
152
|
+
validatedUrl = parsed
|
|
153
|
+
} catch {
|
|
154
|
+
return null
|
|
155
|
+
}
|
|
156
|
+
|
|
143
157
|
try {
|
|
144
158
|
const controller = new AbortController()
|
|
145
159
|
const timeout = setTimeout(() => controller.abort(), 15000)
|
|
146
160
|
try {
|
|
147
|
-
const res = await fetch(`${
|
|
161
|
+
const res = await fetch(`${validatedUrl}/api/chat`, {
|
|
148
162
|
method: 'POST',
|
|
149
163
|
headers: { 'Content-Type': 'application/json' },
|
|
150
164
|
body: JSON.stringify({
|
|
@@ -300,6 +314,16 @@ async function compressWithLLMLingua(text, config) {
|
|
|
300
314
|
async function compressWithFoundationModels(text, config) {
|
|
301
315
|
if (!config.foundationModelsPath) return null
|
|
302
316
|
|
|
317
|
+
// Validate foundationModelsPath to prevent command injection
|
|
318
|
+
const cmdPath = config.foundationModelsPath
|
|
319
|
+
// Allow only simple command names (no path separators) or absolute paths
|
|
320
|
+
if (cmdPath.includes('/') || cmdPath.includes('\\')) {
|
|
321
|
+
// If it contains path separators, must be an absolute path
|
|
322
|
+
if (!cmdPath.startsWith('/')) {
|
|
323
|
+
return null
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
303
327
|
const SYSTEM_PROMPT = config.foundationModelsSystemPrompt ||
|
|
304
328
|
'Compress this text to 50% length while preserving all key information and meaning. Return only the compressed text without explanation.'
|
|
305
329
|
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"providers.js",
|
|
11
11
|
"stats.js"
|
|
12
12
|
],
|
|
13
|
-
"version": "0.4.
|
|
13
|
+
"version": "0.4.8",
|
|
14
14
|
"description": "Token compression proxy for coding agents. Works with Claude Code, Aider, Cursor, Cline, Windsurf. 52.6% fewer input tokens.",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"main": "index.js",
|