All Projects → SMAT-Lab → Scalpel

SMAT-Lab / Scalpel

Licence: Apache-2.0 license
Scalpel: The Python Static Analysis Framework

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Scalpel

Security Code Scan
Vulnerability Patterns Detector for C# and VB.NET
Stars: ✭ 550 (+212.5%)
Mutual labels:  analysis, static-analysis
Codechecker
CodeChecker is an analyzer tooling, defect database and viewer extension for the Clang Static Analyzer and Clang Tidy
Stars: ✭ 1,209 (+586.93%)
Mutual labels:  analysis, static-analysis
Phan
Phan is a static analyzer for PHP. Phan prefers to avoid false-positives and attempts to prove incorrectness rather than correctness.
Stars: ✭ 5,194 (+2851.14%)
Mutual labels:  analysis, static-analysis
Go Ruleguard
Define and run pattern-based custom linting rules.
Stars: ✭ 402 (+128.41%)
Mutual labels:  analysis, static-analysis
SDA
SDA is a rich cross-platform tool for reverse engineering that focused firstly on analysis of computer games. I'm trying to create a mix of the Ghidra, Cheat Engine and x64dbg. My tool will combine static and dynamic analysis of programs. Now SDA is being developed.
Stars: ✭ 98 (-44.32%)
Mutual labels:  analysis, static-analysis
Binee
Binee: binary emulation environment
Stars: ✭ 408 (+131.82%)
Mutual labels:  analysis, static-analysis
Structured Acceptance Test
An open format definition for static analysis tools
Stars: ✭ 10 (-94.32%)
Mutual labels:  analysis, static-analysis
Chronos
Chronos - A static race detector for the go language
Stars: ✭ 272 (+54.55%)
Mutual labels:  analysis, static-analysis
Dg
[LLVM Static Slicer] Various program analyses, construction of dependence graphs and program slicing of LLVM bitcode.
Stars: ✭ 242 (+37.5%)
Mutual labels:  analysis, static-analysis
Zpa
A parser and source code analyzer for PL/SQL and Oracle SQL.
Stars: ✭ 124 (-29.55%)
Mutual labels:  analysis, static-analysis
Detekt
Static code analysis for Kotlin
Stars: ✭ 4,169 (+2268.75%)
Mutual labels:  analysis, static-analysis
swap-detector
A library for detecting swapped arguments in function calls, and a Clang Static Analyzer plugin used to demonstrate the library.
Stars: ✭ 19 (-89.2%)
Mutual labels:  analysis, static-analysis
Exakat
The Exakat Engine : smart static analysis for PHP
Stars: ✭ 346 (+96.59%)
Mutual labels:  analysis, static-analysis
Phpmnd
PHP Magic Number Detector
Stars: ✭ 431 (+144.89%)
Mutual labels:  analysis, static-analysis
Horusec
Horusec is an open source tool that improves identification of vulnerabilities in your project with just one command.
Stars: ✭ 311 (+76.7%)
Mutual labels:  analysis, static-analysis
Sonar Java
☕️ SonarSource Static Analyzer for Java Code Quality and Security
Stars: ✭ 745 (+323.3%)
Mutual labels:  analysis, static-analysis
Static Analysis
⚙️ A curated list of static analysis (SAST) tools for all programming languages, config files, build tools, and more.
Stars: ✭ 9,310 (+5189.77%)
Mutual labels:  analysis, static-analysis
Krane
Kubernetes RBAC static Analysis & visualisation tool
Stars: ✭ 254 (+44.32%)
Mutual labels:  analysis, static-analysis
Analyzer
🔍 Offline Analyzer for extracting features, artifacts and IoCs from Windows, Linux, Android, iPhone, Blackberry, macOS binaries, emails and more
Stars: ✭ 108 (-38.64%)
Mutual labels:  analysis, static-analysis
sbt-findbugs
FindBugs static analysis plugin for sbt.
Stars: ✭ 47 (-73.3%)
Mutual labels:  analysis, static-analysis

Scalpel: The Python Static Analysis Framework

Documentation Status

Scalpel is a Python Static Analysis Framework. It provides essential program analysis functions for facilitating the implementation of client applications focusing on statically resolving dedicated problems.

Contributing

We will be highly appreciated it if you can contribute to this project. Please feel free to do so by submiting issue reports or directly adding pull requests. We hope to obtain help for:

  1. New features. If you believe your publication/open-source project can be part of our framework, please contact us.
  2. Bug reports.
  3. Docuemntation.
  4. Code refactoring

Setting up Scalpel

Clone the repository of Scalpel and in the root directory simply run:

python -m pip install .

Brief Introduction

Detailed user guides can be found at python-scalpel.readthedocs.io.

