FeeiCN / Cobra

Source Code Security Audit (源代码安全审计)

Home Page:http://cobra.feei.cn

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

collect_files的文件收集模块出错,会累积之前的项目文件

liusn opened this issue · comments

commented

System and Python Environment

Item Tooltip Value
System uname -a
Python python -V
Cobra python cobra.py

Description

在/cobra/pickup.py文件的165行左右,如下

class Directory(object):
    def __init__(self, absolute_path):
        self.absolute_path = absolute_path

    file_sum = 0
    type_nums = {}
    result = {}
    file = []

其中

    file_sum = 0
    type_nums = {}
    result = {}
    file = []

这几个变量声明成全局变量导致多个项目的文件信息都加在了一起,文件数也越来越多,导致后面的识别语言和框架也出错。
修复建议,将上面几个变量放在初始化函数中,如下:

class Directory(object):
    def __init__(self, absolute_path):
        self.absolute_path = absolute_path
        self.file_sum = 0
        self.type_nums = {}
        self.result = {}
        self.file = []

Steps to Reproduce

  1. [First Step]
  2. [Second Step]
  3. [and so on...]

Expected behavior: [What you expected to happen]

Actual behavior: [What actually happened]