arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2205.04432cs.PLcs.FLcs.LO
收藏

Python代码中AWS最佳实践的静态分析

Static Analysis for AWS Best Practices in Python Code

Rajdeep Mukherjee, Omer Tripp, Ben Liblit, Michael Wilson

摘要:

Amazon Web Services(AWS)是一家全面且广泛采用的云提供商,提供200多种功能齐全的服务,包括计算、数据库、存储、网络和内容交付、机器学习、物联网等。AWS SDK通过API端点提供对AWS服务的访问。但是,不正确地使用这些API可能会导致代码缺陷、崩溃、性能问题和其他问题。本文介绍了自动化静态分析规则,该规则是在用于检测代码缺陷和安全漏洞的商业服务的上下文中开发的,用于识别使用AWS SDK的Python应用程序中与AWS最佳实践的偏差。这些应用程序使用AWS SDK for Python(称为“Boto3”)来访问AWS云服务。然而,对使用云SDK的Python应用程序进行精确的静态分析需要健壮的类型推断来推断云服务客户端的类型。Boto3 API的动态风格对类型解析提出了独特的挑战,服务客户端在实践中使用的过程间风格也是如此。为了支持我们的最佳实践目标,我们提出了一个分层的类型推断策略,它结合了多个类型的分辨率和跟踪策略,在一个阶段的方式。从我们对使用AWS SDK的超过3,000个流行Python GitHub存储库的实验中,我们的分层类型推断系统在推断Python客户端代码中的Boto3客户端时实现了85%的准确率和100%的召回率。此外,我们还提供了八个AWS最佳实践规则的代表性示例,这些规则可检测各种问题,包括分页、轮询和批处理操作。我们根据真实世界的开发人员反馈评估了这些规则的有效性。开发人员已经接受了八条Python规则中的五条中超过85%的建议,以及所有建议的近83%。

英文摘要:

Amazon Web Services (AWS) is a comprehensive and broadly adopted cloud provider, offering over 200 fully featured services, including compute, database, storage, networking and content delivery, machine learning, Internet of Things and many others. AWS SDKs provide access to AWS services through API endpoints. However, incorrect use of these APIs can lead to code defects, crashes, performance issues, and other problems. This paper presents automated static analysis rules, developed in the context of a commercial service for detection of code defects and security vulnerabilities, to identify deviations from AWS best practices in Python applications that use the AWS SDK. Such applications use the AWS SDK for Python, called "Boto3", to access AWS cloud services. However, precise static analysis of Python applications that use cloud SDKs requires robust type inference for inferring the types of cloud service clients. The dynamic style of Boto3 APIs poses unique challenges for type resolution, as does the interprocedural style in which service clients are used in practice. In support of our best-practices goal, we present a layered strategy for type inference that combines multiple type-resolution and tracking strategies in a staged manner. From our experiments across >3,000 popular Python GitHub repos that make use of the AWS SDK, our layered type inference system achieves 85% precision and 100% recall in inferring Boto3 clients in Python client code. Additionally, we present a representative sample of eight AWS best-practice rules that detect a wide range of issues including pagination, polling, and batch operations. We have assessed the efficacy of these rules based on real-world developer feedback. Developers have accepted more than 85% of the recommendations made by five out of eight Python rules, and almost 83% of all recommendations.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