From fae1981161080f698c3f1263b712306d63baae64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=AA=E6=8D=B1=E5=AE=85?= Date: Thu, 7 Aug 2025 08:57:13 +0800 Subject: [PATCH 1/4] perf: add start:server npm script for quick server launch from root directory (#484) @orzyyyy --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e104b7ae..e18c98f3 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ }, "scripts": { "start": "lerna bootstrap --hoist", + "start:server": "cd ./packages/ui/certd-server && npm start", "devb": "lerna run dev-build", "i-all": "lerna link && lerna exec npm install ", "publish": "npm run prepublishOnly2 && lerna publish --force-publish=pro/plus-core --conventional-commits --create-release github && npm run afterpublishOnly && npm run commitAll", From be053d47e41084f817882400882b64143d036d1a Mon Sep 17 00:00:00 2001 From: ayakasuki <27204037@163.com> Date: Thu, 7 Aug 2025 08:59:01 +0800 Subject: [PATCH 2/4] =?UTF-8?q?perf:=20=E6=B7=BB=E5=8A=A0=E5=85=8D?= =?UTF-8?q?=E8=B4=B9=E9=80=9A=E7=9F=A5,OneBot=20V11=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=94=AF=E6=8C=81=20(#491)=20@ayakasuki?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/plugins/plugin-notification/index.ts | 1 + .../plugin-notification/onebot/index.ts | 140 ++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100755 packages/ui/certd-server/src/plugins/plugin-notification/onebot/index.ts diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/index.ts index aab72469..ee1a12bd 100644 --- a/packages/ui/certd-server/src/plugins/plugin-notification/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-notification/index.ts @@ -12,3 +12,4 @@ export * from './bark/index.js'; export * from './feishu/index.js'; export * from './dingtalk/index.js'; export * from './vocechat/index.js'; +export * from './onebot/index.js'; \ No newline at end of file diff --git a/packages/ui/certd-server/src/plugins/plugin-notification/onebot/index.ts b/packages/ui/certd-server/src/plugins/plugin-notification/onebot/index.ts new file mode 100755 index 00000000..bc430d7e --- /dev/null +++ b/packages/ui/certd-server/src/plugins/plugin-notification/onebot/index.ts @@ -0,0 +1,140 @@ +import { BaseNotification, IsNotification, NotificationBody, NotificationInput } from "@certd/pipeline"; +import axios from "axios"; + +/** + * 文档: https://github.com/botuniverse/onebot-11 + * 教程: https://ayakasuki.com/ + */ + +@IsNotification({ + name: 'onebot', + title: 'OneBot V11 通知', + desc: '通过动态拼接URL发送 OneBot V11 协议消息', + needPlus: false, +}) +export class OneBotNotification extends BaseNotification { + // 基础服务地址(不含路径) + @NotificationInput({ + title: '服务地址', + component: { + placeholder: 'http://xxxx.xxxx.xxxx', + }, + helper: 'OneBot 服务的基础地址(不包含action路径)', + required: true, + rules: [ + { + validator: (value) => /^https?:\/\/\S+$/.test(value), + message: '请输入有效的HTTP/HTTPS地址' + } + ] + }) + baseUrl = ''; + + // 目标类型选择 + @NotificationInput({ + title: '目标类型', + component: { + name: 'a-select', + options: [ + { value: 'group', label: '群聊' }, + { value: 'private', label: '私聊' }, + ], + }, + required: true, + helper: '选择消息发送的目标类型', + }) + targetType = 'group'; + + // 目标ID配置 + @NotificationInput({ + title: '目标ID', + component: { + placeholder: '123456789', + }, + helper: '群聊ID或用户ID(纯数字)', + required: true, + rules: [ + { + validator: (value) => /^\d+$/.test(value), + message: 'ID必须为纯数字' + } + ] + }) + targetId = ''; + + // 鉴权密钥(非必填) + @NotificationInput({ + title: '鉴权密钥', + component: { + placeholder: 'xxxxxxxxxx', + }, + helper: '(选填)访问API的授权令牌(无token时留空)', + required: false, // 关键修改点 + }) + accessToken = ''; + + // 构建完整请求URL(支持无token场景) + private buildFullUrl(): string { + const action = this.targetType === 'group' + ? 'send_group_msg' + : 'send_private_msg'; + + let url = `${this.baseUrl}/${action}`; + + // 动态添加access_token参数(仅当存在时) + if (this.accessToken) { + url += `?access_token=${encodeURIComponent(this.accessToken)}`; + } + + return url; + } + + // 构建消息内容 + private buildMessage(body: NotificationBody): string { + return body.title + ? `${body.title}\n${body.content}` + : body.content; + } + + // 构建请求体(动态字段) + private buildRequestBody(body: NotificationBody): object { + return { + [this.targetType === 'group' ? 'group_id' : 'user_id']: Number(this.targetId), + message: this.buildMessage(body), + auto_escape: false + }; + } + + // 发送通知主逻辑 + async send(body: NotificationBody) { + const fullUrl = this.buildFullUrl(); + const requestBody = this.buildRequestBody(body); + + try { + console.debug("[ONEBOT] 最终请求URL:", fullUrl); + console.debug("[ONEBOT] 请求体:", JSON.stringify(requestBody)); + console.debug("[ONEBOT] 使用Token:", !!this.accessToken); // 明确token使用状态 + + const response = await axios.post(fullUrl, requestBody, { + timeout: 5000, + headers: { + 'Content-Type': 'application/json', + 'User-Agent': 'Certd-Notification/1.0' + } + }); + + // 响应验证(保持不变) + if (response.data?.retcode !== 0) { + throw new Error(`[${response.data.retcode}] ${response.data.message}`); + } + return response.data; + } catch (error) { + console.error('[ONEBOT] 请求失败:', { + url: fullUrl, + tokenUsed: !!this.accessToken, // 记录token使用状态 + error: error.response?.data || error.message + }); + throw new Error(`OneBot通知发送失败: ${error.message}`); + } + } +} \ No newline at end of file From 58b7fbcf7587880d4b419f63e797b03937327fe9 Mon Sep 17 00:00:00 2001 From: greper Date: Thu, 7 Aug 2025 08:59:47 +0800 Subject: [PATCH 3/4] Potential fix for code scanning alert no. 26: Clear-text logging of sensitive information (#480) Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- packages/ui/certd-server/test/plugins/51dns.test.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/certd-server/test/plugins/51dns.test.mjs b/packages/ui/certd-server/test/plugins/51dns.test.mjs index e068ff6e..56241d75 100644 --- a/packages/ui/certd-server/test/plugins/51dns.test.mjs +++ b/packages/ui/certd-server/test/plugins/51dns.test.mjs @@ -54,7 +54,7 @@ async function login() { 'redirectTo': 'https://www.51dns.com/domain', '_token': _token } - console.log(JSON.stringify(obj, null, 2)) + // console.log(JSON.stringify(obj, null, 2)) // Avoid logging sensitive data const res2 = await instance.request({ url: 'https://www.51dns.com/login', method: 'post', From 5ec025a3b9488ce5f953f6e85285e21c661474c0 Mon Sep 17 00:00:00 2001 From: greper Date: Thu, 7 Aug 2025 09:57:17 +0800 Subject: [PATCH 4/4] Potential fix for code scanning alert no. 31: Incomplete string escaping or encoding (#479) Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- .../src/modules/pipeline/service/pipeline-service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts index 89e862f1..9ab49853 100644 --- a/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts +++ b/packages/ui/certd-server/src/modules/pipeline/service/pipeline-service.ts @@ -461,7 +461,7 @@ export class PipelineService extends BaseService { cron = cron.replace("* *", "0 0"); } if (cron.startsWith("*")) { - cron = cron.replace("*", "0"); + cron = cron.replace(/\*/g, "0"); } const triggerId = trigger.id; const name = this.buildCronKey(pipelineId, triggerId);