Skip to content

feat: add configurable custom avatars - #67

Open
buguoshixc wants to merge 2 commits into
NanmiCoder:mainfrom
buguoshixc:feat/custom-avatars
Open

feat: add configurable custom avatars#67
buguoshixc wants to merge 2 commits into
NanmiCoder:mainfrom
buguoshixc:feat/custom-avatars

Conversation

@buguoshixc

Copy link
Copy Markdown

Summary

  • Add per-team captain custom avatars using HTTP(S) URLs or local uploads
  • Add per-member avatar overrides with higher priority than role artwork
  • Add configurable role-to-avatar mappings
  • Add a CSP-compatible same-origin remote image proxy
  • Add secure PNG/JPEG/WebP uploads with a 2 MiB limit
  • Preserve the existing role artwork and initial-letter fallbacks
  • Keep legacy team.json files backward-compatible

Security

  • Validate declared MIME type and image signature
  • Reject oversized files and traversal-shaped filenames
  • Generate server-owned upload filenames
  • Protect mutation routes with a process-local edit token and custom request marker
  • Reject loopback and private-network remote URLs
  • Pin validated DNS results to prevent DNS rebinding

Testing

  • pnpm typecheck
  • pnpm build
  • pnpm verify
  • Added HTTP-level avatar upload, validation, persistence, fallback, snapshot, and legacy-state tests

Notes

DSH Desktop requires a full restart to load the rebuilt host/client bundles because loader.internal is unavailable under Electron.

@NanmiCoder NanmiCoder left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

感谢头像能力和上传/代理测试。这个 PR 目前与主线冲突,且涉及新的网络与持久化边界。请先重基到统一宿主适配后的主线,保留现行 Web 鉴权和默认角色图;随后补 IPv4/IPv6、重定向与 DNS 校验、大小限制、旧状态读取和真实浏览器上传验证。我们保留这个功能 PR,单独完成验收。

# Conflicts:
#	docs/usage.md
#	package.json
#	src/client/ActivityPanel.module.css
#	src/client/ActivityPanel.tsx
#	src/client/activity-monitor.ts
#	src/client/locales.ts
#	src/index.ts
#	src/snapshot.ts
#	src/tools.ts
@buguoshixc

Copy link
Copy Markdown
Author

已按 review 要求完成,当前 PR head 为 ca4b56f,已基于 main@1caff61 重基;GitHub 显示 No conflicts with base branch

完成项:

  • 保留现行 Web 鉴权:真实宿主测试确认未鉴权 state 路由返回 401,浏览器 token 鉴权可用。
  • 保留默认角色图与覆盖优先级:自定义成员头像 > role override > 打包角色图;未匹配角色仍使用首字母 fallback。
  • 加固 IPv4/IPv6 SSRF:覆盖私网、特殊用途 IPv6、IPv4-mapped IPv6、NAT64 内嵌 IPv4,并保留 IANA 标记为 globally reachable 的例外。
  • DNS/重定向:拒绝混合公私 DNS 结果;每一跳重新解析、校验并 pin 目标地址;限制重定向次数。
  • 大小限制:覆盖声明 Content-Length 超限、无 Content-Length 的流式超限及上传端 2 MiB 限制。
  • 旧状态读取:缺少 avatar 字段的旧 team.json 可读取并投影到当前 UI。
  • 真实浏览器上传:新增 scripts/avatar-browser-verify.mjs,通过 Playwright Core 驱动系统 Chrome/Edge、实际 DSH Web、真实 file chooser;校验存储文件 SHA-256,并在宿主冷重启 + 浏览器 reload 后继续渲染 256×256 图片。Linux/Windows Verify job 均已接入 pnpm verify:browser

可复现命令:

npx --yes pnpm@10.33.0 install --frozen-lockfile
npx --yes pnpm@10.33.0 typecheck
npx --yes pnpm@10.33.0 build
npx --yes pnpm@10.33.0 verify
npx --yes pnpm@10.33.0 verify:browser

本机实际测试结果(Windows):

  • typecheck: PASS
  • build: PASS
  • node scripts/avatar-verify.mjs: PASS(IPv4/IPv6、DNS、redirect、size、legacy、auth 等)
  • node scripts/avatar-browser-verify.mjs: PASS;63873 bytes,SHA-256 b3ccfd7fda115c4ba39f44c8c25cff7a98a2567c2a7e7c4e0d6bd2919335a4fa;冷重启前后均 256×256
  • node scripts/doctor.mjs: PASS(214 个 DSH package identities)
  • 完整 pnpm verify: 所有此前步骤通过,最后现有 Windows compatibility symlink case 为 7/8;本机因创建 doctor bin 符号链接报 EPERM 停止。该失败不在本 PR 修改文件内,也不是头像断言失败。

GitHub Actions 已触发,但当前 run 为 action_required 且 jobs=0,需要上游维护者批准 fork workflow 后才能提供独立 CI 结果:
https://github.com/NanmiCoder/dsh-agent-teams/actions/runs/34036276487

烦请批准 workflow 后重新验收,谢谢。

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.

2 participants