Skip to content

KSU-SDML/Statica

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Statica

Statica is a compilation-independent tool designed to detect static methods candidates in C# systems.

Prerequisites

Before running Statica, you must install srcML and Stereocode:

  1. srcML: An infrastructure for the exploration, analysis, and manipulation of source code.
  2. Stereocode: A static analysis tool that detects and annotates class and function stereotypes using srcML input.

You will also need Python 3.12+ and a valid Google Gemini API Key.

Installation

  1. Clone the Statica repository and navigate to the project root:

    git clone https://github.com/KSU-SDML/Statica.git
    cd Statica
  2. Install the required Python packages:

    pip install langgraph langchain-core langchain-google-genai google-genai pydantic

Setup

Statica relies on the Gemini API for evaluating external interface inheritance. You must provide a valid API key. You can set this as an environment variable prior to execution:

Linux/macOS:

export GOOGLE_API_KEY="your_api_key_here"

Windows (Command Prompt):

set GOOGLE_API_KEY="your_api_key_here"

(If the environment variable is not found during execution, Statica will securely prompt you to enter it in the terminal).

Usage

Running Statica is a two-step process. First, you must generate the required stereotype metadata, and then pass that metadata into the Statica pipeline.

Step 1: Generate Metadata

Use srcML and Stereocode to process your target C# system. This will generate the *.metadata.csv file that Statica requires.

# Convert your source code into a srcML archive
srcml --position system.zip -o system.xml

# Run Stereocode to annotate stereotypes and generate the metadata CSV
stereocode system.xml -b -d -i -t

Step 2: Run Statica

Pass the generated CSV file into statica.py.

python statica.py system.metadata.csv

Optional Arguments

  • --output_file_path: Specify a custom name and path for the final Statica results. By default, it will save as output.csv in the root directory.

Example:

python statica.py Files-4.0.24.metadata.csv --output_file_path my_results.csv

Output

Statica will output a CSV file detailing the analysis of all non-degenerate and degenerate instance methods. The CSV contains the following columns:

  • method_name: The name of the evaluated method.
  • line_number: The line number where the method is defined.
  • file_name: The source file containing the method.
  • to_static: A boolean (True/False) indicating if the method is safely eligible for static conversion.
  • reasoning: The pipeline stage or condition that led to the method's approval or rejection (e.g., Direct Analysis, Cascading Analysis, Cascading + LLM).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages