一句话:提出基于规则的程序变换技术,临时改写代码以抑制静态分析误报,支持多语言多分析器。
静态分析在软件开发中能有效发现缺陷,但出于理论与实用性考虑,分析工具必须进行近似,导致误报普遍存在,而工具配置与定制对可用性至关重要。开发者通常只能禁用检查或插入抑制注释,现有机制难以满足需求。本文基于一个关键观察:无论分析器选项与实现如何,用户始终可以通过修改程序来影响分析行为。作者提出一种自动化、通用且临时的代码变换技术,采用基于规则的方法,以简单声明式模板描述分析器已知有问题的代码模式所对应的通用语法改动,并将分析器视为黑盒,把程序变换提升为提升分析报告保真度的通用原语。评估使用支持 C、Java 和 PHP 三种语言的五个静态分析器,在最大达 800KLOC 的真实程序上进行,结果表明该方法能有效规避分析实现中长期存在的复杂问题。
Static analysis is a proven technique for catching bugs during software development. However, analysis tooling must approximate, both theoretically and in the interest of practicality. False positives are a pervading manifestation of such approximations---tool configuration and customization is therefore crucial for usability and directing analysis behavior. To suppress false positives, developers readily disable bug checks or insert comments that suppress spurious bug reports. Existing work shows that these mechanisms fall short of developer needs and present a significant pain point for using or adopting analyses. We draw on the insight that an analysis user always has one notable ability to influence analysis behavior regardless of analyzer options and implementation: modifying their program. We present a new technique for automated, generic, and temporary code changes that tailor to suppress spurious analysis errors. We adopt a rule-based approach where simple, declarative templates describe general syntactic changes for code patterns that are known to be problematic for the analyzer. Our technique promotes program transformation as a general primitive for improving the fidelity of analysis reports (we treat any given analyzer as a black box). We evaluate using five different static analyzers supporting three different languages (C, Java, and PHP) on large, real world programs (up to 800KLOC). We show that our approach is effective in sidestepping long-standing and complex issues in analysis implementations.