deepspider 0.3.0 → 0.3.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/package.json +1 -1
- package/src/agent/core/PanelBridge.js +2 -2
- package/src/agent/logger.js +1 -1
- package/src/agent/middleware/report.js +1 -1
- package/src/agent/skills/evolve.js +0 -3
- package/src/agent/tools/captcha.js +1 -1
- package/src/agent/tools/evolve.js +1 -1
- package/src/agent/tools/file.js +2 -2
- package/src/agent/tools/python.js +4 -4
- package/src/agent/tools/report.js +2 -2
- package/src/agent/tools/runtime.js +1 -1
- package/src/analyzer/EncryptionAnalyzer.js +2 -2
- package/src/browser/collector.js +1 -1
- package/src/browser/interceptors/NetworkInterceptor.js +1 -1
- package/src/browser/interceptors/ScriptInterceptor.js +2 -2
- package/src/core/PatchGenerator.js +2 -2
- package/src/env/EnvCodeGenerator.js +1 -1
- package/src/store/DataStore.js +5 -5
package/package.json
CHANGED
|
@@ -53,7 +53,7 @@ export class PanelBridge {
|
|
|
53
53
|
const escaped = JSON.stringify(content.trim());
|
|
54
54
|
const code = `window.__deepspider__?.addMessage?.('${role}', ${escaped})`;
|
|
55
55
|
await this.evaluateInPage(code);
|
|
56
|
-
} catch
|
|
56
|
+
} catch {
|
|
57
57
|
// ignore
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -110,7 +110,7 @@ export class PanelBridge {
|
|
|
110
110
|
})()`;
|
|
111
111
|
await this.evaluateInPage(code);
|
|
112
112
|
}
|
|
113
|
-
} catch
|
|
113
|
+
} catch {
|
|
114
114
|
// ignore
|
|
115
115
|
}
|
|
116
116
|
|
package/src/agent/logger.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { BaseCallbackHandler } from '@langchain/core/callbacks/base';
|
|
7
7
|
import { appendFileSync, mkdirSync, existsSync } from 'fs';
|
|
8
|
-
import { join
|
|
8
|
+
import { join } from 'path';
|
|
9
9
|
import { DEEPSPIDER_HOME } from '../config/paths.js';
|
|
10
10
|
|
|
11
11
|
const LOG_DIR = join(DEEPSPIDER_HOME, 'logs');
|
|
@@ -106,7 +106,7 @@ export const captchaSlideDetect = tool(
|
|
|
106
106
|
|
|
107
107
|
// 获取背景图和滑块图
|
|
108
108
|
const bgElement = await page.$(bg_selector);
|
|
109
|
-
const
|
|
109
|
+
const _slideElement = slide_selector ? await page.$(slide_selector) : null;
|
|
110
110
|
|
|
111
111
|
if (!bgElement) {
|
|
112
112
|
return JSON.stringify({ success: false, error: '未找到背景图' });
|
package/src/agent/tools/file.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { tool } from '@langchain/core/tools';
|
|
8
|
-
import { writeFileSync, readFileSync, existsSync, readdirSync
|
|
8
|
+
import { writeFileSync, readFileSync, existsSync, readdirSync } from 'fs';
|
|
9
9
|
import { dirname, join, isAbsolute, relative } from 'path';
|
|
10
10
|
import { PATHS, ensureDir, DEEPSPIDER_HOME } from '../../config/paths.js';
|
|
11
11
|
|
|
@@ -186,7 +186,7 @@ function searchInFile(filePath, pattern, isRegex) {
|
|
|
186
186
|
if (isRegex) regex.lastIndex = 0; // 重置正则
|
|
187
187
|
}
|
|
188
188
|
return matches;
|
|
189
|
-
} catch
|
|
189
|
+
} catch {
|
|
190
190
|
return [];
|
|
191
191
|
}
|
|
192
192
|
}
|
|
@@ -53,7 +53,7 @@ async function executePython(code, timeout = 10000) {
|
|
|
53
53
|
* 生成 Python 验证代码
|
|
54
54
|
*/
|
|
55
55
|
function generateVerifyCode(algorithm, params) {
|
|
56
|
-
const { plaintext, ciphertext, key, iv,
|
|
56
|
+
const { plaintext, ciphertext, key, iv, _mode, format, hmacKey, digestmod } = params;
|
|
57
57
|
|
|
58
58
|
const templates = {
|
|
59
59
|
// AES
|
|
@@ -223,7 +223,7 @@ print('MATCH' if result == expected else f'MISMATCH: got {result}')
|
|
|
223
223
|
* 生成可复用的 Python 代码片段
|
|
224
224
|
*/
|
|
225
225
|
function generatePythonSnippet(algorithm, params) {
|
|
226
|
-
const { key, iv,
|
|
226
|
+
const { key, iv, _mode, _format, hmacKey, digestmod } = params;
|
|
227
227
|
|
|
228
228
|
const snippets = {
|
|
229
229
|
'AES-CBC': `
|
|
@@ -488,7 +488,7 @@ export const executePythonCode = tool(
|
|
|
488
488
|
export const generateExecjsCode = tool(
|
|
489
489
|
async ({ jsCode, functionName, description }) => {
|
|
490
490
|
// 转义 JS 代码中的特殊字符
|
|
491
|
-
const
|
|
491
|
+
const _escapedJs = jsCode
|
|
492
492
|
.replace(/\\/g, '\\\\')
|
|
493
493
|
.replace(/"""/g, '\\"\\"\\"')
|
|
494
494
|
.replace(/\n/g, '\\n');
|
|
@@ -539,7 +539,7 @@ def ${functionName || 'execute_js'}(*args):
|
|
|
539
539
|
* 分析 JS 代码,判断转换策略
|
|
540
540
|
*/
|
|
541
541
|
export const analyzeJsForPython = tool(
|
|
542
|
-
async ({ jsCode, cryptoPatterns }) => {
|
|
542
|
+
async ({ jsCode, cryptoPatterns: _cryptoPatterns }) => {
|
|
543
543
|
const analysis = {
|
|
544
544
|
canPureRewrite: true,
|
|
545
545
|
reasons: [],
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { tool } from '@langchain/core/tools';
|
|
9
9
|
import { writeFileSync, readFileSync, existsSync } from 'fs';
|
|
10
|
-
import { join
|
|
11
|
-
import { PATHS, ensureDir
|
|
10
|
+
import { join } from 'path';
|
|
11
|
+
import { PATHS, ensureDir } from '../../config/paths.js';
|
|
12
12
|
|
|
13
13
|
const OUTPUT_DIR = PATHS.REPORTS_DIR;
|
|
14
14
|
|
|
@@ -110,7 +110,7 @@ export const addInitScript = tool(
|
|
|
110
110
|
* 清除 Cookie
|
|
111
111
|
*/
|
|
112
112
|
export const clearCookies = tool(
|
|
113
|
-
async ({ domain }) => {
|
|
113
|
+
async ({ domain: _domain }) => {
|
|
114
114
|
const browser = await getBrowser();
|
|
115
115
|
const context = browser.getContext();
|
|
116
116
|
await context.clearCookies();
|
|
@@ -51,7 +51,7 @@ export class EncryptionAnalyzer {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
traceParam(code, paramName) {
|
|
54
|
-
const
|
|
54
|
+
const _ast = this.astAnalyzer.parse(code);
|
|
55
55
|
const traces = [];
|
|
56
56
|
|
|
57
57
|
// 简化实现:查找参数使用位置
|
|
@@ -80,7 +80,7 @@ export class EncryptionAnalyzer {
|
|
|
80
80
|
// 使用模式库进行深度检测
|
|
81
81
|
detectWithPatterns(code) {
|
|
82
82
|
const detected = [];
|
|
83
|
-
for (const [
|
|
83
|
+
for (const [_key, pattern] of Object.entries(cryptoPatterns)) {
|
|
84
84
|
for (const sig of pattern.signatures) {
|
|
85
85
|
if (sig.test(code)) {
|
|
86
86
|
detected.push({
|
package/src/browser/collector.js
CHANGED
|
@@ -21,7 +21,7 @@ export class EnvCollector {
|
|
|
21
21
|
return this.cache.get(path);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const result = await this.page.evaluate(({ path, depth, includeProto }) => {
|
|
24
|
+
const result = await this.page.evaluate(({ path, depth, includeProto: _includeProto }) => {
|
|
25
25
|
function getByPath(obj, path) {
|
|
26
26
|
return path.split('.').reduce((o, k) => o && o[k], obj);
|
|
27
27
|
}
|
|
@@ -38,7 +38,7 @@ export class ScriptInterceptor {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
async onScriptParsed(params) {
|
|
41
|
-
const { scriptId, url, length } = params;
|
|
41
|
+
const { scriptId, url, length: _length } = params;
|
|
42
42
|
|
|
43
43
|
// 跳过扩展和空脚本
|
|
44
44
|
if (!url || url.startsWith('chrome-extension://')) return;
|
|
@@ -67,7 +67,7 @@ export class ScriptInterceptor {
|
|
|
67
67
|
timestamp: Date.now(),
|
|
68
68
|
pageUrl: this.getPageUrl() // 传递页面 URL
|
|
69
69
|
});
|
|
70
|
-
} catch
|
|
70
|
+
} catch {
|
|
71
71
|
// 获取失败,跳过
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -169,7 +169,7 @@ export class PatchGenerator {
|
|
|
169
169
|
return defaults[type] || 'undefined';
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
_generateSmartTemplate(property,
|
|
172
|
+
_generateSmartTemplate(property, _context = {}) {
|
|
173
173
|
const parts = property.split('.');
|
|
174
174
|
const propName = parts[parts.length - 1];
|
|
175
175
|
const type = this._inferType(property);
|
|
@@ -232,7 +232,7 @@ export class PatchGenerator {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
// 检测同一对象的重复定义
|
|
235
|
-
for (const [
|
|
235
|
+
for (const [_root, props] of roots) {
|
|
236
236
|
if (props.length > 1) {
|
|
237
237
|
const seen = new Set();
|
|
238
238
|
for (const p of props) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 根据 Hook 收集的数据生成可在 Node.js 运行的浏览器环境代码
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import { GETSET_LIST, FUNC_LIST, HTML_TAG_MAP } from './BrowserAPIList.js';
|
|
7
|
+
import { GETSET_LIST, FUNC_LIST, HTML_TAG_MAP } from './BrowserAPIList.js'; // eslint-disable-line no-unused-vars
|
|
8
8
|
|
|
9
9
|
export class EnvCodeGenerator {
|
|
10
10
|
constructor() {
|
package/src/store/DataStore.js
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* 支持会话隔离、内容去重、自动清理
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import { writeFile, readFile,
|
|
7
|
+
import { existsSync, readFileSync } from 'fs';
|
|
8
|
+
import { writeFile, readFile, rm } from 'fs/promises';
|
|
9
9
|
import { join } from 'path';
|
|
10
10
|
import { createHash } from 'crypto';
|
|
11
11
|
import { PATHS, ensureDir } from '../config/paths.js';
|
|
@@ -201,7 +201,7 @@ export class DataStore {
|
|
|
201
201
|
if (existsSync(indexFile)) {
|
|
202
202
|
index = JSON.parse(readFileSync(indexFile, 'utf-8'));
|
|
203
203
|
}
|
|
204
|
-
} catch
|
|
204
|
+
} catch {
|
|
205
205
|
// 使用默认索引
|
|
206
206
|
}
|
|
207
207
|
|
|
@@ -446,7 +446,7 @@ export class DataStore {
|
|
|
446
446
|
timestamp: meta.timestamp
|
|
447
447
|
});
|
|
448
448
|
}
|
|
449
|
-
} catch
|
|
449
|
+
} catch { /* skip */ }
|
|
450
450
|
}
|
|
451
451
|
}
|
|
452
452
|
return results;
|
|
@@ -477,7 +477,7 @@ export class DataStore {
|
|
|
477
477
|
timestamp: meta.timestamp
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
|
-
} catch
|
|
480
|
+
} catch { /* skip */ }
|
|
481
481
|
}
|
|
482
482
|
}
|
|
483
483
|
return results;
|