Skip to content

Commit 907ba93

Browse files
committed
chore: add repository security configuration
1 parent f557e06 commit 907ba93

5 files changed

Lines changed: 182 additions & 0 deletions

File tree

.coderabbit.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
language: zh-CN
2+
early_access: false
3+
4+
reviews:
5+
profile: assertive
6+
request_changes_workflow: false
7+
high_level_summary: true
8+
review_status: true
9+
collapse_walkthrough: false
10+
poem: false
11+
12+
path_filters:
13+
- "!node_modules/**"
14+
- "!dist/**"
15+
- "!data/**"
16+
- "!.codex/**"
17+
- "!AGENTS.md"
18+
- "!package-lock.json"
19+
20+
path_instructions:
21+
- path: "src/**/*.ts"
22+
instructions: |
23+
重点审查 Telegram 双向转发、管理员白名单、限流、封禁、会话销毁和数据库写入逻辑。
24+
不要建议绕过 Telegram 隐私限制;外部用户必须先主动联系 bot。
25+
任何可能导致非白名单成员代发、bot 自己消息回环、Topic 错路由或用户数据泄露的问题都应标为高优先级。
26+
依赖和脚本要兼顾 Serv00/FreeBSD,不要轻易建议恢复 libsql、better-sqlite3、esbuild、tsx 或直接执行 tsc 的路径。
27+
28+
- path: "src/app/config.ts"
29+
instructions: |
30+
配置审查要关注 .env 缺失值、默认值安全性、shell 环境变量优先级,以及 token/API key 不被记录到日志。
31+
32+
- path: "src/bot/telegram/**/*.ts"
33+
instructions: |
34+
Telegram 适配层审查要关注 message_thread_id 路由、copyMessage 降级、Forum Topic 创建/删除、命令不外发、bot 自身消息不回环。
35+
管理群消息必须限制在 TELEGRAM_MANAGEMENT_CHAT_ID,代发必须限制在 TELEGRAM_ADMIN_USER_IDS。
36+
37+
- path: "src/core/**/*.ts"
38+
instructions: |
39+
核心业务审查要关注会话状态、封禁、限流、投递重试、消息保留、会话销毁和 AI 草稿失败隔离。
40+
AI 草稿不得自动发送给外部用户,失败不应阻断主消息投递。
41+
42+
- path: "src/db/**/*.ts"
43+
instructions: |
44+
数据库审查要关注 SQLite schema 迁移幂等性、删除级联、过期清理是否只清理预期字段,以及是否可能残留坏 Topic 映射。
45+
46+
- path: ".github/**"
47+
instructions: |
48+
GitHub 工作流审查要关注最小权限、依赖安装可复现、Node 24、CI 与 CodeQL 是否能在 pull_request 和 main push 上运行。
49+
50+
- path: "**/*.md"
51+
instructions: |
52+
面向用户的文档默认使用简体中文。README 保持项目门面和导航,详细部署内容应指向 GitHub Wiki。
53+
不要在文档中加入真实 token、API key、用户 ID、数据库内容或私密部署信息。
54+
55+
chat:
56+
auto_reply: true

.github/dependabot.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
day: monday
8+
time: "09:00"
9+
timezone: Asia/Shanghai
10+
open-pull-requests-limit: 5
11+
labels:
12+
- dependencies
13+
- security
14+
groups:
15+
npm-production:
16+
dependency-type: production
17+
npm-development:
18+
dependency-type: development
19+
20+
- package-ecosystem: github-actions
21+
directory: /
22+
schedule:
23+
interval: weekly
24+
day: monday
25+
time: "09:30"
26+
timezone: Asia/Shanghai
27+
open-pull-requests-limit: 5
28+
labels:
29+
- dependencies
30+
- github-actions

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
verify:
14+
name: Verify
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: "24"
24+
cache: npm
25+
26+
- name: Install dependencies
27+
run: npm ci
28+
29+
- name: Run project verification
30+
run: npm run verify

.github/workflows/codeql.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: CodeQL
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
schedule:
9+
- cron: "24 3 * * 1"
10+
11+
permissions:
12+
actions: read
13+
contents: read
14+
security-events: write
15+
16+
jobs:
17+
analyze:
18+
name: Analyze TypeScript
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Initialize CodeQL
25+
uses: github/codeql-action/init@v3
26+
with:
27+
languages: javascript-typescript
28+
29+
- name: Autobuild
30+
uses: github/codeql-action/autobuild@v3
31+
32+
- name: Perform CodeQL analysis
33+
uses: github/codeql-action/analyze@v3

SECURITY.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 安全策略
2+
3+
## 支持范围
4+
5+
当前项目仍处于早期版本,安全修复优先覆盖 `main` 分支。
6+
7+
## 报告安全问题
8+
9+
请不要在公开 Issue 中披露可被利用的安全细节。建议通过 GitHub Security Advisory 私下报告,或联系仓库维护者后再提供复现信息。
10+
11+
报告时请尽量包含:
12+
13+
- 影响范围和触发条件。
14+
- 复现步骤或最小复现样例。
15+
- 可能泄露的数据类型,例如 Telegram 用户信息、消息正文、bot token 或 AI API key。
16+
- 建议修复方向。
17+
18+
## 敏感数据边界
19+
20+
以下内容不得提交到仓库:
21+
22+
- `.env`
23+
- `data/*.sqlite`
24+
- Telegram bot token
25+
- OpenAI-compatible API key
26+
- 私钥、备份文件、真实用户导出数据
27+
28+
## 默认安全姿态
29+
30+
- 外部用户必须先主动联系 bot;项目不尝试绕过 Telegram 隐私限制。
31+
- 管理员代发必须通过 `TELEGRAM_ADMIN_USER_IDS` 白名单。
32+
- AI 草稿只发送到管理 Topic,不自动回复外部用户。
33+
- 会话删除和到期销毁应同步清理 Telegram Topic 与数据库会话数据。

0 commit comments

Comments
 (0)