MCPcopy Index your code
hub / github.com/GPTScan/GPTScan

github.com/GPTScan/GPTScan @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
98 symbols 315 edges 17 files 2 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

GPTScan

描述

使用ChatGPT进行逻辑漏洞检测。

如何使用

  1. 安装依赖,

  2. 需要Python 3.10+

  3. 安装依赖:pip install -r requirements.txt

  4. 运行GPTScan

例如,我这边源码存放于/source目录,则运行命令为:

python3.10 main.py -s /sourcecode -o /sourcecode/output.json -k OPEN_AI_API_KEY_xxxxxxxxxxxxx
  1. 查看输出

输出结果位于-o参数指定的位置,在上例中位于/sourcecode/output.json

支持的项目类型

目前支持的项目类型有: - 单文件,即一个sol文件 - 多文件,即一个目录下有多个sol文件,不包括其它外部依赖 - 常见的框架项目,如truffle,hardhat,brownie等

经测试的框架有: - hardhad - truffle - brownie

注意,这个项目不包含编译环境,如Node.js等,需要自行安装。

数据集

论文中用于评估GPTScan的数据集,如下: 1. Web3Bugs: https://github.com/MetaTrustLabs/GPTScan-Web3Bugs 2. DefiHacks: https://github.com/MetaTrustLabs/GPTScan-DefiHacks 3. Top200: https://github.com/MetaTrustLabs/GPTScan-Top200

如何引用这个项目

@inproceedings{sun2024gptscan,
    author = {Sun, Yuqiang and Wu, Daoyuan and Xue, Yue and Liu, Han and Wang, Haijun and Xu, Zhengzi and Xie, Xiaofei and Liu, Yang},
    title = {{GPTScan}: Detecting Logic Vulnerabilities in Smart Contracts by Combining GPT with Program Analysis},
    year = {2024},
    isbn = {9798400702174},
    publisher = {Association for Computing Machinery},
    address = {New York, NY, USA},
    url = {https://doi.org/10.1145/3597503.3639117},
    doi = {10.1145/3597503.3639117},
    booktitle = {Proceedings of the IEEE/ACM 46th International Conference on Software Engineering},
    articleno = {166},
    numpages = {13},
    series = {ICSE '24}
}

Core symbols most depended-on inside this repo

ask_with_timeout
called by 8
src/analyze_pipeline.py
get_function_detail
called by 7
src/antlr4helper/callgraph.py
parseToken
called by 5
src/antlr4helper/SolidityParser.py
get_rel_path
called by 4
src/antlr4helper/callgraph.py
get_callers
called by 3
src/antlr4helper/callgraph.py
prompt_single_yes_no_question
called by 2
src/query_template.py
prompt_multiple_choice_scenarios
called by 2
src/query_template.py
_do_load_config
called by 2
src/tasks.py

Shape

Function 81
Method 14
Class 3

Languages

Python100%

Modules by API surface

src/query_template.py21 symbols
src/antlr4helper/callgraph.py14 symbols
src/static_check.py9 symbols
src/antlr4helper/SolidityParser.py9 symbols
src/analyze_pipeline.py9 symbols
src/tasks.py8 symbols
src/chatgpt_api.py6 symbols
src/falcon_adapter.py5 symbols
src/utils.py4 symbols
src/rich_utils.py3 symbols
src/antlr4helper/utils.py3 symbols
src/antlr4helper/SolidityLexer.py3 symbols

For agents

$ claude mcp add GPTScan \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact