一句话:提出 XPress,用差分测试自动生成 XML 文档与 XPath 查询,发现六个 XML 处理器中的 27 个独特缺陷。
XML 是广泛使用的数据存储与传输格式,许多 XML 处理器支持用于抽取元素的查询语言 XPath。这些系统可能存在逻辑缺陷,即返回错误结果。作者提出 XPress 系统,以差分测试作为测试预言:对同一测试输入比较多个系统的输出,通过结果不一致识别缺陷。XPress 同时生成 XML 文档与 XPath 查询,并选取一个目标节点(targeted node)来引导查询生成过程,使其引用该节点相关的上下文(如标签名和属性),并在继续扩展查询前保证谓词求值为真,从而生成能计算出非空结果的有意义查询。作者在 BaseX、eXist-DB、Saxon、PostgreSQL、libXML2 以及一个商业数据库系统共六个成熟 XML 处理器上评估,共发现 27 个独特缺陷,其中 25 个已被开发者确认,20 个已被修复。XPress 效率较高,在 BaseX 上 24 小时内发现 12 个独特缺陷,速度是朴素随机生成的两倍。
Extensible Markup Language (XML) is a widely used file format for data storage and transmission. Many XML processors support XPath, a query language that enables the extraction of elements from XML documents. These systems can be affected by logic bugs, which are bugs that cause the processor to return incorrect results. In order to tackle such bugs, we propose a new approach, which we realized as a system called XPress. As a test oracle, XPress relies on differential testing, which compares the results of multiple systems on the same test input, and identifies bugs through discrepancies in their outputs. As test inputs, XPress generates both XML documents and XPath queries. Aiming to generate meaningful queries that compute non-empty results, XPress selects a so-called targeted node to guide the XPath expression generation process. Using the targeted node, XPress generates XPath expressions that reference existing context related to the targeted node, such as its tag name and attributes, while also guaranteeing that a predicate evaluates to true before further expanding the query. We tested our approach on six mature XML processors, BaseX, eXist-DB, Saxon, PostgreSQL, libXML2, and a commercial database system. In total, we have found 27 unique bugs in these systems, of which 25 have been verified by the developers, and 20 of which have been fixed. XPress is efficient, as it finds 12 unique bugs in BaseX in 24 hours, which is 2× as fast as naive random generation. We expect that the effectiveness and simplicity of our approach will help to improve the robustness of many XML processors.