diff --git a/.github/workflows/plugin-auth.yml b/.github/workflows/plugin-auth.yml new file mode 100644 index 00000000..02db0c12 --- /dev/null +++ b/.github/workflows/plugin-auth.yml @@ -0,0 +1,28 @@ +name: Plugin authentication +on: + pull_request: + paths: + - 'plugins/**' + - 'scripts/test-plugin-auth.sh' + - '.github/workflows/plugin-auth.yml' + push: + branches: [main] + paths: + - 'plugins/**' + - 'scripts/test-plugin-auth.sh' + - '.github/workflows/plugin-auth.yml' +permissions: + contents: read +jobs: + auth: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '11' + - run: bash scripts/test-plugin-auth.sh diff --git a/plugins/README.md b/plugins/README.md index 7503c38a..6d708139 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -11,7 +11,7 @@ Optional integrations that connect CyberStrikeAI with other tools. ### Browser (Chrome / Edge) - **Path**: `plugins/browser-extension/cyberstrikeai-browser-extension/` -- **Version**: **0.3.8** +- **Version**: **0.3.11** - **Install**: `chrome://extensions/` → Load unpacked → F12 → **CyberStrikeAI** tab - **Package**: `bash package.sh` → `dist/cyberstrikeai-browser-extension.zip` - **Docs**: `README.zh-CN.md` (full) / `README.md` (summary) diff --git a/plugins/browser-extension/cyberstrikeai-browser-extension/README.md b/plugins/browser-extension/cyberstrikeai-browser-extension/README.md index bcd0b474..b1c05944 100644 --- a/plugins/browser-extension/cyberstrikeai-browser-extension/README.md +++ b/plugins/browser-extension/cyberstrikeai-browser-extension/README.md @@ -1,6 +1,6 @@ ## CyberStrikeAI Browser Extension -**Version 0.3.10** — Full docs: **README.zh-CN.md** +**Version 0.3.11** — Full docs: **README.zh-CN.md** Chromium DevTools extension: capture Network traffic and send it to CyberStrikeAI for AI-assisted security testing. Aligned with the Burp Suite plugin. @@ -11,6 +11,12 @@ Chromium DevTools extension: capture Network traffic and send it to CyberStrikeA 3. Open target page → **F12** → **CyberStrikeAI** tab → **Validate** 4. Select a captured request → **Send** → view **Output** +### RBAC login + +Fill in Host / Port / HTTPS and the same Username / Password used in the web UI, then click Validate. Username defaults to `admin`; custom accounts use their own username. The username is saved locally; the password is not persisted. Changing connection settings or credentials clears the cached token and requires Validate again. + +If the server reports a missing username and the panel only has Password, reload the updated extension at `chrome://extensions/`, then close and reopen DevTools. Do not enter `username:password` in Password. + ### Popup vs DevTools panel | Location | Purpose | @@ -72,3 +78,7 @@ lib/ # api, storage, capture, http-normalize, markdown, … icons/ package.sh ``` + +### Authentication regression tests + +From the repository root, run `bash scripts/test-plugin-auth.sh` (Node.js and JDK 11+). This tests both clients against local HTTP fixtures, username validation, credential escaping, settings migration, and Burp account-switch invalidation. The script downloads the compile-only Burp API; set `BURP_API_JAR` to an existing JAR for offline use. diff --git a/plugins/browser-extension/cyberstrikeai-browser-extension/README.zh-CN.md b/plugins/browser-extension/cyberstrikeai-browser-extension/README.zh-CN.md index d49c22f6..dda1dd5b 100644 --- a/plugins/browser-extension/cyberstrikeai-browser-extension/README.zh-CN.md +++ b/plugins/browser-extension/cyberstrikeai-browser-extension/README.zh-CN.md @@ -1,6 +1,6 @@ ## CyberStrikeAI 浏览器扩展 -**当前版本:0.3.10**(UI 为英文;中文说明见下文) +**当前版本:0.3.11**(UI 为英文;中文说明见下文) Chrome / Edge(Chromium)DevTools 扩展:在开发者工具中捕获 **Network** 流量,发送到 CyberStrikeAI 进行 AI 辅助安全测试。能力与 Burp Suite 插件对齐,并按生产场景做了性能与体验优化。 @@ -11,7 +11,7 @@ Chrome / Edge(Chromium)DevTools 扩展:在开发者工具中捕获 **Netwo 1. `chrome://extensions/` → 开发者模式 → **加载已解压的扩展程序** 2. 选择目录:`plugins/browser-extension/cyberstrikeai-browser-extension/` 3. 打开目标页面 → **F12** → 顶部 Tab **CyberStrikeAI** -4. 填写 Host / Port / Password → **Validate**(首次会请求访问服务器地址权限) +4. 填写 Host / Port / Username / Password → **Validate**(首次会请求访问服务器地址权限) 5. 左侧选中捕获请求 → **Send** → 在 **Output** 查看 AI 结果 点击浏览器工具栏图标可查看 **只读连接状态**;完整配置与操作均在 DevTools 面板内完成。 @@ -34,7 +34,7 @@ Chrome / Edge(Chromium)DevTools 扩展:在开发者工具中捕获 **Netwo | 区域 | 说明 | |------|------| -| **连接栏** | Host、Port、HTTPS、Password、Validate;成功后收起为 `https://host:port` 摘要 | +| **连接栏** | Host、Port、HTTPS、Username、Password、Validate;成功后收起为 `https://host:port` 摘要 | | **Test History** | 最多 50 次 Send 记录,可回看 Progress / Final | | **Captured Requests** | 当前 Tab 捕获列表,最多 200 条,支持搜索 | | **Output** | 默认 Tab:流式 Progress + Final Response | @@ -97,7 +97,7 @@ Cookie: ... | 控件 | 作用 | |------|------| | **Validate** | 登录并校验 Token;进行中再次点击为 Cancel | -| **连接设置 / 收起** | 展开或折叠 Host/Port/Password 表单 | +| **连接设置 / 收起** | 展开或折叠 Host/Port/Username/Password 表单 | | **Send** | 对选中捕获发起到 CyberStrikeAI | | **Latest XHR** | 选中最近 XHR/Fetch 并 Send | | **Stop** | 停止当前 AI 流(本地 + 服务端) | @@ -251,3 +251,9 @@ package.sh | 项目/角色/模式 | Send 弹窗 | Send 弹窗 | | SSE 输出 | Progress + Final | Progress + Final | | 捕获开关 | — | ● 捕获中 / ○ 已暂停 | + +### RBAC 用户名与密码 + +Username 填网页登录用户名(默认 `admin`,自建账号填写自己的用户名),Password 填该账号密码,不要拼接成 `用户名:密码`。用户名保存在本地,密码不持久化。修改连接信息或账号密码后,旧 Token 会清除,需要重新 Validate。 + +若提示“用户名不能为空”且界面只有 Password,请在 `chrome://extensions/` 重新加载更新后的插件,再完全关闭并重新打开 DevTools。 diff --git a/plugins/browser-extension/cyberstrikeai-browser-extension/dist/cyberstrikeai-browser-extension.zip b/plugins/browser-extension/cyberstrikeai-browser-extension/dist/cyberstrikeai-browser-extension.zip index c2bf4ff9..a8315a60 100644 Binary files a/plugins/browser-extension/cyberstrikeai-browser-extension/dist/cyberstrikeai-browser-extension.zip and b/plugins/browser-extension/cyberstrikeai-browser-extension/dist/cyberstrikeai-browser-extension.zip differ diff --git a/plugins/browser-extension/cyberstrikeai-browser-extension/lib/api.js b/plugins/browser-extension/cyberstrikeai-browser-extension/lib/api.js index 99b5b234..06b75bf0 100644 --- a/plugins/browser-extension/cyberstrikeai-browser-extension/lib/api.js +++ b/plugins/browser-extension/cyberstrikeai-browser-extension/lib/api.js @@ -39,11 +39,15 @@ async function apiFetch(baseUrl, path, options = {}) { return json; } -async function loginAndValidate(baseUrl, password, signal) { +async function loginAndValidate(baseUrl, username, password, signal) { + username = username.trim(); + if (!username || [...username].length > 64) { + throw new Error('Username is required and must not exceed 64 characters'); + } const login = await apiFetch(baseUrl, '/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json', Accept: 'application/json' }, - body: JSON.stringify({ password }), + body: JSON.stringify({ username, password }), signal, }); const token = login && login.token; diff --git a/plugins/browser-extension/cyberstrikeai-browser-extension/lib/storage.js b/plugins/browser-extension/cyberstrikeai-browser-extension/lib/storage.js index 657e02f0..17b32381 100644 --- a/plugins/browser-extension/cyberstrikeai-browser-extension/lib/storage.js +++ b/plugins/browser-extension/cyberstrikeai-browser-extension/lib/storage.js @@ -1,6 +1,7 @@ /* global chrome */ const STORAGE_KEYS = { + username: 'csai_username', host: 'csai_host', port: 'csai_port', https: 'csai_https', @@ -17,6 +18,7 @@ const STORAGE_KEYS = { const SESSION_TOKEN_KEY = 'csai_token'; const DEFAULTS = { + username: 'admin', host: '127.0.0.1', port: '8080', https: true, @@ -134,6 +136,7 @@ async function loadConfig() { const data = await localGet(Object.values(STORAGE_KEYS)); const sess = await sessionGet([SESSION_TOKEN_KEY, SESSION_TOKEN_EXPIRY_KEY]); return { + username: data[STORAGE_KEYS.username] ?? DEFAULTS.username, host: data[STORAGE_KEYS.host] || DEFAULTS.host, port: data[STORAGE_KEYS.port] || DEFAULTS.port, https: data[STORAGE_KEYS.https] !== false, @@ -152,6 +155,7 @@ async function loadConfig() { async function saveConfig(partial) { const localMap = {}; + if (partial.username != null) localMap[STORAGE_KEYS.username] = partial.username; if (partial.host != null) localMap[STORAGE_KEYS.host] = partial.host; if (partial.port != null) localMap[STORAGE_KEYS.port] = partial.port; if (partial.https != null) localMap[STORAGE_KEYS.https] = partial.https; diff --git a/plugins/browser-extension/cyberstrikeai-browser-extension/manifest.json b/plugins/browser-extension/cyberstrikeai-browser-extension/manifest.json index b05e3f71..548eb72a 100644 --- a/plugins/browser-extension/cyberstrikeai-browser-extension/manifest.json +++ b/plugins/browser-extension/cyberstrikeai-browser-extension/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "CyberStrikeAI", - "version": "0.3.10", + "version": "0.3.11", "description": "Capture browser HTTP traffic and send to CyberStrikeAI for AI-assisted security testing.", "devtools_page": "devtools.html", "permissions": ["storage"], diff --git a/plugins/browser-extension/cyberstrikeai-browser-extension/package.sh b/plugins/browser-extension/cyberstrikeai-browser-extension/package.sh index 6282a4b3..61689489 100644 --- a/plugins/browser-extension/cyberstrikeai-browser-extension/package.sh +++ b/plugins/browser-extension/cyberstrikeai-browser-extension/package.sh @@ -5,5 +5,5 @@ OUT="$ROOT/dist/cyberstrikeai-browser-extension.zip" mkdir -p "$ROOT/dist" rm -f "$OUT" (cd "$ROOT" && zip -r "$OUT" . \ - -x './dist/*' -x './package.sh' -x '*/.DS_Store') + -x './dist/*' -x './tests/*' -x './package.sh' -x '*/.DS_Store') echo "[+] $OUT" diff --git a/plugins/browser-extension/cyberstrikeai-browser-extension/panel/panel.html b/plugins/browser-extension/cyberstrikeai-browser-extension/panel/panel.html index defae550..835c72bd 100644 --- a/plugins/browser-extension/cyberstrikeai-browser-extension/panel/panel.html +++ b/plugins/browser-extension/cyberstrikeai-browser-extension/panel/panel.html @@ -34,6 +34,10 @@ HTTPS +