renatahodovan / idl2js

Grammar-based Fuzzer that uses WebIDL as a grammar.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

idl2js

Grammar-based Fuzzer that uses WebIDL as a grammar.

Build Status Codecov Python Version License

Quick start

pip install idl2js

Build from source

Get source and install dependencies

git clone https://gitlab.com/PrVrSs/idl2js.git
cd idl2js
poetry install

Download ANTLR tool

wget https://www.antlr.org/download/antlr-4.10.1-complete.jar

Generate parser

make grammar

Run tests

make unit

Examples

import logging
from pathlib import Path
from pprint import pprint

from idl2js import InterfaceTarget, Transpiler


class Module(InterfaceTarget):
    kind = 'Module'


class Global(InterfaceTarget):
    kind = 'Global'


class Table(InterfaceTarget):
    kind = 'Table'


class Memory(InterfaceTarget):
    kind = 'Memory'


def main():
    logging.getLogger('idl2js').setLevel(logging.DEBUG)

    transpiler = Transpiler(
        idls=(
            str((Path(__file__).parent / 'webassembly.webidl').resolve()),
        )
    )

    transpiler.transpile(
        targets=[
            Module,
            Global,
            Table,
            Memory,
        ]
    )

    pprint(transpiler.js_instances)


if __name__ == '__main__':
    main()

Output

try {v_0805c1325a3048aca879de7ce5f8c9a5 = new Int8Array()} catch(e){}
try {v_cfa435d6211f41df8a6af0a8543b3b37 = new WebAssembly.Module(v_0805c1325a3048aca879de7ce5f8c9a5)} catch(e){}
try {v_5deaeb375b774b54b6140be12322296a = {value: 'v128', mutable: true}} catch(e){}
try {v_788c98fd9d97444688f48fedb824130b = 'meoein'} catch(e){}
try {v_c3fcd21aecdd4ef6bb2060cbb0bd70fb = new WebAssembly.Global(v_5deaeb375b774b54b6140be12322296a, v_788c98fd9d97444688f48fedb824130b)} catch(e){}
try {v_73a4bd166ae34681a13acc70c2a67876 = {element: 'anyfunc', initial: 290477176, maximum: 3297392043}} catch(e){}
try {v_061571cb277b42beb33546c8d8c3ed07 = 'pahfbx'} catch(e){}
try {v_0c4bc44857394e40a9ade62f0eaadfca = new WebAssembly.Table(v_73a4bd166ae34681a13acc70c2a67876, v_061571cb277b42beb33546c8d8c3ed07)} catch(e){}
try {v_06ab1c4441d543ae8d4289c13a07c895 = {initial: 2477011723, maximum: 3809510539}} catch(e){}
try {v_5e251ff6ba8647e48a2d633ba42386f8 = new WebAssembly.Memory(v_06ab1c4441d543ae8d4289c13a07c895)} catch(e){}

Links

Contributing

Any help is welcome and appreciated.

License

idl2js is licensed under the terms of the Apache-2.0 License (see the file LICENSE).

About

Grammar-based Fuzzer that uses WebIDL as a grammar.

License:Apache License 2.0


Languages

Language:Python 70.2%Language:WebIDL 16.0%Language:ANTLR 13.3%Language:Makefile 0.5%