Giter VIP home page Giter VIP logo

codeauditor's Introduction

CodeAuditor

python代码审计工具

PyCodeAuditor

CodeAuditor 是一个 Python 代码审计工具,能够遍历指定目录中的所有 Python 文件,并根据预设的规则库进行代码审计,最后生成审计报告。

安装

本工具目前未提供安装包,你可以直接克隆代码库到本地使用。同时,你需要安装 tqdm 进度条库。

# 克隆代码库
git clone https://github.com/TTSecTeam/CodeAuditor.git

# 进入代码库目录
cd CodeAuditor

# 安装 tqdm
pip install tqdm

+------+     +----------------+     +------------------+     +----------------+     +-----+
| User | --> | Code Parser    | --> | Rule Execution   | --> | Report Generator| --> | CLI |
|      |     | (AST creation) |     | Engine           |     |                 |     | /UI |
+------+     +----------------+     +------------------+     +----------------+     +-----+
                                     ^
                                     |
                                     |
                             +----------------+
                             |  Rule Library  |
                             | (Plugin System)|
                             +----------------+


架构设计

代码解析器(Code Parser):该模块的任务是接收输入(可能是一个文件,一个文件夹,甚至是一个git仓库),并将其中的Python代码转换为可供后续处理的形式。在Python中,通常可以通过使用ast库来解析代码,将代码转换为抽象语法树(AST)。

规则库(Rule Library):规则库包含了用于识别问题的所有规则。每个规则都会定义一种特定的问题类型,包括问题的描述、如何检测问题,以及可能的修复建议。规则可能需要查找特定类型的AST节点,或者分析节点的某些特性。

规则执行引擎(Rule Execution Engine):规则执行引擎会对每个规则进行遍历,对于每个规则,引擎会遍历AST的所有节点,查找匹配该规则的问题。对于每个找到的问题,引擎将创建一个报告,其中包含问题的位置,相关的规则,以及可能的修复建议。

报告生成器(Report Generator):报告生成器会收集规则执行引擎的所有报告,然后生成一个总的报告。这个报告可以以各种格式呈现,比如纯文本,HTML,或者JSON。报告中应该包含每个找到的问题的详细信息,以及整体的统计信息。

CLI/UI:用户需要一种方式来使用这个工具,这可能是一个命令行界面,或者一个更复杂的图形用户界面。这个界面需要让用户能够选择要检查的代码,选择要使用的规则,以及查看生成的报告。

插件系统(Plugin System):为了提高工具的可扩展性,可以添加一个插件系统,允许用户或第三方开发者添加自己的规则或修改现有规则。插件系统应该提供一个简单的API,让开发者能够方便地定义新的规则,包括问题的检测和修复。

codeauditor's People

Contributors

rockmelodies avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.