-
Notifications
You must be signed in to change notification settings - Fork 43
/
cli.py
54 lines (39 loc) · 2.18 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import module
import utils
import typing
class ChatGPTScan():
"""
ChatGPTScan help summary page
A white box code scan powered by ChatGPT
Example:
python chatgptscan.py common_scan --project ./benchmark --language "['python']" --include "['directory']" --proxy http://127.0.0.1:7890
python chatgptscan.py common_scan --project ./go-sec-code --language "['go']" --include "['controllers/cmdi.go','utils']" --proxy http://127.0.0.1:8080
python chatgptscan.py taint_sink_scan --project ./benchmark --language "['python']" --sink "os.system()" --exclude "['directory/exclude.go']"
Note:
--project path to target project
--language languages of the project, decide which file extension will be loaded
--include files send to ChatGPT, relative directory or relative filepath, match by prefix
--exclude files not send to ChatGPT, relative directory or relative filepath, match by prefix
--sink decrible your sink, only works in taint_sink_scan
--key openai api key, also get from environment variable OPENAI_API_KEY
--proxy openai api proxy
--dry dry run, not send files to ChatGPT
"""
def common_scan(self, project: str = "", language: typing.List[str] = [], include: typing.List[str] = [], exclude: typing.List[str] = [], key="", proxy="", dry=False):
"""
scan project file and output report
"""
utils.check_params(project=project, language=language)
res = module.common_scan(project, language, include,
exclude, key, proxy, dry)
if res:
utils.dump(res)
def taint_sink_scan(self, project: str = "", language: typing.List[str] = [], sink: str = "", include: typing.List[str] = [], exclude: typing.List[str] = [], key="", proxy="", dry=False):
"""
scan project and output taint path to sink
"""
utils.check_params(project=project, language=language, sink=sink)
res = module.taint_sink_scan(
project, language, sink, include, exclude, key, proxy, dry)
if res:
utils.dump(res)