{"id":28561114,"url":"https://github.com/codelion/gramtest","last_synced_at":"2025-06-10T10:14:21.121Z","repository":{"id":30685137,"uuid":"34241040","full_name":"codelion/gramtest","owner":"codelion","description":"GramTest: A tool for Grammar based Test case generation","archived":false,"fork":false,"pushed_at":"2023-09-23T13:05:37.000Z","size":96,"stargazers_count":86,"open_issues_count":3,"forks_count":18,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-03T18:51:43.431Z","etag":null,"topics":["bnf","grammar","grammars","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codelion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-04-20T05:59:37.000Z","updated_at":"2025-05-22T12:53:43.000Z","dependencies_parsed_at":"2024-03-12T11:15:30.978Z","dependency_job_id":null,"html_url":"https://github.com/codelion/gramtest","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelion%2Fgramtest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelion%2Fgramtest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelion%2Fgramtest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelion%2Fgramtest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codelion","download_url":"https://codeload.github.com/codelion/gramtest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codelion%2Fgramtest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259054152,"owners_count":22798451,"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":["bnf","grammar","grammars","java"],"created_at":"2025-06-10T10:14:20.474Z","updated_at":"2025-06-10T10:14:21.111Z","avatar_url":"https://github.com/codelion.png","language":"Java","readme":"# GramTest\nThis tool allows you to generate test cases based on arbitrary user defined grammars. The input grammar is given in BNF notation. Potential applications include fuzzing and automated testing.\n\n## Instructions\nWe use maven as our build tool. When you compile the project using maven (`mvn clean package`) it will generate a single all dependencies Jar, that can be run from the command line as follows:\n\n`java -jar gramtest.jar -file grammar.bnf`\n\nTo take a look at all the additional options, you can run `java -jar gramtest.jar -h` which will print the details as below.\n\n```\nusage: gramtest [options]\n -dep \u003cdepth of rules\u003e         maximum depth for recursive rules\n -ext \u003cextension\u003e              file extension for generated tests\n -file \u003cgrammar file\u003e          path to the grammar file (in BNF notation)\n -h,--help                     prints this message\n -max \u003cmax size of test\u003e       maximum size of each generated test\n -min \u003cmin size of test\u003e       minimum size of each generated test\n -mingen \u003cminimal generator\u003e   use minimal sentence generation\n                               (true/false)\n -num \u003cnumber of tests\u003e        maximum number of test cases\n -tests \u003ctest folder\u003e          path to the folder to store generated tests\n```\n\n## Bugs found using GramTest\n| Project | Reference | Status |\n|---------|---------|--------|\n| Apache Commons Validator | https://issues.apache.org/jira/browse/VALIDATOR-410 | Open | \n| segmentio/is-url | https://github.com/segmentio/is-url/issues/15 | Open |\n| gajus/url-regexp | https://github.com/gajus/url-regexp/issues/6 | Open |\n| segmentio/is-url | https://github.com/segmentio/is-url/issues/21 | Open |\n\n## Articles\n- [Continuous fuzzing of Java projects with GramTest](https://lambdasec.github.io/Fuzzing-Java-Libraries-with-GramTest/)\n- [How does grammar-based test case generation work?](https://www.veracode.com/blog/managing-appsec/how-does-grammar-based-test-case-generation-work)\n- [Practical tips for implementing grammar-based test case generation](https://www.veracode.com/blog/secure-development/practical-tips-implementing-grammar-based-test-case-generation)\n\n## FAQ\n\n- _Can I use this particular grammar with GramTest?_\n\nAs long as the input grammar is described in BNF it is possible to use it with GramTest to generate random strings. Several grammars that you find online are not given in proper BNF format, have comments/text in some productions, or do not have complete clauses. Verify that the grammar you are using doesn't have any bugs before using it. \n\n- _Why did you choose BNF and not EBNF/ABNF/etc. as the input format for GramTest?_\n\nBNF was the simplest of all formats to use, it is certainly possible to implement another input format but it is going to be a non-trivial excercise. You will need to implement your own [generator](https://github.com/codelion/gramtest/blob/master/src/main/java/com/sourceclear/gramtest/GeneratorVisitor.java) that can create strings based on each type of production in the grammar. \n\n- _Where can I find some sample BNF grammars to use?_\n\nSeveral examples are available in the [test folder](https://github.com/codelion/gramtest/tree/master/src/test/resources). You can refer to the unit tests to see how they can be used.\n","funding_links":[],"categories":["Generic ##"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelion%2Fgramtest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodelion%2Fgramtest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodelion%2Fgramtest/lists"}