软件代码缺陷检测技术

 2022-07-29 09:07

论文总字数:19639字

摘 要

代码缺陷是软件缺陷的重要组成部分,指产生于程序编程阶段可能会对系统质量造成影响的代码结构。为了消除或者降低代码缺陷为系统带来的影响,我们需要对代码缺陷进行检测。冗余代码缺陷是一种比较常见的代码缺陷,不仅影响着软件的测试评估和运行效率,同时还存在着一些安全隐患,但是当前对于冗余代码缺陷的检测工具较少,本文的主要工作是代码缺陷中的冗余代码缺陷的检测,针对此缺陷的检测提出了一个基于控制结构的静态冗余代码缺陷检测模型,该模型首先对源代码进行词法分析生成TOKEN序列建立复合语句结构信息表,精简了程序的控制依赖关系。在此模型的基础上实现对幂等操作、死代码、冗余的赋值三种冗余代码缺陷进行检测,最后根据这三种缺陷的检测结果,给出缺陷检测报告。

本文使用了一些开源的C语言代码对该模型进行测试,检测到了一些真正的缺陷,此外还进行了仿真实验,实验结果表明本文所提出的缺陷检测模型确实能够有效地检测出代码中的三种冗余代码缺陷,该模型能为这些开源项目的进一步完善提供到帮助,方便了开发人员对此类缺陷的检测和节省了此类缺陷检测检测成本,进一步提升了软件的质量。

关键词:冗余代码,TOKEN序列,静态分析

Abstract

Code defects are an important part of software defects. They refer to the code structures that may affect the system quality due to program programming. In order to eliminate or reduce the impact of code defects on the system, we need to detect code defects. Redundancy code defect is a common code defect, which not only affects the software test evaluation and operation efficiency, but also has some security risks. However, there are fewer current detection tools for redundant code defects. The main work of this paper is the detection of redundant code defects in code defects. A static redundancy code defect detection model based on control structure is proposed for the detection of this defect, the model firstly performs lexical analysis on the source code to generate a TOKEN sequence to establish a compound statement structure information table, and simplifies the control dependence of the program. Based on this model, three redundant code defects such as idempotent operation, dead code, and redundant assignment are detected. Finally, a defect inspection report is given based on the detection results of these three defects.

This article uses a number of open source C language code to test the model, detected that the redundant code does exist in some open source projects, this model can provide help for the further improvement of these open source projects, greatly facilitate the development staff The detection of such defects and saves the cost of detection and detection of such defects, further improving the quality of the software.

KEY WORDS: redundant code, TOKEN, static analysis

目录

摘要 I

Abstract II

第一章 绪论 1

1.1 课题研究的背景和意义 1

1.2 文献综述 1

1.3 冗余代码缺陷的分类 3

1.4 课题主要研究内容 3

1.5 本文的章节安排 3

第二章 冗余代码缺陷检测涉及关键技术 4

2.1 程序的静态分析 4

2.2 词法分析生成TOKEN序列 4

2.3 复合语句控制结构信息表 5

2.4 本章小结 5

第三章 冗余代码缺陷检测方法 6

3.1 冗余代码缺陷检测流程 6

3.2 幂等操作 6

3.2.1 幂等操作定义 6

3.2.2 幂等操作检查器设计思路 6

3.2.3 幂等操作示例 7

3.3 冗余的赋值 7

3.3.1 冗余的赋值定义 7

3.3.2 冗余的赋值检查器设计思路 7

3.3.3 冗余的赋值检查器算法描述 8

3.3.4 冗余的赋值检测流程图 9

3.3.5 冗余的赋值示例 10

3.4 死代码 11

3.4.1 死代码定义 11

3.4.2 死代码检查器设计思路 11

3.4.3 死代码检查器算法描述 11

3.4.4 死代码检测流程图 13

3.4.5 死代码示例 14

3.5 本章小结 15

第四章 冗余代码缺陷检测系统设计与实现 16

4.1 冗余代码缺陷检测系统的设计 16

4.2 冗余代码缺陷检测系统的实现 16

4.3 本章小结 18

第五章 实验结果和分析 19

5.1 实验环境 19

5.2 实际开源代码缺陷检测和结果分析 19

5.2.1 开源代码缺陷检测 19

5.2.2 开源代码缺陷检测结果分析 20

5.3 人工注入缺陷检测和结果分析 20

5.3.1 人工注入缺陷检测 20

5.3.2 人工注入缺陷检测结果分析 21

5.4 本章小结 21

第六章 结论 22

6.1 结论 22

6.2 本文主要完成的工作 22

6.3 存在的问题 22

6.4 研究展望 22

致谢 24

参考文献 25

绪论

课题研究的背景和意义

随着科学技术的不断进步,软件行业也在进行着飞速的发展,如今各行各业基本也已经离不开软件的身影,完全融入人们的生活和企业发展之中,为中国的经济快速发展提供了强大的动力支撑。根据2017年工信部在网上公布的《2017 年软件行业经济运行情况》,我国在2017年的信息技术服务行业的创收为5.5万亿元,和去年相比增长了13.9%。

与此同时,在软件行业不壮大的同时,软件结构也趋于更加的复杂化,而由此产生的软件错误也发生得更加的频繁。而这些产生的错误轻微的可能只会造成某台个人电脑的崩溃,但严重也可以导致一整个工作体系崩塌。如2017年导致大量用户数据被锁定加密无法访问的Wannacry勒索病毒。而且随着硬件容错能力的不断提高,软件缺陷逐渐成为影响软件可靠性的主要因素。

剩余内容已隐藏,请支付后下载全文,论文总字数:19639字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;