CyberStrikeAI/web/frontend
Sycun b5f4ab9071 feat(assessment): fuse global security base and deep assessment governance (v1.8.2)
- Add random-nonce CSAI_DATA prompt guard envelope and typed scanner surface ingest (nmap/nuclei/httpx/ffuf) with cross-path execution deduplication
- Add deterministic 3-axis vulnerability fingerprinting and 5-dimension adversarial review shared across record/status/retest/assessment review
- Extend project scope_json with structured allow/deny constraints, scanner noise profiles, and evidence-gated project lessons (off/shadow/inject)
- Bundle offline WSTG/CWE/ATT&CK lookup_security_taxonomy tool and Pi compact skill index + prompt_cache_prefix_split support
- Add deep assessment pre-plan goal decomposition, persistent coverage ledger & acceptance gate, optimistic-concurrency plan notes, and graceful segment wrap-up
- Bump personal version to v1.8.2 and update CHANGELOG.md
2026-11-27 19:21:04 +08:00
..
src feat(assessment): fuse global security base and deep assessment governance (v1.8.2) 2026-11-27 19:21:04 +08:00
tests feat(assessment): fuse global security base and deep assessment governance (v1.8.2) 2026-11-27 19:21:04 +08:00
CONTRACT.md fix(frontend): unify page overlays as drawers 2026-11-19 11:38:19 +08:00
README.md feat(frontend): migrate to Semi Design and refresh workspace 2026-11-19 09:09:11 +08:00
index.html feat(frontend): migrate to Semi Design and refresh workspace 2026-11-19 09:09:11 +08:00
package-lock.json feat(frontend): migrate to Semi Design and refresh workspace 2026-11-19 09:09:11 +08:00
package.json feat(frontend): migrate to Semi Design and refresh workspace 2026-11-19 09:09:11 +08:00
playwright.config.mjs feat(frontend): migrate to Semi Design and refresh workspace 2026-11-19 09:09:11 +08:00
vite.config.mjs feat(frontend): migrate to Semi Design and refresh workspace 2026-11-19 09:09:11 +08:00

README.md

前端(React 19 + Semi Design)

CyberStrikeAI 的 Web 界面是一个 Vite 构建的 React 单页应用,UI 组件统一来自 Semi Design。页面不再使用 Go 模板、手写 HTML/CSS/JS 或全局 window.* 脚本。

目录

web/frontend/
├─ index.html            # Vite 入口,挂载 #root
├─ vite.config.mjs       # base=/static/app/,产物输出到 web/static/app
├─ CONTRACT.md           # 页面开发契约(公共模块 / 样式 / 自检)
└─ src/
   ├─ main.jsx           # 主题、i18n、Semi ConfigProvider、HashRouter
   ├─ App.jsx            # 路由与权限守卫
   ├─ lib/               # http、auth、i18n、theme、nav、format
   ├─ layout/            # 侧边导航、顶栏、登录页
   ├─ components/        # PageHeader / DataTable / StatGrid / Markdown 等
   ├─ pages/<页面 id>/   # 与路由 #/<页面 id> 一一对应
   └─ styles/app.css     # 外壳与共享组件样式

开发

npm ci --prefix web/frontend
npm run --prefix web/frontend dev      # 本地热更新,静态资源直接从工作区读取
# 联调时显式指定你实际启动的后端,避免误连占用默认端口的其他应用:
CSAI_API_ORIGIN=http://127.0.0.1:8080 npm run --prefix web/frontend dev

后端仍由 Go 提供:go run ./cmd/server -config config.yaml。未设置 CSAI_API_ORIGIN 时,开发服务器的 API 返回 503,不会连接默认端口上的其他服务。

浏览器回归:npm run --prefix web/frontend test:ui(需要本机 Chrome)。测试使用独立浏览器和匿名 fixture,拦截全部 API 与外联,不连接部署环境;报告和截图分别位于 playwright-report/、test-results/。该测试不替代真实后端联调。

构建与发布

npm run --prefix web/frontend build

产物写入 web/static/app/(哈希文件名)。Go 服务通过 router.Static("/static", "./web/static") 提供静态资源,GET / 直接返回 web/static/app/index.html;/api-docs 302 到 /#/api-docs。 构建产物需要随源码一起提交,internal/app/spa_test.go 会校验首页引用的资源全部存在。

约定

  • 路由使用 hash:#/dashboard、#/chat?conversation=<id>、#/vulnerabilities?id=<id>,深链接可直接分享。
  • 会话令牌沿用 localStorage['cyberstrike-auth'],请求统一走 src/lib/http.js(自动附加 Authorization)。
  • 主题偏好沿用 localStorage['cyberstrike-theme'](system/light/dark),语言沿用 localStorage['csai_lang'], 词条复用 web/static/i18n/*.json。
  • 页面只能通过 api / postStream 访问 /api,不得直接 fetch;权限判断用 useAuth().hasPermission(...)。
  • 新增页面:在 src/pages/<id>/index.jsx 实现默认导出组件,并在 src/pages/registry.js 与 src/lib/nav.js 注册。

详细页面契约见 CONTRACT.md。