bugx-cli 0.1.1 → 0.1.3
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 +36 -35
- package/core/README.md +1 -1
- package/core/agent/agent_orchestrator.py +3 -0
- package/core/agent/agent_workspace.py +14 -2
- package/core/assets/README.md +3 -2
- package/core/assets/bugx-social-preview.svg +71 -0
- package/core/assets/bugx-wechat-group.png +0 -0
- package/core/assets/twitter_promo_art.jpg +0 -0
- package/core/assets/twitter_promo_card.svg +166 -0
- package/core/assets/twitter_promo_clean.jpg +0 -0
- package/core/assets/twitter_terminal_real.png +0 -0
- package/core/audit_packs/README.md +2 -0
- package/core/audit_packs/pitfalls/auth_crypto.json +64 -0
- package/core/audit_packs/pitfalls/file_ssrf_cmd.json +64 -0
- package/core/audit_packs/pitfalls/go_backend.json +66 -0
- package/core/audit_packs/pitfalls/java_spring.json +64 -0
- package/core/audit_packs/pitfalls/js_ts_web.json +67 -0
- package/core/audit_packs/pitfalls/python_web.json +82 -0
- package/core/bugx.md +2 -2
- package/core/bugx_paths.py +2 -2
- package/core/cli-help.txt +1 -1
- package/core/cloud_sync/cloud_client.py +56 -5
- package/core/cloud_sync/consent.py +33 -3
- package/core/cloud_sync/flywheel_client.py +186 -24
- package/core/contracts/README.md +1 -1
- package/core/contracts/bugx-opencode.md +1 -1
- package/core/contracts/bugx-runtime-contract.md +1 -1
- package/core/contracts/bugx-worker.md +1 -1
- package/core/engine-integrity.json +191 -95
- package/core/host_acp/kimi.py +175 -0
- package/core/host_acp/minimax.py +28 -0
- package/core/host_runtime/host_registry.py +23 -3
- package/core/hosts/dsh.py +1 -1
- package/core/hosts/kimi.py +293 -0
- package/core/hosts/minimax.py +248 -0
- package/core/hosts/zcode.py +5 -0
- package/core/infra/README.md +1 -1
- package/core/infra/build_info.py +30 -5
- package/core/launch_phases/README.md +6 -3
- package/core/launch_phases/finding_confirm_phase.py +168 -7
- package/core/launch_phases/post_phase.py +5 -5
- package/core/launch_phases/pre_recon_scout.py +13 -0
- package/core/launch_phases/report_sharing.py +3 -7
- package/core/launch_phases/round_orchestrator.py +114 -26
- package/core/launch_phases/semantic_recon.py +545 -0
- package/core/launch_phases/startup_version_gate.py +6 -2
- package/core/launch_phases/supervisor_bridge.py +14 -23
- package/core/launch_phases/verify_loop.py +767 -0
- package/core/launch_phases/worker_prior.py +115 -0
- package/core/ledger/README.md +2 -1
- package/core/ledger/finding_verification.py +511 -2
- package/core/ledger/fp_ledger.py +255 -0
- package/core/metadata.txt +2 -2
- package/core/planning/README.md +2 -1
- package/core/planning/prompt_harness.py +50 -10
- package/core/planning/prompt_policy_engine.py +386 -0
- package/core/prompts/README.md +4 -2
- package/core/prompts/policies/prompt_policies.json +101 -0
- package/core/prompts/stages/stage_verify.defensive.md +42 -0
- package/core/prompts/stages/stage_verify.md +44 -0
- package/core/report_engine/report_share.py +0 -8
- package/core/retrieval/README.md +2 -1
- package/core/retrieval/pitfall_packs.py +277 -0
- package/core/runtime/README.md +1 -1
- package/core/runtime/global_telemetry.py +20 -0
- package/core/runtime/scenario_eval.py +1 -1
- package/core/runtime/setup_ui_env.py +4 -7
- package/core/supervisor/README.md +1 -1
- package/core/supervisor/cli.py +2 -2
- package/core/webui/mcp_inspector.py +6 -0
- package/core/webui/static/index.html +51 -3
- package/core/webui/static/manifest.webmanifest +1 -1
- package/core/webui/static/project-settings.js +18 -3
- package/core/webui/static/robots.txt +36 -0
- package/core/webui/static/sitemap.xml +15 -0
- package/docs/07_distribution/01_README_NPM.md +36 -35
- package/ecosystem/integrations/cline/skills/bugx/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/agents/bugx.md +1 -1
- package/ecosystem/integrations/dsh/dsh-patch.yml +2 -2
- package/ecosystem/integrations/dsh/mcp/package.json +1 -1
- package/ecosystem/integrations/dsh/skills/bugx/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/integrations/dsh/ui/package.json +1 -1
- package/ecosystem/integrations/opencode/bugx-mcp-manifest.json +1 -1
- package/ecosystem/integrations/pi/extensions/bugx/manifest.json +1 -1
- package/ecosystem/integrations/pi/skills/bugx/SKILL.md +1 -1
- package/ecosystem/integrations/qoder/connector-meta.json +9 -9
- package/ecosystem/integrations/workbuddy/connector-meta.json +9 -9
- package/ecosystem/integrations/workbuddy/skills/bugx/SKILL.md +2 -2
- package/ecosystem/plugins/bugx/.claude-plugin/marketplace.json +2 -2
- package/ecosystem/plugins/bugx/.claude-plugin/plugin.json +2 -2
- package/ecosystem/plugins/bugx/.codex-plugin/plugin.json +4 -4
- package/ecosystem/plugins/bugx/.zcode-plugin/plugin.json +2 -2
- package/ecosystem/plugins/bugx/agents/bugx-worker.md +1 -1
- package/ecosystem/plugins/bugx/agents/bugx.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx/SKILL.md +3 -3
- package/ecosystem/plugins/bugx/skills/bugx-claude/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-dsh/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-opencode/SKILL.md +1 -1
- package/ecosystem/plugins/bugx/skills/bugx-zcode/SKILL.md +1 -1
- package/interfaces/bin/bugx.js +9 -7
- package/interfaces/cli/bugx_cli/__init__.py +2 -2
- package/interfaces/cli/bugx_cli/cli.py +178 -67
- package/interfaces/cli/bugx_cli/commands/agent.py +313 -127
- package/interfaces/cli/bugx_cli/commands/audit.py +8 -7
- package/interfaces/cli/bugx_cli/commands/cloud.py +27 -19
- package/interfaces/cli/bugx_cli/commands/doctor.py +18 -0
- package/interfaces/cli/bugx_cli/commands/knowledge.py +3 -4
- package/interfaces/cli/bugx_cli/commands/lifecycle.py +54 -47
- package/interfaces/cli/bugx_cli/commands/plugin.py +9 -9
- package/interfaces/cli/bugx_cli/commands/plugin_claude.py +27 -13
- package/interfaces/cli/bugx_cli/commands/plugin_kimi.py +348 -0
- package/interfaces/cli/bugx_cli/commands/plugin_minimax.py +322 -0
- package/interfaces/cli/bugx_cli/commands/plugin_qoder.py +3 -4
- package/interfaces/cli/bugx_cli/commands/plugin_zcode.py +4 -5
- package/interfaces/cli/bugx_cli/commands/project.py +6 -13
- package/interfaces/cli/bugx_cli/commands/system.py +577 -162
- package/interfaces/cli/bugx_cli/common.py +102 -15
- package/interfaces/cli/bugx_cli/host_adapters.py +150 -4
- package/interfaces/cli/bugx_cli/hosts/registry.py +4 -2
- package/interfaces/cli/bugx_cli/hosts/template_engine.py +10 -9
- package/interfaces/cli/bugx_cli/infra/engine_installer.py +21 -10
- package/interfaces/cli/bugx_cli/infra/host_sync.py +1 -1
- package/interfaces/cli/bugx_cli/infra/mcp_advisor.py +2 -2
- package/package.json +54 -16
- package/pyproject.toml +64 -1
- package/scripts/sync-version.mjs +1 -1
- package/skills/README.md +25 -0
- package/skills/platform/bugx-user/SKILL.md +92 -0
- package/core/assets/bugx-hero-cn.png +0 -0
- package/core/assets/bugx-hero-en.png +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pack_id": "file_ssrf_cmd",
|
|
3
|
+
"schema_version": 1,
|
|
4
|
+
"description": "跨语言文件系统、SSRF 与命令注入冷启动漏洞先验包",
|
|
5
|
+
"pitfalls": [
|
|
6
|
+
{
|
|
7
|
+
"pitfall_id": "IO-PATH-001",
|
|
8
|
+
"cwe": "CWE-22",
|
|
9
|
+
"severity": "high",
|
|
10
|
+
"languages": ["*"],
|
|
11
|
+
"frameworks": ["*"],
|
|
12
|
+
"surfaces": ["file", "http", "api", "storage"],
|
|
13
|
+
"title": "未做规范化前缀校验的路径拼接导致目录穿越或同前缀逃逸",
|
|
14
|
+
"anti_pattern_signals": ["os.path.join(", "Path(", "open(", "send_file(", "readFile(", "startswith("],
|
|
15
|
+
"false_positive_guards": [
|
|
16
|
+
"使用 resolve().relative_to(base.resolve()) 且拦截符号链接组件",
|
|
17
|
+
"startswith 校验包含尾部分隔符 os.sep 且先经 realpath 规范化"
|
|
18
|
+
],
|
|
19
|
+
"poc_skeleton": "传入 `../target_sibling/secret` 或 `../../etc/hosts`,验证是否绕过目录限制"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"pitfall_id": "IO-CMD-002",
|
|
23
|
+
"cwe": "CWE-78",
|
|
24
|
+
"severity": "critical",
|
|
25
|
+
"languages": ["*"],
|
|
26
|
+
"frameworks": ["*"],
|
|
27
|
+
"surfaces": ["cli", "api", "process", "http"],
|
|
28
|
+
"title": "subprocess(shell=True) / os.system / child_process.exec 拼接非受信参数",
|
|
29
|
+
"anti_pattern_signals": ["shell=True", "os.system(", "os.popen(", "child_process.exec(", "exec.Command(\"sh\"", "Runtime.getRuntime().exec("],
|
|
30
|
+
"false_positive_guards": [
|
|
31
|
+
"使用 argv 数组形式且 shell=False,并对参数做严格字符白名单校验"
|
|
32
|
+
],
|
|
33
|
+
"poc_skeleton": "传入带命令分隔符的无害标记参数,验证是否触发预期外命令解析"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"pitfall_id": "IO-SSRF-003",
|
|
37
|
+
"cwe": "CWE-918",
|
|
38
|
+
"severity": "high",
|
|
39
|
+
"languages": ["*"],
|
|
40
|
+
"frameworks": ["*"],
|
|
41
|
+
"surfaces": ["http", "webhook", "api", "network"],
|
|
42
|
+
"title": "服务端按用户提供 URL 发起 HTTP 请求未拦截回环/私网/云元数据地址(SSRF)",
|
|
43
|
+
"anti_pattern_signals": ["requests.get(", "httpx.", "urllib.request.urlopen(", "fetch(", "axios.get(", "http.Get("],
|
|
44
|
+
"false_positive_guards": [
|
|
45
|
+
"解析 DNS 后校验所有解析 IP 非私网/回环/链路本地(169.254.169.254),且禁用自动重定向或对每跳重验"
|
|
46
|
+
],
|
|
47
|
+
"poc_skeleton": "传入本地回环测试端点或 `http://169.254.169.254/`,断言服务端直接发出请求且未拒绝私网 IP"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"pitfall_id": "IO-ZIPSLIP-004",
|
|
51
|
+
"cwe": "CWE-22",
|
|
52
|
+
"severity": "high",
|
|
53
|
+
"languages": ["*"],
|
|
54
|
+
"frameworks": ["*"],
|
|
55
|
+
"surfaces": ["file", "archive", "upload"],
|
|
56
|
+
"title": "zipfile.extractall / tarfile.extractall 未校验归档成员路径(Zip Slip)",
|
|
57
|
+
"anti_pattern_signals": ["extractall(", "tarfile.open(", "zipfile.ZipFile(", "unzip"],
|
|
58
|
+
"false_positive_guards": [
|
|
59
|
+
"逐成员校验 resolved.relative_to(dest) 并拒绝符号链接/硬链接(Python 3.12+ filter='data')"
|
|
60
|
+
],
|
|
61
|
+
"poc_skeleton": "构造包含 `../escape.txt` 成员的内存归档,调用解压函数验证文件写到目标目录外"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pack_id": "go_backend",
|
|
3
|
+
"schema_version": 1,
|
|
4
|
+
"description": "Go 后端冷启动漏洞先验包(net/http / Gin / GORM / 并发竞态)",
|
|
5
|
+
"pitfalls": [
|
|
6
|
+
{
|
|
7
|
+
"pitfall_id": "GO-SQLI-001",
|
|
8
|
+
"cwe": "CWE-89",
|
|
9
|
+
"severity": "critical",
|
|
10
|
+
"languages": ["go"],
|
|
11
|
+
"frameworks": ["gin", "gorm", "net/http", "echo"],
|
|
12
|
+
"surfaces": ["http", "api", "database"],
|
|
13
|
+
"title": "GORM Where/Order/Raw 使用 fmt.Sprintf 拼接用户输入",
|
|
14
|
+
"anti_pattern_signals": ["fmt.Sprintf(", ".Where(", ".Raw(", ".Order(", "db.Query("],
|
|
15
|
+
"false_positive_guards": [
|
|
16
|
+
"使用占位符参数 db.Where('name = ?', input)",
|
|
17
|
+
"Order 列名经 map 白名单映射后再拼接"
|
|
18
|
+
],
|
|
19
|
+
"poc_skeleton": "传入带 SQL 语法边界符的参数(如 `id; DROP` 或 `1 OR 1=1`),验证生成 SQL 改变查询语义"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"pitfall_id": "GO-PATH-002",
|
|
23
|
+
"cwe": "CWE-22",
|
|
24
|
+
"severity": "high",
|
|
25
|
+
"languages": ["go"],
|
|
26
|
+
"frameworks": ["gin", "net/http", "echo"],
|
|
27
|
+
"surfaces": ["http", "file", "api"],
|
|
28
|
+
"title": "filepath.Join 拼接用户路径未校验前缀边界(路径穿越)",
|
|
29
|
+
"anti_pattern_signals": ["filepath.Join(", "os.ReadFile(", "c.File(", "http.ServeFile("],
|
|
30
|
+
"false_positive_guards": [
|
|
31
|
+
"使用 filepath.Rel 后验证结果不以 '..' 开头且非绝对路径,或使用 os.Root (Go 1.24+)",
|
|
32
|
+
"仅允许匹配 ^[a-zA-Z0-9_-]+$ 的单段文件名"
|
|
33
|
+
],
|
|
34
|
+
"poc_skeleton": "传入 `../../etc/passwd` 或同前缀目录逃逸 `../base_secret/a`,验证突破 baseDir 约束"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"pitfall_id": "GO-RACE-003",
|
|
38
|
+
"cwe": "CWE-362",
|
|
39
|
+
"severity": "high",
|
|
40
|
+
"languages": ["go"],
|
|
41
|
+
"frameworks": ["gin", "net/http", "grpc"],
|
|
42
|
+
"surfaces": ["concurrency", "api", "state"],
|
|
43
|
+
"title": "无锁并发读写共享 map 或检查-后-使用(TOCTOU)竞态",
|
|
44
|
+
"anti_pattern_signals": ["go func(", "make(map[", "sync.Mutex", "balance", "quota"],
|
|
45
|
+
"false_positive_guards": [
|
|
46
|
+
"共享状态全程受 sync.Mutex / sync.RWMutex 或 sync.Map / channel 单写者保护",
|
|
47
|
+
"余额/配额扣减在数据库事务中使用原子条件更新 WHERE balance >= ?"
|
|
48
|
+
],
|
|
49
|
+
"poc_skeleton": "使用 `go test -race` 并发触发多个 goroutine 访问同一处理器,观测 data race 或超扣"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"pitfall_id": "GO-TEMPLATE-004",
|
|
53
|
+
"cwe": "CWE-79",
|
|
54
|
+
"severity": "medium",
|
|
55
|
+
"languages": ["go"],
|
|
56
|
+
"frameworks": ["gin", "net/http"],
|
|
57
|
+
"surfaces": ["web", "http", "template"],
|
|
58
|
+
"title": "使用 text/template 渲染 HTML 或将非受信输入强转为 template.HTML",
|
|
59
|
+
"anti_pattern_signals": ["text/template", "template.HTML(", "template.JS(", "template.URL("],
|
|
60
|
+
"false_positive_guards": [
|
|
61
|
+
"使用 html/template 且未对用户输入做 template.HTML 类型强转"
|
|
62
|
+
],
|
|
63
|
+
"poc_skeleton": "向模板变量注入 `<script>1</script>`,验证输出 HTML 未被自动实体转义"
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pack_id": "java_spring",
|
|
3
|
+
"schema_version": 1,
|
|
4
|
+
"description": "Java / Spring Boot 冷启动漏洞先验包(MyBatis / SpEL / Jackson / XXE)",
|
|
5
|
+
"pitfalls": [
|
|
6
|
+
{
|
|
7
|
+
"pitfall_id": "JAVA-MYBATIS-001",
|
|
8
|
+
"cwe": "CWE-89",
|
|
9
|
+
"severity": "critical",
|
|
10
|
+
"languages": ["java", "kotlin"],
|
|
11
|
+
"frameworks": ["spring", "springboot", "mybatis"],
|
|
12
|
+
"surfaces": ["http", "api", "database"],
|
|
13
|
+
"title": "MyBatis Mapper 中使用 ${...} 字符串插值导致 SQL 注入",
|
|
14
|
+
"anti_pattern_signals": ["${", "@Select(", "order by ${", "like '%${"],
|
|
15
|
+
"false_positive_guards": [
|
|
16
|
+
"使用预编译占位符 #{param}",
|
|
17
|
+
"${column} 传入前经过枚举/白名单映射"
|
|
18
|
+
],
|
|
19
|
+
"poc_skeleton": "向 ORDER BY / LIKE 参数传入 SQL 注释或布尔表达式,对比响应差异"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"pitfall_id": "JAVA-SPEL-002",
|
|
23
|
+
"cwe": "CWE-917",
|
|
24
|
+
"severity": "critical",
|
|
25
|
+
"languages": ["java", "kotlin"],
|
|
26
|
+
"frameworks": ["spring", "springboot"],
|
|
27
|
+
"surfaces": ["http", "api", "expression"],
|
|
28
|
+
"title": "SpelExpressionParser 解析非受信表达式且使用 StandardEvaluationContext",
|
|
29
|
+
"anti_pattern_signals": ["SpelExpressionParser", "parseExpression(", "StandardEvaluationContext"],
|
|
30
|
+
"false_positive_guards": [
|
|
31
|
+
"使用 SimpleEvaluationContext.forReadOnlyDataBinding() 禁止类型/构造器解析"
|
|
32
|
+
],
|
|
33
|
+
"poc_skeleton": "传入 `T(java.lang.Math).abs(-7)` 验证类型解析被求值为 7"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"pitfall_id": "JAVA-JACKSON-003",
|
|
37
|
+
"cwe": "CWE-502",
|
|
38
|
+
"severity": "critical",
|
|
39
|
+
"languages": ["java", "kotlin"],
|
|
40
|
+
"frameworks": ["spring", "springboot", "jackson"],
|
|
41
|
+
"surfaces": ["http", "api", "json"],
|
|
42
|
+
"title": "Jackson enableDefaultTyping / activateDefaultTyping(LaissezFaireSubTypeValidator) 多态反序列化",
|
|
43
|
+
"anti_pattern_signals": ["enableDefaultTyping(", "LaissezFaireSubTypeValidator", "@JsonTypeInfo"],
|
|
44
|
+
"false_positive_guards": [
|
|
45
|
+
"使用 BasicPolymorphicTypeValidator 显式限制允许基类/包白名单"
|
|
46
|
+
],
|
|
47
|
+
"poc_skeleton": "提交包含非预期 `@class` 类型标签的 JSON,验证反序列化实例化任意类"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"pitfall_id": "JAVA-XXE-004",
|
|
51
|
+
"cwe": "CWE-611",
|
|
52
|
+
"severity": "high",
|
|
53
|
+
"languages": ["java", "kotlin"],
|
|
54
|
+
"frameworks": ["spring", "springboot", "jaxp"],
|
|
55
|
+
"surfaces": ["http", "api", "xml"],
|
|
56
|
+
"title": "DocumentBuilderFactory / SAXParserFactory 未禁用外部实体解析(XXE)",
|
|
57
|
+
"anti_pattern_signals": ["DocumentBuilderFactory.newInstance(", "SAXParserFactory.newInstance(", "XMLInputFactory.newInstance("],
|
|
58
|
+
"false_positive_guards": [
|
|
59
|
+
"显式设置 disallow-doctype-decl=true 与 external-general-entities=false"
|
|
60
|
+
],
|
|
61
|
+
"poc_skeleton": "提交含本地无害实体声明的 DOCTYPE XML,验证解析器展开外部/内部实体"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pack_id": "js_ts_web",
|
|
3
|
+
"schema_version": 1,
|
|
4
|
+
"description": "JavaScript / TypeScript Web 冷启动漏洞先验包(Express / Next.js / React / Node)",
|
|
5
|
+
"pitfalls": [
|
|
6
|
+
{
|
|
7
|
+
"pitfall_id": "JS-PROTO-001",
|
|
8
|
+
"cwe": "CWE-1321",
|
|
9
|
+
"severity": "high",
|
|
10
|
+
"languages": ["javascript", "typescript"],
|
|
11
|
+
"frameworks": ["express", "nextjs", "node"],
|
|
12
|
+
"surfaces": ["http", "api", "json"],
|
|
13
|
+
"title": "递归对象合并/路径赋值未拦截 __proto__ / constructor.prototype(原型污染)",
|
|
14
|
+
"anti_pattern_signals": ["__proto__", "Object.assign", "deepMerge", "merge(", "for (const key in", "target[key] ="],
|
|
15
|
+
"false_positive_guards": [
|
|
16
|
+
"显式跳过 key === '__proto__' || key === 'constructor' || key === 'prototype'",
|
|
17
|
+
"目标对象使用 Object.create(null) 或 Map 存储动态键"
|
|
18
|
+
],
|
|
19
|
+
"poc_skeleton": "传入 JSON `{\"__proto__\": {\"polluted\": true}}` 经合并函数处理后检查 `({}).polluted === true`"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"pitfall_id": "JS-XSS-002",
|
|
23
|
+
"cwe": "CWE-79",
|
|
24
|
+
"severity": "high",
|
|
25
|
+
"languages": ["javascript", "typescript"],
|
|
26
|
+
"frameworks": ["react", "nextjs", "vue", "express"],
|
|
27
|
+
"surfaces": ["web", "ui", "http"],
|
|
28
|
+
"title": "dangerouslySetInnerHTML / innerHTML / javascript: URL 未经净化",
|
|
29
|
+
"anti_pattern_signals": ["dangerouslySetInnerHTML", "innerHTML", "v-html", "res.send(", "window.location ="],
|
|
30
|
+
"false_positive_guards": [
|
|
31
|
+
"经过 DOMPurify.sanitize() 且禁止 javascript:/data: 协议",
|
|
32
|
+
"URL 经 new URL() 解析并严格限制 protocol 为 http:/https:"
|
|
33
|
+
],
|
|
34
|
+
"poc_skeleton": "传入 `<img src=x onerror=alert(1)>` 或 `javascript:alert(1)`,验证输出未转义或协议未拦截"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"pitfall_id": "JS-NOSQLI-003",
|
|
38
|
+
"cwe": "CWE-943",
|
|
39
|
+
"severity": "critical",
|
|
40
|
+
"languages": ["javascript", "typescript"],
|
|
41
|
+
"frameworks": ["express", "nextjs", "node", "mongoose"],
|
|
42
|
+
"surfaces": ["http", "api", "database"],
|
|
43
|
+
"title": "req.body / req.query 对象直接传入 MongoDB findOne(NoSQL 运算符注入)",
|
|
44
|
+
"anti_pattern_signals": ["findOne(", "find(", "req.body", "req.query", "$ne", "$gt", "$regex"],
|
|
45
|
+
"false_positive_guards": [
|
|
46
|
+
"输入经 zod/joi 强类型校验为 string(String(val) 或 typeof val === 'string')",
|
|
47
|
+
"开启 sanitizeFilter 或过滤 `$` 开头键"
|
|
48
|
+
],
|
|
49
|
+
"poc_skeleton": "登录或查询接口传入 `{\"password\": {\"$ne\": \"\"}}`,验证绕过校验返回首条记录"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"pitfall_id": "JS-OPENREDIRECT-004",
|
|
53
|
+
"cwe": "CWE-601",
|
|
54
|
+
"severity": "medium",
|
|
55
|
+
"languages": ["javascript", "typescript"],
|
|
56
|
+
"frameworks": ["express", "nextjs", "node"],
|
|
57
|
+
"surfaces": ["http", "web", "auth"],
|
|
58
|
+
"title": "res.redirect / NextResponse.redirect 直接跳转外部非受信 URL",
|
|
59
|
+
"anti_pattern_signals": ["res.redirect(", "NextResponse.redirect(", "returnUrl", "next=", "redirect_uri"],
|
|
60
|
+
"false_positive_guards": [
|
|
61
|
+
"仅允许单斜杠相对路径(startswith('/') 且不以 '//' 开头且不含反斜杠)",
|
|
62
|
+
"解析 host 严格命中固定域名白名单"
|
|
63
|
+
],
|
|
64
|
+
"poc_skeleton": "传入 `next=//evil.example` 或 `next=https://evil.example`,断言响应 Location 指向外部域"
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pack_id": "python_web",
|
|
3
|
+
"schema_version": 1,
|
|
4
|
+
"description": "Python Web & ORM 冷启动漏洞先验包(FastAPI / Django / Flask / SQLAlchemy / Jinja2 / Pickle)",
|
|
5
|
+
"pitfalls": [
|
|
6
|
+
{
|
|
7
|
+
"pitfall_id": "PY-SQLI-001",
|
|
8
|
+
"cwe": "CWE-89",
|
|
9
|
+
"severity": "critical",
|
|
10
|
+
"languages": ["python"],
|
|
11
|
+
"frameworks": ["fastapi", "django", "flask", "sqlalchemy"],
|
|
12
|
+
"surfaces": ["http", "api", "database"],
|
|
13
|
+
"title": "ORM text()/raw()/extra() 字符串拼接导致 SQL 注入",
|
|
14
|
+
"anti_pattern_signals": ["text(f\"", "text(\"", ".raw(f\"", ".extra(", "cursor.execute(f\"", "execute(\"SELECT", "%s\" %", ".format("],
|
|
15
|
+
"false_positive_guards": [
|
|
16
|
+
"使用绑定参数 text('... :id').bindparams(id=val) 或 cursor.execute(sql, (val,))",
|
|
17
|
+
"拼接项来自硬编码白名单映射(如 ALLOWED_SORT_COLS[col])"
|
|
18
|
+
],
|
|
19
|
+
"poc_skeleton": "向查询参数传入 `' OR '1'='1` 或布尔盲注条件,对比合法输入与注入输入的返回行数/结果集差异"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"pitfall_id": "PY-SSTI-002",
|
|
23
|
+
"cwe": "CWE-1336",
|
|
24
|
+
"severity": "critical",
|
|
25
|
+
"languages": ["python"],
|
|
26
|
+
"frameworks": ["flask", "fastapi", "django", "jinja2"],
|
|
27
|
+
"surfaces": ["http", "web", "template"],
|
|
28
|
+
"title": "Jinja2 Template/render_template_string 直接渲染非受信用户输入(SSTI)",
|
|
29
|
+
"anti_pattern_signals": ["render_template_string(", "Template(", "from_string(", "Environment("],
|
|
30
|
+
"false_positive_guards": [
|
|
31
|
+
"模板字符串为常量,用户输入仅作为上下文变量传入(render_template_string(CONST, name=user_input))",
|
|
32
|
+
"使用 SandboxedEnvironment 且严格限制对象属性访问"
|
|
33
|
+
],
|
|
34
|
+
"poc_skeleton": "传入 `{{7*7}}` 验证算术求值被渲染为 `49`;负对照传入纯文本 `hello` 原样输出"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"pitfall_id": "PY-DESER-003",
|
|
38
|
+
"cwe": "CWE-502",
|
|
39
|
+
"severity": "critical",
|
|
40
|
+
"languages": ["python"],
|
|
41
|
+
"frameworks": ["fastapi", "django", "flask", "celery"],
|
|
42
|
+
"surfaces": ["http", "api", "cache", "queue"],
|
|
43
|
+
"title": "对非受信字节流调用 pickle.loads / yaml.load(不安全反序列化)",
|
|
44
|
+
"anti_pattern_signals": ["pickle.loads(", "pickle.load(", "yaml.load(", "marshal.loads(", "shelve.open("],
|
|
45
|
+
"false_positive_guards": [
|
|
46
|
+
"yaml.safe_load 或显式指定 Loader=yaml.SafeLoader",
|
|
47
|
+
"输入先经过 HMAC-SHA256 强签名验证(hmac.compare_digest)且密钥未泄露"
|
|
48
|
+
],
|
|
49
|
+
"poc_skeleton": "构造最小 `__reduce__` payload(无害标记对象或环境变量探针),验证反序列化触发任意可调用对象执行"
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"pitfall_id": "PY-AUTHZ-004",
|
|
53
|
+
"cwe": "CWE-862",
|
|
54
|
+
"severity": "high",
|
|
55
|
+
"languages": ["python"],
|
|
56
|
+
"frameworks": ["fastapi", "django", "flask"],
|
|
57
|
+
"surfaces": ["http", "api", "auth"],
|
|
58
|
+
"title": "FastAPI/Django/Flask 路由缺失鉴权依赖或对象归属校验(IDOR)",
|
|
59
|
+
"anti_pattern_signals": ["@app.get(", "@app.post(", "@router.", "Depends(", "get_object_or_404(", "filter(id="],
|
|
60
|
+
"false_positive_guards": [
|
|
61
|
+
"APIRouter 顶层已绑定 dependencies=[Depends(require_auth)] 且查询带 owner_id == current_user.id",
|
|
62
|
+
"Django 视图继承 LoginRequiredMixin 且 get_queryset 按 request.user 过滤"
|
|
63
|
+
],
|
|
64
|
+
"poc_skeleton": "以普通用户 A 的会话请求属于用户 B 的 resource_id,断言越权读取或修改成功;负对照访问自身资源正常"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"pitfall_id": "PY-MASSASSIGN-005",
|
|
68
|
+
"cwe": "CWE-915",
|
|
69
|
+
"severity": "high",
|
|
70
|
+
"languages": ["python"],
|
|
71
|
+
"frameworks": ["fastapi", "django", "sqlalchemy"],
|
|
72
|
+
"surfaces": ["http", "api", "database"],
|
|
73
|
+
"title": "请求体未裁剪直接 setattr / model_dump 更新敏感字段(批量赋值)",
|
|
74
|
+
"anti_pattern_signals": ["setattr(", "model_dump(", ".dict()", "**payload", "fields = '__all__'"],
|
|
75
|
+
"false_positive_guards": [
|
|
76
|
+
"使用显式字段白名单 Schema(排除 is_admin / role / balance)",
|
|
77
|
+
"setattr 前严格校验 key in ALLOWED_UPDATE_FIELDS"
|
|
78
|
+
],
|
|
79
|
+
"poc_skeleton": "向更新接口附加 `is_admin=True` 或 `role='admin'`,验证持久化对象权限字段被意外改写"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
}
|
package/core/bugx.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: bugx
|
|
3
3
|
# Frontmatter is host/Agent routing metadata. Human-facing usage guidance belongs in README.md and docs/.
|
|
4
|
-
description: Use BugX
|
|
5
|
-
version: 0.1.
|
|
4
|
+
description: Use BugX when asked to perform autonomous code review, deep bug hunting, black-box testing, or automated functional and performance verification. Do NOT use BugX for normal conversation, everyday coding, minor cosmetic fixes, or documentation tasks. Normal development should proceed without activating BugX lifecycle.
|
|
5
|
+
version: 0.1.3
|
|
6
6
|
mode: all
|
|
7
7
|
temperature: 0.1
|
|
8
8
|
permission:
|
package/core/bugx_paths.py
CHANGED
|
@@ -104,8 +104,8 @@ def _version_from_text(path: Path, pattern: re.Pattern[str],
|
|
|
104
104
|
except (OSError, UnicodeError):
|
|
105
105
|
return None
|
|
106
106
|
value = match.group(1) if match else None
|
|
107
|
-
if value == "0.1.
|
|
108
|
-
value = os.environ.get("BUGX_VERSION", "0.1.
|
|
107
|
+
if value == "0.1.3":
|
|
108
|
+
value = os.environ.get("BUGX_VERSION", "0.1.3").strip()
|
|
109
109
|
return value if value and VERSION_RE.fullmatch(value) else None
|
|
110
110
|
|
|
111
111
|
|
package/core/cli-help.txt
CHANGED
|
@@ -33,7 +33,7 @@ positional arguments:
|
|
|
33
33
|
config 设置本地 BugX 隐私与遥测配置
|
|
34
34
|
daemon BugX 自治持续挖掘常驻守护进程管理
|
|
35
35
|
autonomous 显式启动 Claude Code/Codex/OpenCode/DeepSeek
|
|
36
|
-
Harness/Pi/Cline/ZCode 前台无人值守挖掘
|
|
36
|
+
Harness/Pi/Kimi Code/Cline/ZCode 前台无人值守挖掘
|
|
37
37
|
goal 目标导向无人值守自治挖掘与长程自愈循环
|
|
38
38
|
supervisor 本地监督 MCP:install / status / rpc;带外动作:reset-budget /
|
|
39
39
|
recover / rebind-target / gate / findings
|
|
@@ -1083,7 +1083,15 @@ class CloudClient:
|
|
|
1083
1083
|
|
|
1084
1084
|
# ---- 版本检查与 CLI 包下载(Phase 2 自动更新)----
|
|
1085
1085
|
|
|
1086
|
-
def check_version(
|
|
1086
|
+
def check_version(
|
|
1087
|
+
self,
|
|
1088
|
+
current_version: str = "",
|
|
1089
|
+
channel: str = "",
|
|
1090
|
+
*,
|
|
1091
|
+
client_kind: str = "pip",
|
|
1092
|
+
artifact_kind: str = "python-wheel",
|
|
1093
|
+
release_id: str = "",
|
|
1094
|
+
) -> ReportResult:
|
|
1087
1095
|
"""GET /api/v1/agent/version — 查询最新版本元数据。
|
|
1088
1096
|
|
|
1089
1097
|
当传入 current_version 时,服务端额外返回 update_available 和
|
|
@@ -1095,6 +1103,12 @@ class CloudClient:
|
|
|
1095
1103
|
params["current"] = current_version
|
|
1096
1104
|
if channel and channel.strip():
|
|
1097
1105
|
params["channel"] = channel.strip()
|
|
1106
|
+
if client_kind and client_kind.strip():
|
|
1107
|
+
params["client_kind"] = client_kind.strip()
|
|
1108
|
+
if artifact_kind and artifact_kind.strip():
|
|
1109
|
+
params["artifact_kind"] = artifact_kind.strip()
|
|
1110
|
+
if release_id and release_id.strip():
|
|
1111
|
+
params["release_id"] = release_id.strip()
|
|
1098
1112
|
return self._request("GET", VERSION_CHECK_PATH, None,
|
|
1099
1113
|
auth=False, retry_auth=False, params=params or None)
|
|
1100
1114
|
|
|
@@ -1113,8 +1127,16 @@ class CloudClient:
|
|
|
1113
1127
|
return host in {"127.0.0.1", "::1", "localhost"}
|
|
1114
1128
|
return False
|
|
1115
1129
|
|
|
1116
|
-
def download_package(
|
|
1117
|
-
|
|
1130
|
+
def download_package(
|
|
1131
|
+
self,
|
|
1132
|
+
dest: Path,
|
|
1133
|
+
*,
|
|
1134
|
+
expected_sha256: str = "",
|
|
1135
|
+
expected_version: str = "",
|
|
1136
|
+
release_id: str = "",
|
|
1137
|
+
channel: str = "",
|
|
1138
|
+
artifact_kind: str = "python-wheel",
|
|
1139
|
+
) -> tuple[bool, str]:
|
|
1118
1140
|
"""GET /api/v1/agent/download — 下载 CLI 包到指定路径。
|
|
1119
1141
|
|
|
1120
1142
|
返回 (success, message)。下载后做 SHA-256 校验(必须提供)。
|
|
@@ -1124,7 +1146,7 @@ class CloudClient:
|
|
|
1124
1146
|
|
|
1125
1147
|
dest: 目标文件路径(含文件名)。
|
|
1126
1148
|
expected_sha256: 下载后校验哈希(必填,缺失即拒绝下载)。
|
|
1127
|
-
|
|
1149
|
+
release_id/channel/artifact_kind: 锁定服务端返回的具体制品。
|
|
1128
1150
|
"""
|
|
1129
1151
|
expected_sha256 = str(expected_sha256 or "").strip().lower()
|
|
1130
1152
|
if not expected_sha256:
|
|
@@ -1132,10 +1154,23 @@ class CloudClient:
|
|
|
1132
1154
|
if not re.fullmatch(r"[0-9a-f]{64}", expected_sha256):
|
|
1133
1155
|
return False, "下载失败: expected_sha256 必须是 64 位 SHA-256 hex"
|
|
1134
1156
|
|
|
1157
|
+
params: dict[str, str] = {}
|
|
1158
|
+
if channel and channel.strip():
|
|
1159
|
+
params["channel"] = channel.strip()
|
|
1160
|
+
if artifact_kind and artifact_kind.strip():
|
|
1161
|
+
params["artifact_kind"] = artifact_kind.strip()
|
|
1162
|
+
if release_id and release_id.strip():
|
|
1163
|
+
params["release_id"] = release_id.strip()
|
|
1135
1164
|
url = self.base + DOWNLOAD_PATH
|
|
1165
|
+
if params:
|
|
1166
|
+
url += "?" + urllib.parse.urlencode(params)
|
|
1136
1167
|
# 跟随重定向(版本检查端点可能配置了外部 PyPI 镜像地址)
|
|
1137
1168
|
opener = _build_redirect_opener(self.base)
|
|
1138
|
-
headers = {
|
|
1169
|
+
headers = {
|
|
1170
|
+
"Accept": "application/octet-stream",
|
|
1171
|
+
"X-BugX-Artifact-Kind": artifact_kind,
|
|
1172
|
+
**client_headers(),
|
|
1173
|
+
}
|
|
1139
1174
|
req = urllib.request.Request(url, headers=headers)
|
|
1140
1175
|
try:
|
|
1141
1176
|
resp = opener.open(req, timeout=self.timeout)
|
|
@@ -1151,6 +1186,22 @@ class CloudClient:
|
|
|
1151
1186
|
f"下载失败: 最终 URL 非 HTTPS,拒绝下载: {final_url}"
|
|
1152
1187
|
)
|
|
1153
1188
|
headers = getattr(resp, "headers", None)
|
|
1189
|
+
if headers is not None:
|
|
1190
|
+
remote_release_id = str(headers.get("X-BugX-Release-ID") or "").strip()
|
|
1191
|
+
remote_version = str(headers.get("X-BugX-Version") or "").strip()
|
|
1192
|
+
remote_checksum = str(headers.get("X-Checksum-SHA256") or "").strip().lower()
|
|
1193
|
+
if remote_release_id and release_id and remote_release_id != release_id:
|
|
1194
|
+
return False, (
|
|
1195
|
+
"下载失败: 服务端 release_id 与版本检查结果不一致"
|
|
1196
|
+
)
|
|
1197
|
+
if remote_version and expected_version and remote_version != expected_version:
|
|
1198
|
+
return False, (
|
|
1199
|
+
"下载失败: 服务端版本与版本检查结果不一致"
|
|
1200
|
+
)
|
|
1201
|
+
if remote_checksum and remote_checksum != expected_sha256:
|
|
1202
|
+
return False, (
|
|
1203
|
+
"下载失败: 服务端响应校验值与版本元数据不一致"
|
|
1204
|
+
)
|
|
1154
1205
|
content_length = None
|
|
1155
1206
|
if headers is not None:
|
|
1156
1207
|
raw_length = headers.get("Content-Length")
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
"""cloud_sync/consent.py -
|
|
1
|
+
"""cloud_sync/consent.py - 云端数据共享与遥测开关的唯一真源。
|
|
2
2
|
|
|
3
3
|
语义(三态,禁止双轨实现):
|
|
4
4
|
|
|
5
5
|
- ``True`` —— 用户显式同意共享;云端 push/pull 仍需项目 onboarding 完成。
|
|
6
6
|
- ``False`` —— 用户显式撤销;任何云端 egress(push 或 pull)一律拒绝,
|
|
7
7
|
且不得写项目侧状态(撤销是用户级决定,不改写 ``.bugx/cloud-onboard.json``)。
|
|
8
|
-
- ``None`` ——
|
|
8
|
+
- ``None`` —— 用户尚未表态;云同步仍按既有 onboarding 状态判定,
|
|
9
|
+
遥测则按产品默认值开启。
|
|
9
10
|
|
|
10
|
-
历史缺陷(F1):``bugx
|
|
11
|
+
历史缺陷(F1):``bugx config set telemetry.data_sharing false`` 只清空
|
|
11
12
|
飞轮 outbox 并写 ``~/.bugx/cloud-config.json``,但 ``sync_layers`` / ``auto_sync``
|
|
12
13
|
只看 ``.bugx/cloud-onboard.json`` 的 ``state == "done"``,于是「已撤销共享」的项目
|
|
13
14
|
仍会继续上传 ledger/report。修复方式是把撤销做成读取期硬闸门(本模块),而不是
|
|
@@ -20,8 +21,12 @@ import os
|
|
|
20
21
|
from pathlib import Path
|
|
21
22
|
|
|
22
23
|
CONFIG_ENV = "BUGX_CLOUD_CONFIG"
|
|
24
|
+
TELEMETRY_ENABLED_ENV = "BUGX_TELEMETRY_ENABLED"
|
|
25
|
+
DEFAULT_TELEMETRY_ENABLED = True
|
|
23
26
|
REVOKED_ERROR = "data_sharing_revoked"
|
|
24
27
|
REVOKED_DETAIL = "用户已撤销 telemetry.data_sharing,云端同步被拒绝"
|
|
28
|
+
_TRUE_VALUES = frozenset({"1", "true", "yes", "on"})
|
|
29
|
+
_FALSE_VALUES = frozenset({"0", "false", "no", "off"})
|
|
25
30
|
|
|
26
31
|
|
|
27
32
|
class CloudConsentRevoked(RuntimeError):
|
|
@@ -69,6 +74,31 @@ def sharing_allowed() -> bool:
|
|
|
69
74
|
return data_sharing_flag() is True
|
|
70
75
|
|
|
71
76
|
|
|
77
|
+
def telemetry_enabled() -> bool:
|
|
78
|
+
"""返回统一遥测门禁状态。
|
|
79
|
+
|
|
80
|
+
``telemetry.data_sharing`` 是用户持久化开关,缺失时按产品契约默认开启。
|
|
81
|
+
``BUGX_TELEMETRY_ENABLED`` 是未撤销状态下的进程级覆盖;持久化 ``False``
|
|
82
|
+
优先级最高,非法值按关闭处理,避免把不明确的环境配置误当成允许出网。
|
|
83
|
+
所有本地统计、飞轮入队、飞轮 flush 和安装心跳都必须调用这个函数,禁止在
|
|
84
|
+
调用方自行解释三态值。
|
|
85
|
+
"""
|
|
86
|
+
# 用户显式持久化的 false 是硬撤销,不能通过环境变量 true 绕过。
|
|
87
|
+
# 环境变量仍可在未撤销时关闭当前进程,或在没有持久化决定时临时开启。
|
|
88
|
+
stored = data_sharing_flag()
|
|
89
|
+
if stored is False:
|
|
90
|
+
return False
|
|
91
|
+
raw = os.environ.get(TELEMETRY_ENABLED_ENV)
|
|
92
|
+
if raw is not None:
|
|
93
|
+
normalized = raw.strip().lower()
|
|
94
|
+
if normalized in _TRUE_VALUES:
|
|
95
|
+
return True
|
|
96
|
+
if normalized in _FALSE_VALUES:
|
|
97
|
+
return False
|
|
98
|
+
return False
|
|
99
|
+
return DEFAULT_TELEMETRY_ENABLED if stored is None else stored
|
|
100
|
+
|
|
101
|
+
|
|
72
102
|
def revoked_summary(scopes: set[str] | list[str] | None) -> dict:
|
|
73
103
|
"""与 ``sync_layers`` 返回结构对齐的拒绝汇总(零 egress、零状态变更)。"""
|
|
74
104
|
scope_list = sorted(scopes) if scopes else ["global", "project"]
|