This commit is contained in:
retanoj
2020-08-11 15:14:31 +08:00
parent 11e2de14b4
commit 7619a83e97
3 changed files with 60 additions and 0 deletions

View File

@@ -4,6 +4,8 @@
该项目是基于 [snyk-python-plugin](https://github.com/snyk/snyk-python-plugin.git) 的二次开发。
## 关于我们
Websitehttps://security.immomo.com
@@ -12,16 +14,22 @@ WeChat:
<img src="https://momo-mmsrc.oss-cn-hangzhou.aliyuncs.com/img-1c96a083-7392-3b72-8aec-bad201a6abab.jpeg" width="200" hegiht="200" align="center" /><br>
## 版本要求
Python 3.x
## 安装
```
pip install git+https://github.com/momosecurity/mosec-pip-plugin.git
```
## 使用
首先运行 [MOSEC-X-PLUGIN Backend](https://github.com/momosecurity/mosec-x-plugin-backend.git)
@@ -34,12 +42,63 @@ pip install git+https://github.com/momosecurity/mosec-pip-plugin.git
> mosec setup.py --endpoint http://127.0.0.1:9000/api/plugin --only-provenance
```
## 卸载
```
> pip uninstall mosec-pip-plugin
```
## 帮助
```shell script
> mosec --help
usage: mosec [-h] --endpoint ENDPOINT [--allow-missing] [--only-provenance]
[--level LEVEL] [--debug]
requirements
positional arguments:
requirements 依赖文件 (requirements.txt 或 Pipfile)
optional arguments:
-h, --help show this help message and exit
--endpoint ENDPOINT 上报API
--allow-missing 忽略未安装的依赖
--only-provenance 仅检查直接依赖
--level LEVEL 威胁等级 [High|Medium|Low]. default: High
--debug
```
## 使用效果
以 test/vuln-project 项目为例。
红色部分给出漏洞警告from: 为漏洞依赖链Fix version 为组件安全版本。
程序返回值为1表示发现漏洞。返回值为0即为未发现问题。
![usage](./static/usage.jpg)
## 检测原理
MOSEC-PIP-PLUGIN 核心使用`pkg_resources`内置库来提取当前python环境所安装的依赖。
并将环境依赖与传入的requirements.txt等文件中所声明的项目需要的依赖进行比对从而构造当前项目所需的依赖的依赖树。
最终依赖树会交由 [MOSEC-X-PLUGIN-BACKEND](https://github.com/momosecurity/mosec-x-plugin-backend.git) 检测服务进行检测,并返回结果。
相关数据结构请参考 MOSEC-X-PLUGIN-BACKEND [README.md](https://github.com/momosecurity/mosec-x-plugin-backend/blob/master/README.md).
## 开发
#### Pycharm 调试 mosec-pip-plugin

BIN
static/usage.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

View File

@@ -0,0 +1 @@
Django==3.0.1