nocomplexity/codeaudit
GitHub: nocomplexity/codeaudit
一款基于不信任原则的 Python 静态代码安全分析器,用于检测源码漏洞、评估依赖风险并生成可视化审计报告。
Stars: 27 | Forks: 0
# 代码审计

[](https://github.com/nocomplexity/codeaudit)
[](https://pypi.org/project/codeaudit)
[](https://pypi.org/project/codeaudit)
[](https://www.bestpractices.dev/projects/10970)
[](https://nocomplexity.com/documents/codeaudit/intro.html)
[](https://nocomplexity.com/documents/codeaudit/license.html)
[](https://pepy.tech/projects/codeaudit)
Python Code Audit - 基于不信任原则的现代 Python 源代码分析器。
Python Code Audit 是一个用于发现 Python 代码中**安全弱点**的工具。这个静态应用程序安全测试 (SAST) 工具拥有**出色**的功能,可以简化必要的安全任务,使其变得有趣且简单。
该工具专为任何使用或创建 Python 程序并希望了解和缓解潜在安全风险的人而设计。
该工具适用于:
* Python 用户:希望评估其使用的 Python 代码中的安全风险。
* Python 开发者:从专业人士到爱好者,任何希望交付安全 Python 代码的人。
* 具有安全意识的用户:寻求一种简单、快速的方法来深入了解 Python 包或文件中潜在安全漏洞的人。
创建安全的软件可能具有挑战性。该工具凭借其详尽的[文档](https://nocomplexity.com/documents/codeaudit/intro.html),充当您得力的安全助手,让您更轻松地识别和解决漏洞。
## 功能特性
Python Code Audit 具有以下功能特性:
* **漏洞检测**:识别 Python 文件中的安全漏洞,这对于包安全研究至关重要。
* **复杂度与统计**:通过 Python AST 快速、轻量级的[圈复杂度](https://en.wikipedia.org/wiki/Cyclomatic_complexity)计数,报告与安全相关的复杂度。
* **模块使用与外部漏洞**:检测已使用的模块,并报告已使用外部模块的已知漏洞。
* **内联问题报告**:显示带有行号和代码片段的潜在安全问题。
* **外部出口检测**:识别嵌入的 API Key 以及启用与远程服务通信的逻辑,帮助揭示隐藏的数据渗漏路径。
* **HTML 报告**:所有输出均保存为简单的静态 HTML 报告,可在任何浏览器中查看。
## 安装说明
```
pip install -U codeaudit
```
如果您之前已经安装了 **Python Code Audit** 并希望确保使用最新的验证和功能,只需再次运行此命令即可。Python Code Audit 会频繁更新以增加新的检查项。
## 运行 Codeaudit
安装完成后,您可以查看所有已实现命令的概览。只需在终端中输入:
```
codeaudit
```
这将显示所有命令:
```
----------------------------------------------------
_ __ _
|_) \/_|_|_ _ __ / _ _| _ |_| _| o _|_
| / |_| |(_)| | \__(_)(_|(/_ | ||_|(_| | |_
----------------------------------------------------
Python Code Audit - A modern Python security source code analyzer based on distrust.
Commands to evaluate Python source code:
Usage: codeaudit COMMAND [report.html]
Depending on the command, you must specify a local directory, a Python file, or a package name hosted on PyPI.org.Reporting: The results are generated as a static HTML report for viewing in a web browser.
Commands:
overview Generates an overview report of code complexity and security indicators.
filescan Scans Python source code or PyPI packages for security weaknesses.
modulescan Generate a report on known vulnerabilities in Python modules and packages.
checks Creates an HTML report of all implemented security checks.
version Prints the module version. Or use codeaudit [-v] [--v] [-version] or [--version].
Use the Python Code Audit documentation (https://codeaudit.nocomplexity.com) to audit and secure your Python programmes. Explore further essential open-source security tools at https://simplifysecurity.nocomplexity.com/
```
## 示例
通过运行 `codeaudit filescan` 命令,可以基于已实施的 **80 多项验证**来确定 Python 文件的详细安全信息。
`codeaudit filescan` 命令会在 HTML 报告中显示源文件中检测到的所有**潜在**安全问题。
每一行都会显示可能导致安全风险的构造,以及检测到问题的相关代码行。
要扫描 PyPI.org 上的 Python 包是否存在安全问题,请执行:
```
codeaudit filescan [reportname.html]
=====================================================================
Codeaudit report file created!
Paste the line below directly into your browser bar:
file:///home/usainbolt/tmp/codeaudit-report.html
=====================================================================
```

## 许可证
`codeaudit` 根据 [GPL-3.0-or-later](https://spdx.org/licenses/GPL-3.0-or-later.html) 许可证的条款进行分发。
标签:Codeaudit, GraphQL安全矩阵, SAST工具, 多模态安全, 安全专业人员, 安全合规, 安全扫描器, 安全测试, 对称加密, 开发安全, 攻击性安全, 源代码审计, 网络代理, 自动化payload嵌入, 自动化审计, 逆向工具, 错误基检测, 静态代码分析