Safety- and security-critical systems have to be thoroughly tested against their specifications. The state of practice is to have _natural language_ specifications, from which test cases are derived manually - a process that is slow, error-prone, and difficult to scale. _Formal_ specifications, on the other hand, are well-suited for automated test generation, but are tedious to write and maintain. In this work, we propose a two-stage pipeline that uses large language models (LLMs) to bridge the gap: First, we extract _protocol elements_ from natural-language specifications; second, leveraging a protocol implementation, we synthesize and refine a formal _protocol specification_ from these elements, which we can then use to massively test further implementations. We see this two-stage approach to be superior to end-to-end LLM-based test generation, as 1. it produces an _inspectable specification_ that preserves traceability to the original text; 2. the generation of actual test cases _no longer requires an LLM_; 3. the resulting formal specs are _human-readable_, and can be reviewed, version-controlled, and incrementally refined; and 4. over time, we can build a _corpus_ of natural-language-to-formal-specification mappings that can be used to further train and refine LLMs for more automatic translations. Our prototype, AUTOSPEC, successfully demonstrated the feasibility of our approach on five widely used _internet protocols_ (SMTP, POP3, IMAP, FTP, and ManageSieve) by applying its methods on their _RFC specifications_ written in natural-language, and the recent _I/O grammar_ formalism for protocol specification and fuzzing. In its evaluation, AUTOSPEC recovers on average 92.8% of client and 80.2% of server message types, and achieves 81.5% message acceptance across diverse, real-world systems.


翻译:安全关键与安全攸关系统必须依据其规范进行彻底测试。当前实践状态是采用自然语言规范,并从中手动推导测试用例——这一过程缓慢、易错且难以扩展。另一方面,形式化规范非常适合自动化测试生成,但编写和维护过程繁琐。在本工作中,我们提出一个两阶段流水线,利用大语言模型(LLMs)弥合这一鸿沟:首先,我们从自然语言规范中提取协议要素;其次,借助协议实现,我们从这些要素中合成并精炼出形式化的协议规范,进而可将其用于对更多实现进行大规模测试。我们认为这种两阶段方法优于端到端的基于LLM的测试生成,原因在于:1. 它产生一个可审查的规范,保持与原始文本的可追溯性;2. 实际测试用例的生成不再需要LLM;3. 生成的形式化规范具有人类可读性,可被评审、版本控制及增量精炼;4. 随着时间的推移,我们可以构建一个自然语言到形式化规范映射的语料库,用于进一步训练和精炼LLMs以实现更自动化的翻译。我们的原型系统AUTOSPEC通过将方法应用于以自然语言编写的RFC规范,以及近期用于协议规范和模糊测试的I/O语法形式化,在五种广泛使用的互联网协议(SMTP、POP3、IMAP、FTP和ManageSieve)上成功验证了我们方法的可行性。在评估中,AUTOSPEC平均恢复了92.8%的客户端和80.2%的服务端消息类型,并在多样化的真实世界系统中实现了81.5%的消息接受率。

0
下载
关闭预览

相关内容

Python分布式计算,171页pdf,Distributed Computing with Python
专知会员服务
108+阅读 · 2020年5月3日
[CVPR 2021] 序列到序列对比学习的文本识别
专知
10+阅读 · 2021年4月14日
论文浅尝 | Interaction Embeddings for Prediction and Explanation
开放知识图谱
11+阅读 · 2019年2月1日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
VIP会员
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
46+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
Top
微信扫码咨询专知VIP会员