{"id":22915438,"url":"https://github.com/pandatix/go-abnf","last_synced_at":"2025-05-12T14:23:33.210Z","repository":{"id":195370028,"uuid":"571598879","full_name":"pandatix/go-abnf","owner":"pandatix","description":"Augmented Backus-Naur Form (ABNF) in Go. Implements RFC 5234 and 7405, with Errata 2968 and 3076.","archived":false,"fork":false,"pushed_at":"2024-12-12T11:04:47.000Z","size":405,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-12T12:20:26.192Z","etag":null,"topics":["abnf","backtracking","fuzzing","golang","grammar","graph","regex","rfc5234","rfc7405"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pandatix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-28T13:32:57.000Z","updated_at":"2024-12-12T11:04:45.000Z","dependencies_parsed_at":"2023-10-13T00:43:32.527Z","dependency_job_id":"1f988feb-b317-46c4-95f5-8385763a46e0","html_url":"https://github.com/pandatix/go-abnf","commit_stats":null,"previous_names":["pandatix/go-abnf"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandatix%2Fgo-abnf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandatix%2Fgo-abnf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandatix%2Fgo-abnf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pandatix%2Fgo-abnf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pandatix","download_url":"https://codeload.github.com/pandatix/go-abnf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229669607,"owners_count":18104709,"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":["abnf","backtracking","fuzzing","golang","grammar","graph","regex","rfc5234","rfc7405"],"created_at":"2024-12-14T05:27:01.794Z","updated_at":"2025-05-12T14:23:33.195Z","avatar_url":"https://github.com/pandatix.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\t\u003ch1\u003eGo-ABNF\u003c/h1\u003e\n\t\u003ca href=\"https://pkg.go.dev/github.com/pandatix/go-abnf\"\u003e\u003cimg src=\"https://shields.io/badge/-reference-blue?logo=go\u0026style=for-the-badge\" alt=\"reference\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://goreportcard.com/report/github.com/pandatix/go-abnf\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/pandatix/go-abnf?style=for-the-badge\" alt=\"go report\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://coveralls.io/github/pandatix/go-abnf?branch=main\"\u003e\u003cimg src=\"https://img.shields.io/coverallsCoverage/github/pandatix/go-abnf?style=for-the-badge\" alt=\"Coverage Status\"\u003e\u003c/a\u003e\n\t\u003cbr\u003e\n\t\u003ca href=\"\"\u003e\u003cimg src=\"https://img.shields.io/github/license/pandatix/go-abnf?style=for-the-badge\" alt=\"License\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/pandatix/go-abnf/actions?query=workflow%3Aci+\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/pandatix/go-abnf/ci.yaml?style=for-the-badge\u0026label=CI\" alt=\"CI\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://github.com/pandatix/go-abnf/actions/workflows/codeql-analysis.yaml\"\u003e\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/pandatix/go-abnf/codeql-analysis.yaml?style=for-the-badge\u0026label=CodeQL\" alt=\"CodeQL\"\u003e\u003c/a\u003e\n\t\u003cbr\u003e\n\t\u003ca href=\"https://securityscorecards.dev/viewer/?uri=github.com/pandatix/go-abnf\"\u003e\u003cimg src=\"https://img.shields.io/ossf-scorecard/github.com/pandatix/go-abnf?label=openssf%20scorecard\u0026style=for-the-badge\" alt=\"OpenSSF Scoreboard\"\u003e\u003c/a\u003e\n\t\u003ca href=\"https://bestpractices.coreinfrastructure.org/en/projects/7840\"\u003e\u003cimg src=\"https://img.shields.io/cii/summary/7840?style=for-the-badge\u0026label=openssf%20best%20practices\" alt=\"OpenSSF Best Practices Summary\"\u003e\u003c/a\u003e\n\u003c/div\u003e\n\nGo module to handle Augmented Backus-Naur Form (ABNF), providing a large API.\nIt implements RFC 5234 and 7405, with Errata 2968 and 3076.\n\nCapabilities:\n - [X] parse ABNF (to manipulable datastructure ; with cycle detection)\n - [X] compile ABNF to regex\n - [ ] create a minimal set of tests that covers the full grammar\n - [X] generate a visual representation of the ABNF grammar provided (mermaid)\n - [X] create an ABNF fuzzer for your modules (version \u003e= Go1.18beta1)\n\n## How it works\n\nUnder the hood, `go-abnf` is a dependency-free brute-force parser. It enumerates all possibilities for a given grammar and an input, and returns all possible paths. Those then have to be lexed in order to produce a new grammar.\n\nAs this implementation is not adhesive to the ABNF grammar of the ABNF grammar as defined in RFC 5234, updated by RFC 7405 and fixed by Erratum 2968 and 3076, it enables genericity.\nThis imply that for any valid grammar in ABNF that is properly lexed, if you can write a lexer for this grammar, you can parse new input with the original grammar. To init this loop, we had to hardcode the manual decomposition of the ABNF grammar, reviewed multiple times.\n\n\u003cdiv align=\"center\"\u003e\n\t\u003cimg src=\"res/grammar.excalidraw.png\" width=\"800px\"\u003e\n\u003c/div\u003e\n\nExamples can be found in [the examples directory](examples/)\n\n## Fuzzing\n\nAs go-abnf revolves around grammars, you can use a random walk to traverse its graph and efficiently generate valid inputs according to a given grammar.\n\nThis is particularly powerful when you want to fuzz Go implementations that require a very specific input format that the Go's fuzzing engine can't produce.\n\nYou can use go-abnf to efficiently produce test cases, as follows.\n\n```go\npackage example\n\nimport (\n\t_ \"embed\"\n\t\"testing\"\n\n\tgoabnf \"github.com/pandatix/go-abnf\"\n)\n\n//go:embed my-grammar.abnf\nvar myGrammar []byte\n\nfunc FuzzFunction(f *testing.F) {\n\tg, err := goabnf.ParseABNF(myGrammar)\n\tif err != nil {\n\t\tf.Fatal(err)\n\t}\n\n\tf.Fuzz(func(t *testing.T, seed int64) {\n\t\t// Generate a random test case based on the seed\n\t\tb, _ := g.Generate(seed, \"a\",\n\t\t\tgoabnf.WithRepMax(15),      // Limit repetitions to 15\n\t\t\tgoabnf.WithThreshold(1024), // Stop ASAP input generation if reached 1024 bytes\n\t\t)\n\n\t\tFunction(b)\n\t})\n}\n```\n\n---\n\n## Troubleshooting\n\n### My ABNF grammar does not work\n\n**Q**: My ABNF grammar does not work. Do you have any idea why ?\n\n**R**: There could be many reasons to this. First make sure your grammar ends up by a newline (LF), and especially that the input content has a CR LF. As those appear the same, it is often a source of error.\n\n### Difference between pap and bap\n\n**Q**: Is there a difference between pap and [bap](https://github.com/ietf-tools/bap) ?\n\n**R**: Yes, first of all the language (i.e. Go) enables more portability thus integration in workflows. But the real difference between pap and bap is the way they work: pap is built on an opportunity to challenge bap whether bap is built to generate meaningful errors to the end user. Out of this, no, pap and bap are very similar as they are ABNF parsers/validators.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandatix%2Fgo-abnf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpandatix%2Fgo-abnf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpandatix%2Fgo-abnf/lists"}