wormclaude 1.0.199 → 1.0.201
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/dist/theme.js +1 -1
- package/dist/tools.js +65 -4
- package/package.json +1 -1
package/dist/theme.js
CHANGED
package/dist/tools.js
CHANGED
|
@@ -770,6 +770,18 @@ async function execOne(call, hooks) {
|
|
|
770
770
|
if (!['recon', 'scan', 'xss', 'sqli', 'dirscan', 'idor', 'portscan', 'osint', 'cloud', 'cloudscan', 'spray', 'credspray', 'defaultcreds', 'full', 'fullscan', 'auto', 'pentest'].includes(tool) || !target) {
|
|
771
771
|
return { ok: false, output: 'SecurityScan: tool (recon|scan|xss|sqli|dirscan|full) ve target gerekli.', args };
|
|
772
772
|
}
|
|
773
|
+
// YEREL HEDEF KORUMASI: SecurityScan canlı URL/domain içindir. Model yerel bir DOSYA/YOL'u
|
|
774
|
+
// (cmd.exe, C:\..., ./klasör, *.exe/.py) yanlışlıkla tarama hedefi sanıp çöp tarama + döngü
|
|
775
|
+
// yapıyordu → reddet, dosya OKUMAK için Read/Glob/Grep'e yönlendir.
|
|
776
|
+
{
|
|
777
|
+
const _hostPart = target.replace(/^https?:\/\//i, '').split(/[/?#]/)[0];
|
|
778
|
+
const _isLocalPath = /^[a-zA-Z]:[\\/]/.test(target) || /^[.~]?[\\/]/.test(target) || /^\.{1,2}$/.test(target);
|
|
779
|
+
const _isExe = /\.(exe|dll|bat|cmd|ps1|msi|app|dmg|bin|sys|so|jar|py|js|ts|tsx|jsx|rb|go|php|java|cpp|cs|html?|css|scss|json|md|txt|ya?ml|sh|sql|vue|svelte|xml|env|lock|toml|ini|cfg)$/i.test(_hostPart);
|
|
780
|
+
const _hasDomain = /[a-z0-9-]+\.[a-z]{2,}/i.test(_hostPart) && !_isExe;
|
|
781
|
+
if (_isLocalPath || _isExe || !_hasDomain) {
|
|
782
|
+
return { ok: false, args, output: `SecurityScan canlı bir URL/domain hedefi içindir (örn. https://site.com). "${target}" yerel bir dosya/yol veya geçersiz hedef görünüyor — dosyaların İÇERİĞİNİ okumak için Read/Glob/Grep araçlarını kullan (SecurityScan DEĞİL). Kod güvenliği için /audit (CodeAudit) kullan.` };
|
|
783
|
+
}
|
|
784
|
+
}
|
|
773
785
|
if (tool === 'scan')
|
|
774
786
|
tool = 'recon'; // "scan" genel tarama → motorun bildiği "recon" (slash ile aynı)
|
|
775
787
|
// AUTHENTICATED / login-arkası: kullanıcı session cookie / auth header verdiyse her isteğe enjekte
|
|
@@ -1249,6 +1261,44 @@ const TYPE_EXT = {
|
|
|
1249
1261
|
};
|
|
1250
1262
|
// ── Executor ──────────────────────────────────────────────────────────────────
|
|
1251
1263
|
// Edit/Write icin +/- satir ozeti (Diff paketiyle).
|
|
1264
|
+
// Adapter artığı temizle: küçük modeller değeri <![CDATA[ ... ]]> ile sarabiliyor (gateway de
|
|
1265
|
+
// temizliyor ama istemci-tarafı garanti — dosyayı bozmasın).
|
|
1266
|
+
function stripCdata(s) {
|
|
1267
|
+
let t = s;
|
|
1268
|
+
if (t.startsWith('<![CDATA['))
|
|
1269
|
+
t = t.slice(9);
|
|
1270
|
+
if (t.endsWith(']]>'))
|
|
1271
|
+
t = t.slice(0, -3);
|
|
1272
|
+
return t;
|
|
1273
|
+
}
|
|
1274
|
+
// Boşluk/girinti-toleranslı blok eşleşme: old_string dosyada BİREBİR yoksa (model exact metni
|
|
1275
|
+
// üretemedi — küçük-model klasiği), satırları trim'leyip BENZERSIZ bir blok ara → dosyanın GERÇEK
|
|
1276
|
+
// metnini döndür (replace bununla yapılır, dosya geçerli kalır). null = yok/belirsiz.
|
|
1277
|
+
function fuzzyBlockMatch(content, needle) {
|
|
1278
|
+
const nLines = needle.replace(/^\n+/, '').replace(/\n+$/, '').split('\n');
|
|
1279
|
+
if (nLines.length === 0 || (nLines.length === 1 && !nLines[0].trim()))
|
|
1280
|
+
return null;
|
|
1281
|
+
const cLines = content.split('\n');
|
|
1282
|
+
const key = (l) => l.trim();
|
|
1283
|
+
let foundAt = -1, foundCount = 0;
|
|
1284
|
+
for (let i = 0; i + nLines.length <= cLines.length; i++) {
|
|
1285
|
+
let ok = true;
|
|
1286
|
+
for (let k = 0; k < nLines.length; k++) {
|
|
1287
|
+
if (key(cLines[i + k]) !== key(nLines[k])) {
|
|
1288
|
+
ok = false;
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
if (ok) {
|
|
1293
|
+
if (foundCount === 0)
|
|
1294
|
+
foundAt = i;
|
|
1295
|
+
foundCount++;
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
if (foundCount !== 1)
|
|
1299
|
+
return null; // bulunamadı VEYA birden çok (belirsiz) → güvenli taraf
|
|
1300
|
+
return cLines.slice(foundAt, foundAt + nLines.length).join('\n');
|
|
1301
|
+
}
|
|
1252
1302
|
function diffStat(oldStr, newStr) {
|
|
1253
1303
|
try {
|
|
1254
1304
|
let added = 0, removed = 0;
|
|
@@ -1431,12 +1481,23 @@ export async function executeTool(name, args) {
|
|
|
1431
1481
|
return { ok: false, output: `Error: file does not exist: ${fp}` };
|
|
1432
1482
|
if (!readFiles.has(norm(fp)))
|
|
1433
1483
|
return { ok: false, output: 'Error: you must use the Read tool on this file before editing it.' };
|
|
1434
|
-
|
|
1435
|
-
const newStr = String(args.new_string ?? '');
|
|
1484
|
+
let oldStr = stripCdata(String(args.old_string ?? '')); // CDATA artığını temizle
|
|
1485
|
+
const newStr = stripCdata(String(args.new_string ?? ''));
|
|
1436
1486
|
if (oldStr === newStr)
|
|
1437
1487
|
return { ok: false, output: 'Error: new_string must differ from old_string.' };
|
|
1438
1488
|
let c = fs.readFileSync(fp, 'utf8');
|
|
1439
|
-
|
|
1489
|
+
let count = oldStr ? c.split(oldStr).length - 1 : 0;
|
|
1490
|
+
let _fuzzy = '';
|
|
1491
|
+
// EXACT-MATCH KURTARMA: birebir bulunamadıysa boşluk/girinti-toleranslı blok eşleşmesi dene
|
|
1492
|
+
// (küçük model exact metni üretemiyor → hard-fail yerine gerçek bloğu bul ve onu değiştir).
|
|
1493
|
+
if (count === 0 && oldStr && !args.replace_all) {
|
|
1494
|
+
const fz = fuzzyBlockMatch(c, oldStr);
|
|
1495
|
+
if (fz) {
|
|
1496
|
+
oldStr = fz;
|
|
1497
|
+
count = c.split(oldStr).length - 1;
|
|
1498
|
+
_fuzzy = ' (boşluk-toleranslı eşleşme)';
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1440
1501
|
if (count === 0)
|
|
1441
1502
|
return { ok: false, output: 'Error: old_string not found in file.' };
|
|
1442
1503
|
if (count > 1 && !args.replace_all)
|
|
@@ -1448,7 +1509,7 @@ export async function executeTool(name, args) {
|
|
|
1448
1509
|
recordCheckpoint(fp, _ebefore, 'Edit'); // rewind: düzenleme öncesi tam içerik
|
|
1449
1510
|
c = args.replace_all ? c.split(oldStr).join(newStr) : c.replace(oldStr, newStr);
|
|
1450
1511
|
fs.writeFileSync(fp, c);
|
|
1451
|
-
return { ok: true, output: `Edited ${fp}${args.replace_all ? ` (${count} occurrences)` : ''}${diffStat(_ebefore, c)}` };
|
|
1512
|
+
return { ok: true, output: `Edited ${fp}${args.replace_all ? ` (${count} occurrences)` : ''}${_fuzzy}${diffStat(_ebefore, c)}` };
|
|
1452
1513
|
}
|
|
1453
1514
|
if (name === 'Glob') {
|
|
1454
1515
|
const base = args.path ? resolveWs(args.path) : getBashCwd();
|