Skip to main content

Efficient grammar-based fuzzer.

Project description

Syntax Symphony

Overview

Syntax Symphony is a powerful fuzzer designed to automatically generate test inputs for various applications based on user-defined grammars. The fuzzer leverages the grammar rules to create meaningful and diverse input data, facilitating robust testing of applications. In order to achieve high diversity and coverage of grammar rules, it uses k-coverage, as discussed by Havrikov et al.. This work has been greatly influenced by the concepts and ideas outlined in the Fuzzing Book.

With Syntax Symphony, you can enhance the quality and reliability of your software by generating a comprehensive set of test cases effortlessly. Start fuzzing today and make your software more robust against unexpected inputs!

Getting Started

Prerequisites

  • Python 3.10 or higher

Installation

From PyPI

pip install syntax-symphony

From Source

  1. Clone the repository:
git clone
cd syntax_symphony
  1. We recommend creating a virtual environment to install the dependencies:
python -m venv venv
source venv/bin/activate
python -m pip install -r requirements.txt
  1. Install locally (add flag -e to install in editable mode):
pip install .
  1. To build the package:
python -m pip install build
python -m build

This should create the package in the dist/ directory.

CLI

Syntax Symphony provides a command-line interface (CLI) to interact with the fuzzer. The CLI allows you to specify the grammar file, the number of test cases to generate, and the output directory to save the generated test cases among others.

Example usage:

# Generate 100 test cases using the grammar file examples/expr_grammar.json
ssfuzz -g examples/expr_grammar.json -c 100

# Save the output in the directory out/
ssfuzz -g examples/expr_grammar.json -c 100 -d out

# Set the start symbol
ssfuzz -g examples/expr_grammar.json -c 100 --start begin

# Set the file extension
ssfuzz -g examples/expr_grammar.json -c 100 -e json

Full syntax:

ssfuzz [-h] -g FILE [-s SYMBOL] -c NUMBER [-d DIR] [-e EXT] [--max-depth NUMBER] [--min-depth NUMBER] [-k NUMBER]

Syntax Symphony Fuzzer

options:
  -h, --help            show this help message and exit
  -g FILE, --grammar FILE
                        Path to the grammar file
  -s SYMBOL, --start SYMBOL
                        Start symbol of the grammar (without <...>). Default: start
  -c NUMBER, --count NUMBER
                        Number of strings to generate
  -d DIR, --dir DIR     Output directory for the generated strings. Default: output
  -e EXT, --file-extension EXT
                        The file extension to be used for the produced documents. Default: txt
  --max-depth NUMBER    Maximum depth for the derivation trees. Default: 10
  --min-depth NUMBER    Minimum depth for the derivation trees. Default: 1
  -k NUMBER, --kcov NUMBER
                        Number of strings to generate for k-cov. Default: 1

API

Syntax Symphony can also be used as a library in your Python projects. The API provides a simple interface to generate test inputs using the fuzzer.

Example usage:

from syntax_symphony.fuzzer import SyntaxSymphony
from syntax_symphony.grammar import Grammar

# Define the grammar
grammar = Grammar({
    "<start>": ["<expr>"],
    "<expr>": ["<term> + <expr>", "<term> - <expr>", "<term>"],
    "<term>": ["<factor> * <term>", "<factor> / <term>", "<factor>"],
    "<factor>": ["<number>", "(<expr>)"],
    "<number>": ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
})

# Create the fuzzer
fuzzer = SyntaxSymphony(grammar)

# Generate 10 test cases
for i in range(10):
    test_case = fuzzer.fuzz()
    print(test_case)

Contributing

We welcome contributions from the community. If you have ideas for improvements, new features, or bug fixes, please submit a pull request or open an issue on our GitHub repository.

License

This project is licensed under the MIT License. See LICENSE for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

syntax_symphony-0.1.4.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

syntax_symphony-0.1.4-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file syntax_symphony-0.1.4.tar.gz.

File metadata

  • Download URL: syntax_symphony-0.1.4.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for syntax_symphony-0.1.4.tar.gz
Algorithm Hash digest
SHA256 134b9c1b8470533ab6dbca1e2b69f6c53c39844a144468945f8b124aab27a85b
MD5 5ffe53a145b4a5bb91b3f6d5556535b6
BLAKE2b-256 60bc9b78e37d3d6bca900b95e06f4fd9d8b7cff6e1ff2c59998097e038ac8f12

See more details on using hashes here.

Provenance

The following attestation bundles were made for syntax_symphony-0.1.4.tar.gz:

Publisher: publish_to_pypi.yml on StanimirIglev/syntax-symphony

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file syntax_symphony-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for syntax_symphony-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7bf494fab5e0f93135d787ef31172b1545994c883ff28ba1d6bd5156a729853f
MD5 29a3900595740aeba1eff8490a5c13d9
BLAKE2b-256 4b73598ab56c5ce77edf672bb11154c4c3f1c0678bb05d0b80ea66a7c9b3e600

See more details on using hashes here.

Provenance

The following attestation bundles were made for syntax_symphony-0.1.4-py3-none-any.whl:

Publisher: publish_to_pypi.yml on StanimirIglev/syntax-symphony

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page