Skip to content

fix: 落实 PR #693 review 意见 - #707

Merged
cute-omega merged 37 commits into
masterfrom
pr/8odream/693
Sep 16, 2026
Merged

cute-omega merged 37 commits into
masterfrom
pr/8odream/693

Conversation

@cute-omega

Copy link
Copy Markdown
Collaborator

Summary

按 PR #693 中 cute-omega 与 Copilot 的 review 意见,在合并后手动落地剩余修正。

安全

  • 错误页 HTML 转义,防反射 XSS
  • 未知长度请求体禁止无界重试缓存;有 Content-Length 且 ≤1MiB 才允许
  • 恢复 pnpm-workspace 安全 overrides,并同步 lockfile

更新 / 配置

  • ARM 不再回退 x64 增量包
  • 完整安装包下载到 userData/update(避免 Program Files 只读)
  • 写流 finish 后再通知安装成功
  • util.log-env 兼容 config.json5
  • server.vue 测速标准化保留 Cloudflare 元数据

代理 / 环境变量

  • Connection: close 时也应用 tlsVersionMapping
  • 关闭系统代理时按备份恢复 HTTPS_PROXY / HTTP_PROXY / REQUEST_CA_BUNDLE
  • macOS:launchctl setenv + LaunchAgent;Linux:systemd environment.d + shell profile;Windows 保持注册表

流量监控

  • keep-alive 基线累计、lifetime 总字节、域名 map 淘汰
  • MITM CONNECT 关联客户端 socket,内部端口映射回真实客户端
  • processResolver 仅 Windows 启动,支持 IPv6 netstat,关闭时清理 interval

测试

  • IPv6 连通检查移出 mocha 默认路径(scripts/ipv6-net-check.js)

验证

  • pnpm --filter @docmirror/dev-sidecar test:19 passing
  • dnsDefaultLookupTest:通过

备注

  • 并行启动按 PR 作者意图保留(启动窗口内请求失败属计划内行为)
  • 错误页:浏览器导航 HTML(黑底白字+转义);JSON/XHR 返回 application/json;子资源 text/plain

8odream and others added 30 commits May 16, 2025 12:21
- feat(gui): 新增流量监控页面,adblock 零 IP 与已拦截域名不计入错误统计
- feat(core): 支持 DEV_SIDECAR_LOG_DISABLED 完全关闭日志,设置页增加开关
- feat(overwall): 服务器支持 ID 标识,可按域名选择目标服务器
- feat(speed): 测速过滤零 IP,等待 Cloudflare 路由就绪后执行
- fix(gui): 修复安装后任务栏图标仍为 Electron 默认图标(signAndEditExecutable 改为 true,确保写入 exe 图标与版本信息)
- fix(build): 平台原生可选依赖声明为直接依赖,修复安装后 sysproxy/shutdown-handler 模块缺失
- fix(proxy): DS-Proxy-Request 响应头改用实际上游路径
- fix(system-proxy): 优化系统代理开关与恢复逻辑
- chore(script): 统一 dev.ps1 启停/检查脚本

内容使用DeepSeekV4Pro0813 high+DSH完成
- feat(interceptor): 新增 retry 拦截器,收到 500 或连接失败时自动重试,支持缓存小请求体
- fix(proxy): 子资源错误页改为 text/plain,避免浏览器 ORB 拦截;错误日志精简 rOptions 输出
- feat(sni): sni 配置为空字符串时关闭上游 SNI 发送
- feat(cloudflareRoute): 预设 IP 优先级最高不参与重定向;新增 blacklist/whitelist 模式与域名名单
- fix(speed): 请求失败后从存活 IP 列表移除失败 IP,后续请求与重试自动切换
- feat(server): 新增按域名 TLS 版本设置 tlsVersionMapping,支持远程下发后用户自行启用
- feat(gui): 加速服务页新增 TLS 版本设置 UI,并为 Cloudflare 路由重定向增加模式与域名名单 UI
修复更新检查证书校验失败
Co-authored-by: 8odream <87055981+8odream@users.noreply.github.com>
Co-authored-by: 8odream <87055981+8odream@users.noreply.github.com>
Co-authored-by: 8odream <87055981+8odream@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- 安全:错误页 XSS 转义;未知长度 body 禁止无界重试缓存;恢复 pnpm 安全 overrides
- 更新:ARM 不回退 x64 增量包;下载到 userData;写流 finish 后再通知
- 环境变量:关闭时按备份恢复;macOS 用 launchctl+LaunchAgent,Linux 写 environment.d/profile
- 流量:keep-alive 基线累计、lifetime 总量、域名淘汰、MITM 端口映射;processResolver 仅 Windows
- 其他:TLS 版本在 Connection:close 生效;log-env 兼容 json5;server.vue 保留 cf 字段
- 测试:ipv6 连通检查移出 mocha 默认路径
Copilot AI lite review requested due to automatic review settings September 13, 2026 09:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved critical and moderate findings remain across packaging, environment persistence, updates, proxy behavior, and traffic monitoring.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

