{"id":13647337,"url":"https://github.com/MozillaSecurity/dharma","last_synced_at":"2025-04-22T02:31:20.682Z","repository":{"id":29347340,"uuid":"32881500","full_name":"MozillaSecurity/dharma","owner":"MozillaSecurity","description":"Generation-based, context-free grammar fuzzer. Refer to https://github.com/posidron/dharma for a maintained version.","archived":true,"fork":false,"pushed_at":"2021-08-13T19:50:14.000Z","size":6078,"stargazers_count":489,"open_issues_count":10,"forks_count":89,"subscribers_count":30,"default_branch":"master","last_synced_at":"2025-04-02T05:44:23.463Z","etag":null,"topics":["context-free","fuzzer","fuzzing","generation","grammar","python","random"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MozillaSecurity.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-25T17:56:23.000Z","updated_at":"2025-03-23T07:44:55.000Z","dependencies_parsed_at":"2022-09-05T21:00:21.304Z","dependency_job_id":null,"html_url":"https://github.com/MozillaSecurity/dharma","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MozillaSecurity%2Fdharma","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MozillaSecurity%2Fdharma/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MozillaSecurity%2Fdharma/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MozillaSecurity%2Fdharma/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MozillaSecurity","download_url":"https://codeload.github.com/MozillaSecurity/dharma/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250163637,"owners_count":21385277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["context-free","fuzzer","fuzzing","generation","grammar","python","random"],"created_at":"2024-08-02T01:03:29.985Z","updated_at":"2025-04-22T02:31:20.377Z","avatar_url":"https://github.com/MozillaSecurity.png","language":"Python","readme":"**\u003cp align=\"center\"\u003eArchived \u0026mdash; please see https://github.com/posidron/dharma for maintained version.\u003c/p\u003e**\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/posidron/posidron.github.io/raw/master/static/images/dharma.png\" alt=\"Logo\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\nGeneration-based, context-free grammar fuzzer.\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://travis-ci.org/MozillaSecurity/dharma\"\u003e\u003cimg src=\"https://api.travis-ci.org/MozillaSecurity/dharma.svg?branch=master\" alt=\"Build Status\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.irccloud.com/invite?channel=%23fuzzing\u0026amp;hostname=irc.mozilla.org\u0026amp;port=6697\u0026amp;ssl=1\"\u003e\u003cimg src=\"https://img.shields.io/badge/IRC-%23fuzzing-1e72ff.svg?style=flat\" alt=\"IRC\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/posidron/posidron.github.io/master/static/images/dharma.gif\"\u003e\n\u003c/p\u003e\n\n\u003ch2\u003eTable of Contents\u003c/h2\u003e\n\n- [Run](#Run)\n  - [pip](#pip)\n  - [pipenv](#pipenv)\n  - [package](#package)\n  - [Docker](#Docker)\n- [Examples](#Examples)\n- [Development](#Development)\n- [Dharma Grammar Cheatsheet](#Dharma-Grammar-Cheatsheet)\n- [API Documentation](#API-Documentation)\n- [Dharma in the Public](#Dharma-in-the-Public)\n\n## Run\n\nAll roads lead to Rome but Python 3.x is the prefered vehicle.\n\n### pip\n\n```bash\npip install dharma\ndharma --help\n```\n\n### pipenv\n\n```bash\npipenv install --dev\npipenv run dharma --help\n```\n\n### package\n\n```bash\npython -m dharma --help\n```\n\n### Docker\n\n```bash\ndocker build -t dharma .\ndocker run --rm -it dharma -grammars dharma/grammars/canvas2d.dg\n```\n\n## Examples\n\nGenerate a single test-case and print it to `stdout`. Multiple grammars can be appended to the `-grammars` argument.\n\n```bash\ndharma -grammars dharma/grammars/canvas2d.dg\n```\n\nGenerating multiple test-cases and save the result to disk.\n\n```bash\ndharma -grammars dharma/grammars/canvas2d.dg -storage . -count 5\n```\n\nGenerate test-cases and serve them in a template via WebSocket.\nLaunch `dharma/grammars/var/index.html` in the browser after Dharma launched.\n\n```bash\ndharma -grammars dharma/grammars/canvas2d.dg -server -template dharma/grammars/var/templates/html5/default.html\n```\n\nBenchmark the generator.\n\n```bash\ntime dharma -grammars dharma/grammars/canvas2d.dg -count 10000 \u003e /dev/null\n```\n\n## Development\n\n### PyLint\n\nIn case you run PyLint 1.9.2 and Python 3.7 you need to upgrade PyLint.\n\n```bash\npip3 install pylint astroid --pre -U\n```\n\n## Dharma Grammar Cheatsheet\n\n### Comments\n\n```\n%%% comment\n```\n\n### Controls\n\n```\n%const% name := value\n```\n\n### Sections\n\n```\n%section% := value\n%section% := variable\n%section% := variance\n```\n\n### Extension Methods\n\nRefer to `extensions.py` in `dharma/core/` and to the `xref_registry` in the `DharmaMachine` class to add further extensions.\n\n```\n%range%(0-9)\n%range%(0.0-9.0)\n%range%(a-z)\n%range%(!-~)\n%range%(0x100-0x200)\n\n%repeat%(+variable+)\n%repeat%(+variable+, \", \")\n\n%uri%(path)\n%uri%(lookup_key)\n\n%block%(path)\n\n%choice%(foo, \"bar\", 1)\n```\n\n### Assigning Values\n\n```\ndigit :=\n    %range%(0-9)\n\nsign :=\n    +\n    -\n\nvalue :=\n    +sign+%repeat%(+digit+)\n```\n\n### Using Values\n\n```\n+value+\n```\n\n### Assigning Variables\n\n```\nvariable :=\n    @variable@ = new Foo();\n```\n\n### Using Variables\n\n```\nvalue :=\n    !variable!.bar();\n```\n\n### Referencing values from `common.dg`\n\n```\nvalue :=\n    attribute=+common:number+\n```\n\n### Calling JavaScript library methods\n\n```\nfoo :=\n    Random.pick([0,1]);\n```\n\n## API Documentation\n\n- https://mozillasecurity.github.io/dharma\n\n## Dharma in the Public\n\nDharma mentionings in the news.\n\n- https://webassembly-security.com/fuzzing-wasm-javascript-dharma-chrome-v8/\n- https://www.zerodayinitiative.com/blog/2019/1/31/implementing-fuzz-logics-with-dharma\n- http://blog.ret2.io/2018/06/13/pwn2own-2018-vulnerability-discovery/\n- https://blog.mozilla.org/security/2015/06/29/dharma/\n- https://www.redpacketsecurity.com/dharma-generation-based-context-free-grammar-fuzzing-tool/\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMozillaSecurity%2Fdharma","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMozillaSecurity%2Fdharma","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMozillaSecurity%2Fdharma/lists"}