计算机科学 ›› 2025, Vol. 52 ›› Issue (6): 35-43.doi: 10.11896/jsjkx.240300195
胡梦泽1,2,3, 马旭桐1,3, 张豪1,3, 张健1,3
HU Mengze1,2,3, MA Xutong1,3, ZHANG Hao1,3, ZHANG Jian1,3
摘要: C/C++编程语言应用于众多关键领域的软件系统中,在开发时对编程的规范性和语义的明确性有着极高的要求。为了避免不当使用C/C++语言带来潜在的安全问题,国内提出了面向C/C++语言的《C/C++语言编程安全子集》(后简称为GJB8114)。由于标准中规则较多,程序员在开发过程中难免存在不规范的写法,因此实现用自动化的规则检测工具检测相应的编码规则是必要的。而现有的编程规范检查工具对标准的检查并不全面,在针对需要理解程序上下文的规则的检查时,误报率较高甚至不支持检查。对此,将GJB8114中的规则分类并对复杂规则进行定义。通过调研Testbed工具检查GJB8114中的复杂规则的支持程度,总结得到现有工具存在流敏感分析不完善和无法进行跨文件的全局分析这两个问题。采取了结合语法树匹配的流敏感分析方法和跨文件的全局分析方法来解决这些问题。在此基础上,开发得到了CruletFS工具。实验结果表明,与常见的编程规范检查工具Cppcheck,Testbed等相比,CruletFS在检查复杂规则时有更好的效果。在针对规模较大的项目分析时,CruletFS在开销上也优于Cppcheck。这说明相较于已有的方法和策略,所提方法可以在占用开销较低的基础上有效提高复杂规则检查的准确率。
中图分类号:
[1]TIOBE Index [EB/OL].https://www.tiobe.com/tiobe-in-dex/. [2]Top Programming Language 2024 [EB/OL].https://elevatex.de/blog/it-insights/programming-languages-ranking-2024. [3]safe subset of C language for space armament software [S].Commission of Science,Technology and Industry for National Defense,2005. [4]Safe subset of C/C++language programming:GJB8114-2013 [S].General Armaments Department of the People's Liberation Army,2013. [5]Liverpool Data Research Associates.LDRA Testbed-static and dynamic code analysis[EB/OL].http://ldra.com/aerospace-defence/products/ldra-testbed-tbvision/. [6]GAO Q,MA S,SHAO S,et al.CoBOT:static C/C++ bug detection in the presence of incomplete code [C]//Proceedings of the 26th Conference on Program Comprehension.2018:385-388. [7]Shanghai Nayi Technology Co.,Ltd.[EB/OL].https://naive-systems.com/ [8]MA X,YAN J,LI Y,et al.SPrinter:a static checker for finding smart pointer errors in C++ programs[C]//2019 34th IEEE/ACM International Conference on Automated Software Engineering(ASE).IEEE,2019:1122-1125. [9]MA X,YAN J,ZHANG H,et al.Detecting Memory Errors in Python Native Code by Tracking Object Lifecycle with Reference Count[C]//2023 38th IEEE/ACM International Conference on Automated Software Engineering(ASE).IEEE,2023:1429-1440. [10]WANG X F,ZHAO K J,TIAN Z W.Research on Key Technologies of Data Flow Analysis [J].Computer Science,2005,32(12):91-93. [11]SCHUBERT P D,LEER R,HERMANN B,et al.Into theWoods:Experiences from Building a Dataflow Analysis Framework for C/C++ [C]//2021 IEEE 21st International Working Conference on Source Code Analysis and Manipulation(SCAM).IEEE,2021:18-23. [12]YE S,SUI Y,XUE J.Region-based selective flow-sensitivepointer analysis[C]//International Static Analysis Symposium.Cham:Springer,2014:319-336. [13]SUI Y,YE D,XUE J.Detecting memory leaks statically with full-sparse value-flow analysis[J].IEEE Transactions on Software Engineering,2014,40(2):107-122. [14]BALDONI R,COPPA E,D'ELIA D C,et al.A survey of symbolic execution techniques [J].ACM Computing Surveys,2018,51(3):1-39. [15]ZHANG J,ZHANG C,XUAN J F,et al.Recent Progress in Program Analysis[J].Journal of Software,2019,30(1):80-109. [16]FATIMA A,BIBI S,HANIF R.Comparative study on staticcode analysis tools for C/C++[C]//2018 15th International Bhurban Conference on Applied Sciences and Technology(IBCAST).IEEE,2018:465-469. [17]Cppcheck-a tool for static C/C++ code analysis [EB/OL].(2023).https://cppcheck.net. [18]PEREIRA J D,VIEIRA M.On the use of open-source C/C++ static analysis tools in large projects[C]//2020 16th European Dependable Computing Conference(EDCC).IEEE,2020:97-102. [19]KAUR A,NAYYAR R.A comparative study of static codeanalysis tools for vulnerability detectionin C/C++ and Java source code [J].Procedia Computer Science,2020,171:2023-2029. [20]LLVM Team.Clang static analyzer[EB/OL].https://clang.llvm.org/docs/ClangStaticAnalyzer.html. [21]Astrée runtime error analyzer [EB/OL].https://www.absint.com/astree/index.htm. [22]BLANCHET B,COUSOT P,COUSOT R,et al.A static analyzer for large safety-critical software [C]//Proceedings of the ACM SIGPLAN 2003 Conference on Programming Language Design and Implementation.2003:196-207. [23]MINÉ A,DELMAS D.Towards an industrial use of sound static analysis for the verification of concurrent embedded avionics software [C]//2015 International Conference on Embedded Software(EMSOFT).IEEE,2015:65-74. [24]YANG L.The Optimization and Improvement of Software Testing for C Programs [D].Beijing:University of Chinese Academy of Sciences,2018 [25]WANG W.C/C++ Language Programming Safety StandardCompliance Check [D].Beijing:University of Chinese Academy of Sciences,2022 [26]LLVM Team.Libtooling [EB/OL].https://clang.llvm.org/docs/LibTooling.html. [27]LLVM Team.Introduction to the clang ast [EB/OL].https://clang.llvm.org/docs/IntroductionToTheClangAST.html. [28]Fallahi.awesome-cpp[EB/OL].https://github.com/fffaraz/awesome-cpp. [29]LLVM Team.ASTMatch [EB/OL].https://clang.llvm.org/docs/LibASTMatchersReference.html [30]BLACK P E.Juliet 1.3 test suite:Changes from 1.2 [M].US Department of Commerce,National Institute of Standards and Technology, 2018. [31]ZHANG H,LUO J,HU M,et al.Detecting Exception Handling Bugs in C++ Programs[C]//2023 IEEE/ACM 45th International Conference on Software Engineering(ICSE).IEEE,2023:1084-1095. [32]MA X,YAN J,WANG W,et al.Detecting memory-related bugs by tracking heap memory management of C++ smart pointers[C]//2021 36th IEEE/ACM International Conference on Automated Software Engineering(ASE).IEEE,2021:880-891. |
|