8000 GitHub - Q1IQ/WASCII · GitHub
[go: up one dir, main page]

Skip to content
Q1IQPublic

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

WASCII: Wasm Specification-Code Implementation Inspector

WASCII is a novel framework for aligning WebAssembly (WASM) specifications with runtime implementations and validating their correctness. It translates specifications into a structured four-layer checking tree, performs tentative alignment with runtime code, and uses execution-based validation to generate targeted test cases. These tests are consolidated into a conformance suite for differential testing across multiple WASM runtimes, uncovering specification-related inconsistencies.

Setup Instructions

Using Docker is recommended for a consistent build environment.

  1. Build Docker Image:

    docker build -t wascii -f env/Dockerfile .
  2. Run Docker Container: Mount the current directory to /workspace for file access.

    # Basic run
    docker run -it -v $(pwd):/workspace -w /workspace wascii /bin/bash
    
    # Run with debugging capabilities (required for GDB/ptrace)
    docker run -it --cap-add=SYS_PTRACE --security-opt seccomp=unconfined \
        -v $(pwd):/workspace -w /workspace wascii /bin/bash

Usage

1. Specification to Check Tree

Convert WASM specifications into a structured checking tree using both pattern-based and LLM-based methods, then merge the results.

  • Download Specifications:

    ./preprocess/download_spec.sh [--eval]

    Output: Eval/specsource/

  • Generate Pattern-Based Tree:

    python3 preprocess/merge_valid_check_trees.py [--output xxx.yaml]

    Output: Eval/check_tree/spec/constraint_tree_valid.yaml

  • Generate LLM-Based Tree:

    python3 preprocess/extract_paragraphs.py
    python3 -m check_tree.traverse_spec_to_ir

    Outputs: Eval/check_tree/spec/extracted_paragraphs.json, Eval/check_tree/spec/constraint_tree_paragraphs.yaml

  • Merge Trees:

    python3 preprocess/merge_check_trees.py Eval/check_tree/spec/constraint_tree_valid.yaml Eval/check_tree/spec/constraint_tree_paragraphs.yaml -o Eval/check_tree/spec/merged_tmp.yaml
    python3 preprocess/process_duplicate_keywords.py Eval/check_tree/spec/merged_tmp.yaml Eval/check_tree/spec/merged.yaml

    Output: Eval/check_tree/spec/merged.yaml

2. Code to Check Tree

Prepare the runtime source code, build a CodeQL database, and generate a check tree using LLMs.

  • Download Source Code: For evaluation, use the --eval flag to fetch the specific version.

    python3 ./preprocess/create_databases.py --source-dir /workspace/Eval/source --download-only [--eval]
  • Build CodeQL Database:

    python3 ./preprocess/create_databases.py --source-dir /workspace/Eval/source --databases-dir /workspace/Eval/qldatabase --codeql-path /opt/codeql/codeql --build-only [--eval]
  • Parse Units: Extract units entry functions, retaining units that appear at least twice.

    python3 preprocess/parse_unit.py
  • Build Call Graph and Extract Statements: Generate control flow graphs (CFG) and cache results (one-time effort).

    python3 -m cfg.init_databases --mode statements-cg --process-level 2 --log-level ERROR
  • Generate Code-Based Tree: Use LLMs to convert code into a checking tree.

    python3 -m check_tree.traverse_code_to_ir

3. Alignment Validation and Bug Detection

Run the full validation pipeline to align trees, generate test cases, and perform differential testing across runtimes.

Sample Generation:

python3 -m verifier.entry_point --all [--runtime runtime_name] [--max-iteration 8] [--jobs 32]

Differential Testing:

python3 -m verifier.differential_testing --all

Configuration

Before running, configure the following files in the config/ directory:

  1. config/llm_config.json: Set your LLM API credentials.

    {
        "api_key": "YOUR_API_KEY_HERE",
        "openrouter_api_key": "YOUR_OPENROUTER_API_KEY_HERE",
        ...
    }
  2. config/env.json: Set your Docker container ID (if running inside a container).

    {
        "docker_container_id": "YOUR_CONTAINER_ID_HERE"
    }
  3. Runtime configurations: config/*.yaml files contain settings for different WASM runtimes (V8, WebKit, WAMR, WasmEdge, Wasm3, WABT, Gecko).

Project Structure

WASCII/
├── preprocess/          # Specification and code preprocessing
├── check_tree/          # Check tree generation and traversal
├── cfg/                 # Control flow graph building
├── verifier/            # Validation and differential testing
├── config/              # Configuration files
├── env/                 # Docker environment
├── util/                # Utility functions
├── BaseMachine/         # Base state machine implementation
└── Data/                # Benchmark and auxiliary data

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0