This PR applies follow-up security, proxy, update, monitoring, packaging, and testing fixes from PR #693.

Changes:

  • Hardens retry, error-page, DNS, TLS, and dependency handling.
  • Updates cross-platform proxy and environment persistence.
  • Improves GUI updates, ARM packaging, speed tests, and traffic monitoring.
  • Adds regression tests, diagnostics, and documentation.
File summaries
File Reviewed changes and final comments
README.md Adds proxy conflict troubleshooting guidance.
pnpm-workspace.yaml Restores dependency security overrides.
pnpm-lock.yaml Synchronizes dependency resolutions.
packages/mitmproxy/test/ipv6-test.mjs Adjusts IPv6 test execution.
packages/mitmproxy/test/dnsDefaultLookupTest.mjs Adds DNS lookup regression coverage.
packages/mitmproxy/src/options.js Updates plugin terminology.
packages/mitmproxy/src/lib/traffic/TrafficMonitor.js Adds traffic aggregation, lifetime totals, domain tracking, and client association. Moderate (2 votes): Keep-alive deltas can be omitted from lifetime totals; expired blocked hosts are not swept; repeated requests add duplicate socket listeners. Moderate (1 vote): Initial socket bytes can be omitted from totals.
packages/mitmproxy/src/lib/traffic/processResolver.js Adds Windows process resolution and lifecycle handling.
packages/mitmproxy/src/lib/speed/SpeedTester.js Preserves Cloudflare metadata during speed tests.
packages/mitmproxy/src/lib/speed/index.js Integrates speed-test changes.
packages/mitmproxy/src/lib/speed/config.js Updates speed-test configuration.
packages/mitmproxy/src/lib/proxy/mitmproxy/index.js Integrates proxy monitoring and lifecycle changes.
packages/mitmproxy/src/lib/proxy/mitmproxy/dnsLookup.js Updates DNS and Cloudflare lookup handling. Moderate (1 vote): CONNECT failures do not report probe failures or retain the original DNS address.
packages/mitmproxy/src/lib/proxy/mitmproxy/createConnectHandler.js Associates CONNECT sockets with clients. Moderate (1 vote): Connect errors omit the client port and can miss per-client accounting.
packages/mitmproxy/src/lib/proxy/middleware/overwall.js Updates Overwall server selection. Critical (1 vote): Custom server IDs can leave the default target pointing to nonexistent server ID 0.
packages/mitmproxy/src/lib/proxy/common/util.js Applies TLS version mappings. Moderate (2 votes): Connection: close matching is not case-insensitive or token-aware.
packages/mitmproxy/src/lib/interceptor/index.js Integrates interceptor updates.
packages/mitmproxy/src/lib/interceptor/impl/req/sni.js Applies TLS mapping changes.
packages/mitmproxy/src/lib/interceptor/impl/req/retry.js Implements bounded request retries.
packages/mitmproxy/src/lib/dns/util.ip.js Updates IP handling.
packages/mitmproxy/src/lib/dns/tls.js Updates TLS DNS behavior.
packages/mitmproxy/src/lib/dns/tcp.js Updates TCP DNS behavior.
packages/mitmproxy/src/lib/cloudflareRoute.js Updates Cloudflare routing.
packages/mitmproxy/src/index.js Updates proxy startup and shutdown.
packages/mitmproxy/scripts/ipv6-net-check.js Provides a standalone IPv6 connectivity check.
packages/gui/src/view/router/menu.js Updates GUI navigation.
packages/gui/src/view/router/index.js Registers GUI routes.
packages/gui/src/view/pages/traffic.vue Adds traffic monitoring UI. Moderate (1 vote): Sortable headers are not keyboard accessible.
packages/gui/src/view/pages/setting.vue Updates settings UI.
packages/gui/src/view/pages/server.vue Preserves speed-test metadata. Moderate (1 vote): Normalization drops fields used to display failed probes.
packages/gui/src/view/pages/plugin/overwall.vue Updates Overwall configuration UI.
packages/gui/src/view/pages/plugin/node.vue Updates Node plugin UI.
packages/gui/src/view/pages/index.vue Updates dashboard behavior.
packages/gui/src/view/pages/github-status.vue Adds GitHub status display.
packages/gui/src/view/components/container.vue Updates shared GUI container behavior.
packages/gui/src/utils/util.log-env.js Adds JSON5-compatible logging configuration.
packages/gui/src/bridge/update/front.js Updates installer interaction.
packages/gui/src/bridge/update/backend.js Handles installer downloads. Critical (1 vote): Unvalidated asset names can escape the update directory. Moderate (2 votes): Non-2xx responses can be reported as successful downloads. Moderate (1 vote): Linux AppImages need executable permissions before opening.
packages/gui/src/bridge/api/backend.js Updates backend API bridging.
packages/gui/src/background.js Updates Electron lifecycle integration.
packages/gui/package.json Adds platform-specific dependencies.
packages/gui/electron-builder.config.cjs Updates multi-architecture packaging.
packages/core/test/instanceTest.js Updates core instance tests.
packages/core/src/utils/util.logger.js Updates logging configuration.
packages/core/src/utils/util.log-or-console.js Updates conditional logging.
packages/core/src/shell/scripts/set-system-proxy/index.js Manages proxy environment restoration. Moderate (2 votes): Re-enabling the proxy can overwrite the original backup; restoration can delete untouched environment variables.
packages/core/src/shell/scripts/set-system-env.js Adds cross-platform environment persistence. Moderate (1 vote): System-proxy executors do not use this helper or its cleanup path.
packages/core/src/modules/server/index.js Updates server lifecycle handling.
packages/core/src/modules/plugin/overwall/config.js Updates Overwall configuration.
packages/core/src/modules/plugin/node/index.js Applies Node/npm environment configuration. Critical (1 vote): Disabling acceleration can leave TLS-verification-disabling variables persisted.
packages/core/src/modules/plugin/node/config.js Updates Node plugin settings.
packages/core/src/expose.js Updates exposed core APIs.
packages/core/src/config/index.js Updates default configuration.
packages/core/src/config-api.js Updates configuration API handling.
doc/wiki/加速服务使用说明.md Updates usage documentation.
.github/workflows/build-and-release.yml Updates release artifacts and architectures. Critical (1 vote): The ARM Flatpak path is unreachable because the ARM matrix entry is disabled and the active builder targets only x64; the same issue appears at line 610.
_script/electron-dev.mjs Updates Electron development startup.
_script/dev.js Updates development tooling.
Review details

