Skip to main content

Python 包的元静态分析工具

项目描述

我是不是该

我是不是该

我应该是什么?

shouldi是一个运行静态分析工具的工具,可以让您知道您正在考虑安装的任何 python 包中是否存在任何问题。

shouldi类似于Go Report Card 之类的东西。

shouldi处于非常早期的阶段。期待事情发生变化。

安装

$ python3 -m pip install -U shouldi

用法

有几个不同的子命令shoudli

  • 安装
    • 类似于pip install但运行检查以告诉您是否应该安装
  • 利用
    • 将此命令指向任何 Git URL 或目录,它将针对该语言运行适当的静态分析工具
  • 项目
    • 自动发现目录中的项目和这些项目的依赖关系

安装命令

跑强盗和安全。如果任一工具发现任何问题,请告诉运行命令的人不要安装 Python 包。

$ shouldi install insecure-package bandit
bandit is okay to install
Do not install insecure-package! {'safety_check_number_of_issues': 1}

使用命令

给定一个 Git URL 或一个目录,找出代码库是什么语言,并为该语言运行适当的静态分析工具。

每种语言的工具如下。

您必须在系统上安装以下工具

$ shouldi use https://github.com/trekhleb/javascript-algorithms
{'static_analysis': SAResultsSpec(critical=1, high=2941, medium=16, low=41049, report={'npm_audit_output': {'info': 0, 'low': 41049, 'moderate': 16, 'high': 2941, 'critical': 1}})}

项目指挥

给定一个目录,输出一个 JSON 描述在该目录中找到的依赖项。

目前它会自动发现setup.py' install_requires部分或内列出的 Python 依赖项requirements.txt

无法自动识别的依赖项可以在 YAML 文件中指定。

dependencies:
  python:
    name: Python
    url: https://python.org
    license: Python License 2.0

这是在代码库上运行项目命令的示例,shouldi上面deps.yaml添加了无法自动发现的依赖项。

$ shouldi project create -add deps.yaml -- .
{
    "dependencies": [
        {
            "extra": {
                "pypi": {
                    "euuid": "7bd67f47-9972-57fd-8da1-233783b35321",
                    "license": "Apache 2",
                    "name": "aiohttp",
                    "url": "https://pypi.org/pypi/aiohttp",
                    "uuid": null
                }
            },
            "license": "Apache 2",
            "name": "aiohttp",
            "url": "https://github.com/aio-libs/aiohttp",
            "uuid": "a6172a74-11ca-5624-bbf4-2e064084ee95"
        },
        {
            "extra": {
                "pypi": {
                    "euuid": "8ce644e4-20ef-5a24-85bb-0449fb8e2c94",
                    "license": "",
                    "name": "bandit",
                    "url": "https://pypi.org/pypi/bandit",
                    "uuid": null
                }
            },
            "license": null,
            "name": "bandit",
            "url": "https://bandit.readthedocs.io/en/latest/",
            "uuid": "1fa385fc-91ae-59c5-8d4c-220b9820f173"
        },
        {
            "extra": {
                "pypi": {
                    "euuid": "c09eaab1-7676-55b8-96fd-cb50f5dc125c",
                    "license": "MIT license",
                    "name": "safety",
                    "url": "https://pypi.org/pypi/safety",
                    "uuid": null
                }
            },
            "license": "MIT license",
            "name": "safety",
            "url": "https://github.com/pyupio/safety",
            "uuid": "f2cc3711-8652-584d-8d46-7e060398eff4"
        },
        {
            "extra": {
                "pypi": {
                    "euuid": "5143b2bf-be54-5688-8077-efbd038fbdc5",
                    "license": "MIT",
                    "name": "PyYAML",
                    "url": "https://pypi.org/pypi/PyYAML",
                    "uuid": null
                }
            },
            "license": "MIT",
            "name": "PyYAML",
            "url": "https://github.com/yaml/pyyaml",
            "uuid": "406495d7-1ba9-5a7e-bec9-f2a1119d3913"
        },
        {
            "extra": {},
            "license": "Python License 2.0",
            "name": "Python",
            "url": "https://python.org",
            "uuid": "807b7876-01ec-5fef-ad5a-4cc588b97719"
        },
    ]
}

执照

shouldi 是根据MIT 许可证分发的。

这真的叫什么

这个包的真实名称是“DFFML Evaluator for PyPi Packages”。shouldi 主要是命令行调用,我们声称shouldiPyPi 上的包名称,以避免供应链攻击。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

shouldi-0.1.0.post0.tar.gz (23.2 kB 查看哈希)

已上传 source

内置分布

shouldi-0.1.0.post0-py3-none-any.whl (32.3 kB 查看哈希

已上传 py3