Skip to content

Commit 7ce6810

Browse files
committed
[引入CodeQL安全扫描并迁移至uv包管理器]: 新增自动化代码安全分析工作流,将Python依赖管理从传统pip迁移到更高效的uv工具,提升项目安全性和开发效率
- **安全扫描增强**: 新增CodeQL安全分析工作流,定期自动扫描Python代码安全漏洞,支持push、pull_request和手动触发,提升代码安全性 - **依赖管理现代化**: 将项目依赖管理工具从pip迁移至uv,提供更快的包安装速度和更好的依赖解析,更新README文档详细说明uv使用方法 - **开发环境优化**: 在.gitignore中添加uv.lock文件忽略,更新项目文档包含uv安装指南和清华镜像加速配置,改善开发者体验 - **自动化流程完善**: 配置CodeQL每月定时扫描,忽略文档文件以提升扫描效率,确保代码质量持续监控
1 parent 0b5e741 commit 7ce6810

File tree

3 files changed

+103
-14
lines changed

3 files changed

+103
-14
lines changed

.github/workflows/codeql.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: CodeQL Security Analysis
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**/*.md'
7+
- '**/*.txt'
8+
- '**/.gitignore'
9+
- '**/LICENSE*'
10+
- '**/README*'
11+
branches-ignore:
12+
- 'dependabot/**'
13+
pull_request:
14+
paths-ignore:
15+
- '**/*.md'
16+
- '**/*.txt'
17+
- '**/.gitignore'
18+
- '**/LICENSE*'
19+
- '**/README*'
20+
branches-ignore:
21+
- 'dependabot/**'
22+
schedule:
23+
- cron: '0 0 1 * *' # 每月1号运行
24+
workflow_dispatch:
25+
26+
jobs:
27+
analyze:
28+
name: CodeQL Analysis
29+
runs-on: ubuntu-latest
30+
permissions:
31+
security-events: write
32+
actions: read
33+
contents: read
34+
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v5
38+
with:
39+
fetch-depth: 1
40+
41+
- name: Setup Python
42+
uses: actions/setup-python@v6
43+
44+
- name: Install uv and dependencies
45+
run: |
46+
pip install uv
47+
uv sync --dev
48+
49+
- name: Initialize CodeQL
50+
uses: github/codeql-action/init@v4
51+
with:
52+
languages: python
53+
54+
- name: Autobuild
55+
uses: github/codeql-action/autobuild@v4
56+
57+
- name: Perform CodeQL Analysis
58+
uses: github/codeql-action/analyze@v4

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,5 @@ cython_debug/
162162
# Others
163163
.vscode
164164
logs
165-
movie.parts
165+
movie.parts
166+
uv.lock

README.md

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,39 @@
2323

2424
## 🚀 快速开始
2525

26-
### 安装依赖
26+
### 安装 uv
2727

28-
推荐使用虚拟环境:
28+
首先需要安装 uv - 极速的 Python 包管理器和项目工具链:
29+
30+
**使用 pip 安装(跨平台):**
31+
32+
```bash
33+
pip install uv -i https://pypi.tuna.tsinghua.edu.cn/simple
34+
```
35+
36+
**验证安装:**
37+
38+
```bash
39+
uv --version
40+
```
41+
42+
### 安装项目依赖
43+
44+
使用 uv 管理项目依赖:
2945

3046
```bash
31-
# 创建虚拟环境
32-
python -m venv venv
47+
# 使用 uv 创建虚拟环境并安装所有依赖(一步完成)
48+
uv sync --dev
3349

34-
# 激活虚拟环境 (Linux/macOS)
35-
source venv/bin/activate
50+
# 或者分步执行:
51+
# 1. 创建虚拟环境(默认在 .venv 目录)
52+
uv venv
3653

37-
# 或使用提供的脚本激活
38-
source activate_venv.sh
54+
# 2. 激活虚拟环境 (Linux/macOS)
55+
source .venv/bin/activate
3956

40-
# 安装依赖
41-
pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
57+
# 3. 安装项目依赖(可编辑模式)
58+
uv pip install -e .
4259
```
4360

4461
### 同步依赖文件
@@ -49,10 +66,23 @@ pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
4966
# 生成 requirements.txt
5067
python sync_req.py
5168

52-
# 使用生成的 requirements.txt 安装依赖
53-
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
69+
# 使用 uv 通过 requirements.txt 安装依赖
70+
uv pip install -r requirements.txt
71+
```
72+
73+
### 使用清华镜像加速(可选)
74+
75+
如果需要使用国内镜像源:
76+
77+
```bash
78+
# 设置环境变量使用清华镜像
79+
export UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
80+
uv sync --dev
81+
82+
# 或者单次命令指定镜像
83+
uv pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple
5484
```
5585

5686
### 使用说明
5787

58-
👉 直接 `cd` 进对应目录,`python xxx.py -h` 即可开玩
88+
👉 直接 `cd` 进对应目录,`uv run python xxx.py -h` 查看具体用法

0 commit comments

Comments
 (0)