陆工大赛题三——漏洞影响版本识别 #5
|
|
@ -0,0 +1,24 @@
|
|||
# 使用官方 Python 镜像作为基础镜像
|
||||
FROM python:3.12
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 复制项目的依赖文件到工作目录
|
||||
COPY requirements.txt .
|
||||
|
||||
# 安装 Python 依赖
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# 复制项目代码到工作目录
|
||||
COPY . .
|
||||
|
||||
RUN ls -l .
|
||||
|
||||
# 创建软链接
|
||||
RUN mkdir -p /data1
|
||||
RUN ln -s /app/dataReource /data1/baolingfeng
|
||||
|
||||
# 设置容器启动时运行的命令
|
||||
#CMD ["python", "./src/main.py"]
|
||||
|
||||
|
|
@ -0,0 +1,71 @@
|
|||
## :rocket: 文件结构
|
||||
代码文件主要分为两个部分:dataResource和src部分。
|
||||
|
||||
### dataResource部分
|
||||
dataResource文件夹中包含data和JarResource。
|
||||
|
||||
data文件夹存放代码运行所需的数据文件。
|
||||
> c_cve_fix_detail.json与java_cve_fix_detail.json提供代码运行所需的被测项目的存储库地址(repo_url)。
|
||||
>
|
||||
> dataset.json提供代码运行所需的项目名称project、漏洞标识符cve_id以及对应的漏洞修复位置fix_commits,并且该文件还是方法的ground-truth。
|
||||
>
|
||||
> verified_cve_with_versions_C.json与verified_cve_with_versions_Java.json是根据dataset.json标注的版本文件,用于验证方法确认的漏洞影响范围。
|
||||
|
||||
JarResource文件夹存放代码运行所需的jar包。
|
||||
> ASTMapEval.jar是V-SZZ方法使用的AST映射算法(用于计算两个版本文件之间代码行变更,Java编写,通过jar调用)。
|
||||
>
|
||||
> iASTMapper.jar是VICLocator方法(我们方法)使用的AST树映射算法(用于计算两个版本文件之间代码行变更,Java编写,通过jar调用)。
|
||||
>
|
||||
> 其他jar包是上面两个jar包执行所需的资源包。
|
||||
|
||||
### src部分
|
||||
src是方法主体部分,包含git_analysis、szz以及8个py文件。git_analysis提供对项目git存储库的分析方法,szz中为SZZ、AG-SZZ、MA-SZZ、V-SZZ、VICLocator五个方法实现了核心算法逻辑。
|
||||
> src/main.py是程序执行入口,包括识别漏洞引入位置以及确定漏洞影响范围。
|
||||
>
|
||||
> src/setting.py中主要用于程序中使用文件夹的统一设定。
|
||||
>
|
||||
> src/resultStat.py是对方法识别漏洞引入位置结果的统计。
|
||||
>
|
||||
> src/version_stat.py是对方法确认漏洞影响范围结果的统计。
|
||||
>
|
||||
> src/identify_duplicated_patch.py用于识别指定commit的重复提交。
|
||||
>
|
||||
> src/extract_tag.py用于引入commits和修复commits之间影响的版本(漏洞影响范围)。
|
||||
>
|
||||
> 其余文件为以上文件提供支撑。
|
||||
|
||||
## :checkered_flag: 环境配置
|
||||
环境配置主要分为软件以及数据准备两部分。
|
||||
|
||||
### 软件准备
|
||||
软件准备如下表。
|
||||
|
||||
| 软件 | 版本 |
|
||||
|--------|------|
|
||||
| python | 3.12 |
|
||||
| java | 21 |
|
||||
|
||||
其余python第三方包如下表。
|
||||
|
||||
| 包名 | 版本 |
|
||||
|---------------------|--------|
|
||||
| GitPython | 3.1.18 |
|
||||
| PyDriller | 1.15.5 |
|
||||
| python_Levenshtein | 0.25.1 |
|
||||
| unidiff | 0.6.0 |
|
||||
|
||||
|
||||
## :computer: 代码运行
|
||||
第一步:执行src/main.py。其中run_all_project()函数,这将为dataset.json中所有项目分别应用五种算法,其结果(漏洞引入位置)保存在“/data1/baolingfeng/results”文件夹中。
|
||||
其中time.txt记录了各个方法的运行耗时。step_oneAndtwo()和step_three()函数,生成漏洞影响范围,其结果保存在“/data1/baolingfeng/results”的vulnerable_versions_{method}.json中。
|
||||
|
||||
第二步:执行src/resultStat.py文件,将评估五个方法识别漏洞引入位置的结果,结果文件放在“/data1/baolingfeng/results/initCommit_stat.csv”中。
|
||||
|
||||
第三步:执行src/version_stat.py文件,将评估vszz和VICLocator确认漏洞影响范围的结果,结果文件存放在“/data1/baolingfeng/results/version_stat.csv”中。
|
||||
|
||||
注意:首次运行代码,会下载dataset.json中涉及的项目到相应文件夹,此步骤需连接网络且较耗费时间(这部分耗时在RQ2中并未计算)。
|
||||
|
||||
生成漏洞影响范围这一步骤也极为耗时,因为它根据漏洞引入位置和修复位置生成漏洞影响范围,需要针对整个存储库执行,此步骤执行大致耗时7h。
|
||||
### 关于Docker镜像
|
||||
推荐构建镜像后(例:docker build -t viclocator:1.1 .),进行容器(docker run -it --rm viclocator:1.1 /bin/sh),使用指令运行代码。
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue