Skip to main content
QUICK REVIEW

[论文解读] Finding Likely Errors with Bayesian Specifications

Vijayaraghavan Murali, Swarat Chaudhuri|arXiv (Cornell University)|Mar 4, 2017
Software Engineering Research参考文献 23被引用 4
一句话总结

该论文提出了一种贝叶斯框架,通过建模隐藏规范与语法特征的联合分布,从大规模异构代码语料库中学习概率规范。通过将该模型基于目标程序的特征进行条件化,以生成相关规范的后验分布,该框架能够实现对Android应用中异常API使用的高精度检测,在召回率和精确率方面优于以往的概率方法。

ABSTRACT

We present a Bayesian framework for learning probabilistic specifications from large, unstructured code corpora, and a method to use this framework to statically detect anomalous, hence likely buggy, program behavior. The distinctive insight here is to build a statistical model that correlates all specifications hidden inside a corpus with the syntax and observed behavior of programs that implement these specifications. During the analysis of a particular program, this model is conditioned into a posterior distribution that prioritizes specifications that are relevant to this program. This allows accurate program analysis even if the corpus is highly heterogeneous. The problem of finding anomalies is now framed quantitatively, as a problem of computing a distance between a "reference distribution" over program behaviors that our model expects from the program, and the distribution over behaviors that the program actually produces. We present a concrete embodiment of our framework that combines a topic model and a neural network model to learn specifications, and queries the learned models to compute anomaly scores. We evaluate this implementation on the task of detecting anomalous usage of Android APIs. Our encouraging experimental results show that the method can automatically discover subtle errors in Android applications in the wild, and has high precision and recall compared to competing probabilistic approaches.

研究动机与目标

  • 为解决从噪声大、异构的代码语料库中学习稳健且可泛化的程序规范的挑战。
  • 克服传统定性规范在噪声下脆弱且无法处理多种使用模式的局限性。
  • 通过将程序行为建模为从学习到的上下文相关使用模式中的概率偏离,实现准确的静态错误检测。
  • 开发一种可扩展的方法,无需手动指定正确性属性。
  • 通过将统一模型基于程序特定特征进行条件化,优先考虑相关使用模式,从而提升异常检测效果。

提出的方法

  • 该框架学习一个联合概率模型 P(Ψ, X),其中 Ψ 表示隐藏规范,X 表示代码的语法特征。
  • 利用贝叶斯法则计算 P(Ψ|X_F) —— 即基于目标程序 F 的特征 X_F 的规范后验分布,以聚焦于相关使用模式。
  • 使用主题模型从语料库中的API调用序列中发现潜在的规范聚类。
  • 使用循环神经网络(RNN)对给定规范 Ψ 的观测API调用序列 θ 的条件概率 P(θ|Ψ) 进行建模。
  • 异常得分通过后验分布所表示的预期行为分布与实际程序行为之间的Kullback-Leibler散度计算得出。
  • 该方法结合主题模型与RNN,以学习程序行为的分层、上下文感知模型。

实验结果

研究问题

  • RQ1单一概率模型能否有效表示大规模代码语料库中多样且依赖上下文的API使用模式?
  • RQ2如何基于程序特定的语法特征对模型进行条件化,以提升错误检测中的相关性与准确性?
  • RQ3贝叶斯框架能否在检测细微、现实世界中的API误用方面优于现有概率模型?
  • RQ4该框架在面对大规模非结构化代码语料库中的噪声与异质性时,其容忍度如何?
  • RQ5该方法在无需对规范多样性做先验假设的情况下,能否扩展到超大规模代码库?

主要发现

  • 该框架在检测异常Android API使用方面实现了高精度与高召回率,优于其他竞争的概率方法。
  • 该方法成功识别出生产环境中Android应用中难以被传统技术捕获的细微真实世界错误。
  • 通过基于程序特定特征对模型进行条件化,该框架避免了对有效但不常见的使用模式产生低似然得分的问题。
  • 主题模型与RNN的结合使得在单个语料库中有效发现多种不同使用模式成为可能。
  • 该方法对噪声具有鲁棒性,因为其似然计算基于频率与上下文,而非二元正确性。
  • 该框架在原则上可扩展至非常大规模的代码语料库,包括可能的所有公开可用代码。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。