From 958dee355e7b7b9583dc5f01a12dc69218f0a766 Mon Sep 17 00:00:00 2001 From: dqy <1016751306@qq.com> Date: Wed, 15 May 2024 10:45:34 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=92=B0=E5=86=99pip=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/tech_notes.md | 8 +++++++- docs/usage.md | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/docs/tech_notes.md b/docs/tech_notes.md index 3e3f28c..e2abb8e 100644 --- a/docs/tech_notes.md +++ b/docs/tech_notes.md @@ -46,7 +46,13 @@ - **主要应用**:通过爬虫收集漏洞依赖信息并进行汇总,用于判断依赖是否存在漏洞版本。 -## 8. 代码和风险分析 +## 8. 打包 + +本项目支持打包作为pip包进行发布 + +- **主要应用**:通过`wheel`并自行撰写`setup.py`以及`MANIFEST.in`,将项目打包发布 + +## 9. 代码和风险分析 项目中实现了基本的静态代码分析功能,用于识别和报告潜在的安全风险函数调用,如 `system`、`exec` 等。 diff --git a/docs/usage.md b/docs/usage.md index a13bb77..b1f1d12 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -66,6 +66,55 @@ python backdoor_detection.py ./src -o output/report.pdf -m regex - 结果中会标注出每个文件中发现的高风险和中风险函数调用位置。 - 对于依赖检测,结果将标明每个依赖包的安全状态,包括存在安全风险的依赖及其版本。 +## 打包 + +### 打包命令 + +```bash +pip install wheel +python setup.py sdist bdist_wheel +``` + +执行上述命令后,会在 dist 目录下生成 .tar.gz 和 .whl 文件。 + +### 本地安装 + +- 安装 .whl 文件: + +``` bash +pip install dist/my_project-0.1.0-py3-none-any.whl +``` + +- 安装 .tar.gz 文件: + +``` bash +pip install dist/my_project-0.1.0.tar.gz +``` + +### 上传到 PyPI + +- 安装 twine: + +``` bash +pip install twine +``` + +- 使用 twine 上传包到 PyPI: + +``` bash +twine upload dist/* +``` + +需要提供 PyPI 的用户名和密码。如果没有 PyPI 账号,可以在 PyPI 注册。 + +### 使用 PyPI 安装 + +包上传到 PyPI 后,可以通过以下命令安装: + +``` bash +pip install my_project +``` + ## 常见问题处理 - 确保所有路径都正确无误,避免因路径错误导致文件读取失败。