-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathX1_checker.py
More file actions
55 lines (41 loc) · 2.01 KB
/
X1_checker.py
File metadata and controls
55 lines (41 loc) · 2.01 KB
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
55
from libs_checker.checker_args import parse_check_args
from libs_checker.checker_call import project_checker_call
from libs_checker.checker_enum import CheckerKeys
from libs_com.file_path import path_is_exist
from libs_com.utils_dict import merge_dicts_by_key
from libs_com.utils_hash import get_path_hash
from libs_com.utils_json import load_json, dump_json
def main():
args = parse_check_args()
project_path = args.project_path
project_name = args.project_name
rules_file = args.rules_file
workers = args.workers
exclude_keys = args.exclude_keys
save_cache = args.save_cache
filter_lang = args.filter_lang
filter_risk = args.filter_risk
filter_vuln = args.filter_vuln
exclude_ext = args.exclude_ext
limit_size = args.limit_size
chunk_mode = args.chunk_mode
parsed_file = args.parsed_file
call_parser = args.call_parser
import_filter = args.import_filter
black_key = args.black_key
check_results = project_checker_call(project_name, project_path, rules_file, exclude_keys, exclude_ext, filter_lang,
filter_risk, filter_vuln, parsed_file, save_cache, chunk_mode, limit_size,
call_parser, workers, import_filter, black_key)
# 保存分析结果
if check_results:
save_file = args.output or f"{project_name}.{get_path_hash(project_path)}.checker.json"
if path_is_exist(save_file):
print("The historical analysis results are already available. Let's merging and updating....")
check_results = merge_dicts_by_key(check_results, load_json(save_file), unique_key=CheckerKeys.CHECKER_HASH.value)
print(f"The historical analysis results have been combined, and the final results:{len(check_results)}...")
dump_status, dump_error = dump_json(save_file, check_results)
if dump_error:
raise dump_error
print(f"The analysis results have been saved to: {save_file}")
if __name__ == '__main__':
main()