We aim to provide Scalpel as a generic Python static analysis framework that includes as many functions as possible (e.g., to easily build inter-function control-flow graph, to interpret the import relationship of different Python modules, etc.) towards facilitating developers to implement their dedicated problem-focused static analyzers. The following figure depicts the current architecture of its design.

Scalpel Design

  • Function 1: Code Rewriter. The code rewriter module is designed as a fundamental function for supporting systematic changes of existing Python programs. Two preliminary usages of this function are to (1) simplify the programs for better static analysis and (2) optimize or repair problematic programs. For supporting the first usage, we integrate into the framework a database including a set of rules indicating how matched code snippets should be transformed. This database should be continuously extended to fulfill the complicated simplification requirements for achieving effective static analysis of Python programs. For supporting the second usage, inspired by the optimization mechanism provided by Soot (one of the most famous static Java program analysis frameworks), we also set up a transformation process with dedicated callback methods to be rewritten by users to optimize Python code based on their customized needs.

  • Function 2: Control-Flow Graph Construction. The control-flow graph(CFG) construction module generates intra-procedural CFGs, which are an essential component in static flow analysis with applications such as program optimization and taint analysis. A CFG represents all paths that might be traversed through a program during its execution. The CFGs of a Python project can be combined with the call graph to generate an inter-procedural CFG of the project.

  • Function 3: Static Single Assignment (SSA) Representation. The static single assignment module provides compiler-level intermediate representations (IR) for code analysis. It can not only be used for symbolic execution, but also for constant propagation. By renaming each variable assignment with different names, we are able to obtain explicit use-def chains, therefore precisely tracking how data flow in the program.

  • Function 4: Alias Analysis. Since variables can point to the same memory location or identical values, the alias analysis function is designed to model such usages. This function can be vital to sound constant propagation. In addition, alias analysis will also benefit type checking as well as API name qualifying.

  • Function 5: Constant Propagation. The constant propagation module will evaluate the actual values for variables at certain program points in different execution paths before runtime. With the actual values known beforehand, we are able to optimize code and detect bugs. The constant propagation will utilize the representation from the SSA module to keep recording values from each assignment for a single variable.

  • Function 6: Import Graph Construction. In python, import flows and relations have been pointed out to be important for API mapping, dependency analysis. Our import graph construction aims to provide a data structure to represent these import relationships across the Python module files in the same project. The import graphs of multiple Python projects can be combined to perform inter-library dataflow analysis.

  • Function 7: Fully Qualified Name Inferrer. Python APIs or function names can be invoked in different ways depending on how they are imported. However, this results in inconveniences to API usage analysis. In this module, we will convert all function call names to their fully-qualified names which are dotted strings that can represent the path from the top-level module down to the object itself. Various tasks can be benefited from this functionality such as understanding deprecated API usage, dependency parsing as well as building sound call graphs.

  • Function 8: Call Graph Construction. A call graph depicts calling relationships between methods in a software program. It is a fundamental component in static flow analysis and can be leveraged in tasks such as profiling, vulnerability propagation, and refactoring. This module addresses the challenges brought by complicated features adopted in Python, such as higher-order functions and nested function definitions, to construct the precise call graphs for given Python projects.

  • Function 9: Type Inference. Python, as a dynamically typed language, faces the problem of being hard to utilize the full power of traditional static analysis. This module infers the type information of all variables including function return values and function parameters in a Python program, making more sophisticated static analysis possible for Python. We utilize backward data-flow analysis and a set of heuristic rules to achieve high precision.

API Documentation

The Scalpel's API documentation is available at python-scalpel.readthedocs.io.


We release Scalpel source code in the hope of benefiting others. You are kindly asked to acknowledge usage of the tool by citing the following article:

@article{li2022scalpel, 
title={Scalpel: The Python Static Analysis Framework}, 
author={Li, Li and Wang, Jiawei and Quan, Haowei}, 
journal={arXiv preprint arXiv:2202.11840}, 
year={2022} 
}

Scalpel is invited to be presented at EuroPython 2022. EuroPython is the oldest and longest running volunteer-led Python programming conference on the planet!

Acknowledgement

This project has been inspired and supported by many existing works. If you think your work appears in this project but has not been mentioned yet, please let us know by any means.

  1. Fuzzyingbook by Andreas Zeller, Rahul Gopinath, Marcel Böhme, Gordon Fraser, and Christian Holler.
  2. Debugging book by Andreas Zeller.
  3. StaticCFG.
  4. PyCG: Practical Call Graph Generation in Python, ICSE 2021.
  5. A Simple, Fast Dominance Algorithm Keith D. Cooper, Timothy J. Harvey, and Ken Kennedy
  6. COS598C Advanced Compilers, Princeton University
  7. Restoring Execution Environments of Jupyter Notebooks
  8. Static Single Assignment Book
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].