Files not reviewed (1)

  • pnpm-lock.yaml: Generated file

Suppressed comments (9)

.github/workflows/build-and-release.yml:612

  • The release job has no active download step for the ARM Flatpaks uploaded by the build job (and the x64 Flatpak download is commented out here). Consequently those artifacts never enter release/ and cannot be published, even if the ARM build is fixed. Add download steps for the intended Flatpak artifacts or remove the corresponding uploads.
      #- name: "Download DevSidecar-${{ steps.package-info.outputs.version }}-linux-x86_64.flatpak"
      #  uses: actions/download-artifact@v4.1.8
      #  with:

packages/core/src/shell/scripts/set-system-env.js:348

  • This new cross-platform environment helper is not used by the system-proxy executors: set-system-proxy/index.js still calls the legacy writeProxyEnvFile/profile-source functions on Linux and macOS. Consequently, toggling the system proxy never uses the advertised launchctl/environment.d handling or applies REQUEST_CA_BUNDLE through this implementation. Route those executors through this helper (and its matching cleanup) or remove the legacy path.
module.exports = async function (args) {
  return execute(executor, args)

packages/gui/src/bridge/update/backend.js:363

  • Linux .AppImage files downloaded through createWriteStream do not retain an executable mode. This callback immediately opens the file, so the automatically opened full installer can fail with a permission error; set the executable bit before notifying the renderer.
      log.info('完整安装包下载成功:', downloadedPath)

packages/gui/src/bridge/update/backend.js:127

  • The download request is piped to the file without checking its HTTP status, and finish unconditionally calls onSuccess. A 403/404 or proxy-generated error page can therefore be reported as a completed installer and opened by the GUI. Reject non-2xx responses and remove the partial file before treating the download as successful.
  progress(request(uri, { ca: getTrustedCaList() }), {
    // throttle: 2000,                    // Throttle the progress event to 2000ms, defaults to 1000ms
    // delay: 1000,                       // Only start to emit after 1000ms delay, defaults to 0ms
    // lengthHeader: 'x-transfer-length'  // Length header to use, defaults to content-length
  })

packages/gui/src/view/pages/server.vue:352

  • This normalization drops title and status, but the template uses element.title to distinguish failed probes from pending ones. Failed IPs will therefore be displayed as “测速中” without the error color. Preserve the existing item fields and use a nullish check for time so valid zero values are not discarded.
                const standardized = {
                  host: ipObj.host,
                  port: ipObj.port || 443,
                  dns: ipObj.dns || 'unknown',
                  time: ipObj.time || null,

packages/gui/src/view/pages/traffic.vue:237

  • The custom sortable headers are plain span elements with only a mouse click handler. They are not keyboard focusable or operable, so keyboard and screen-reader users cannot sort either table. Use a native button (or provide equivalent tabindex/role and keyboard handlers) for this control.
    packages/mitmproxy/src/lib/proxy/mitmproxy/createConnectHandler.js:61
  • This rejection path calls markConnectError(hostname) without the client port, even though attachConnect has already associated the request with one. As a result, a failed intercepted CONNECT increments only the domain-wide error count and never the originating process/client entry. Pass the associated client port through the error-reporting API, and deduplicate it with socket error events.
    packages/mitmproxy/src/lib/proxy/mitmproxy/dnsLookup.js:127
  • The lookup records the selected tester/IP for both normal requests and CONNECT tunnels, but the CONNECT timeout/error paths only call dns.count. A Cloudflare-rewritten address is not the original address in that DNS cache, and no tester.reportProbeResult(ip, false) is made for CONNECT failures, so a dead preferred endpoint can remain marked alive and be selected repeatedly. Report the probe failure in the CONNECT path and retain the original DNS address for cache accounting.
    packages/mitmproxy/src/lib/traffic/TrafficMonitor.js:155
  • attachRequest runs after Node has already consumed the request headers, so a newly created entry's socket.bytesRead already includes the first request. Using that value as the baseline permanently drops those bytes from both the per-process and lifetime totals for every new connection. Establish the baseline when the socket is accepted, or otherwise account for the current counters according to the intended traffic metric.
  • Files reviewed: 57/59 changed files
  • Comments generated: 10
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread .github/workflows/build-and-release.yml
Comment thread packages/core/src/modules/plugin/node/index.js
Comment thread packages/gui/src/bridge/update/backend.js Outdated
Comment thread packages/mitmproxy/src/lib/proxy/middleware/overwall.js
Comment thread packages/core/src/shell/scripts/set-system-proxy/index.js Outdated
Comment thread packages/core/src/shell/scripts/set-system-proxy/index.js Outdated
Comment thread packages/mitmproxy/src/lib/proxy/common/util.js Outdated
Comment thread packages/mitmproxy/src/lib/traffic/TrafficMonitor.js
Comment thread packages/mitmproxy/src/lib/traffic/TrafficMonitor.js Outdated
Comment thread packages/mitmproxy/src/lib/traffic/TrafficMonitor.js
- 保留其余安全 overrides
- 同步 pnpm-lock.yaml
- cross-spawn/form-data 等 override 与生产依赖解析冲突
- 安全版本应通过升级直接依赖解决,而非全局 override
- 与上次绿色构建 1f70b07 的依赖解析方式对齐
- 环境变量备份仅首次 enable 写入;restore 只处理备份中的 key
- TrafficMonitor: keep-alive 增量计入 lifetime;同 socket 只挂一次 close;扫过期 blockedHosts
- Connection 头大小写/token 列表兼容
- fullPackageName 限制 basename,防路径穿越
- 移除 Access-Control-Allow-Credentials: true
- 保留 Access-Control-Allow-Origin 反射 + Vary: Origin
- 修复 CodeQL js/cors-misconfiguration-for-credentials (high)
- checkout/setup-node/setup-python/setup-dotnet/cache/pnpm-action 升大版本
- upload-artifact@v6 / download-artifact@v7
- codeql upload-sarif@v4
- 消除 runner 强制 Node 24 的弃用警告
Comment thread packages/core/src/shell/scripts/set-system-proxy/index.js Dismissed
Comment thread packages/core/src/shell/scripts/set-system-proxy/index.js Dismissed
@cute-omega
cute-omega merged commit 95f017c into master Sep 16, 2026
13 checks passed
@cute-omega
cute-omega deleted the pr/8odream/693 branch September 16, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants