{"id":13413931,"url":"https://github.com/google/gofuzz","last_synced_at":"2025-10-05T17:31:46.689Z","repository":{"id":19241211,"uuid":"22476286","full_name":"google/gofuzz","owner":"google","description":"Fuzz testing for go.","archived":true,"fork":false,"pushed_at":"2022-11-07T22:21:34.000Z","size":69,"stargazers_count":1494,"open_issues_count":12,"forks_count":118,"subscribers_count":26,"default_branch":"master","last_synced_at":"2025-01-15T06:39:50.487Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-31T16:21:29.000Z","updated_at":"2025-01-15T02:49:13.000Z","dependencies_parsed_at":"2022-07-10T08:00:42.519Z","dependency_job_id":null,"html_url":"https://github.com/google/gofuzz","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/google%2Fgofuzz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgofuzz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgofuzz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fgofuzz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/gofuzz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235425008,"owners_count":18988329,"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":[],"created_at":"2024-07-30T20:01:52.967Z","updated_at":"2025-10-05T17:31:41.656Z","avatar_url":"https://github.com/google.png","language":"Go","readme":"gofuzz\n======\n\ngofuzz is a library for populating go objects with random values.\n\n[![GoDoc](https://godoc.org/github.com/google/gofuzz?status.svg)](https://godoc.org/github.com/google/gofuzz)\n\nThis is useful for testing:\n\n* Do your project's objects really serialize/unserialize correctly in all cases?\n* Is there an incorrectly formatted object that will cause your project to panic?\n\nImport with ```import \"github.com/google/gofuzz\"```\n\nYou can use it on single variables:\n```go\nf := fuzz.New()\nvar myInt int\nf.Fuzz(\u0026myInt) // myInt gets a random value.\n```\n\nYou can use it on maps:\n```go\nf := fuzz.New().NilChance(0).NumElements(1, 1)\nvar myMap map[ComplexKeyType]string\nf.Fuzz(\u0026myMap) // myMap will have exactly one element.\n```\n\nCustomize the chance of getting a nil pointer:\n```go\nf := fuzz.New().NilChance(.5)\nvar fancyStruct struct {\n  A, B, C, D *string\n}\nf.Fuzz(\u0026fancyStruct) // About half the pointers should be set.\n```\n\nYou can even customize the randomization completely if needed:\n```go\ntype MyEnum string\nconst (\n        A MyEnum = \"A\"\n        B MyEnum = \"B\"\n)\ntype MyInfo struct {\n        Type MyEnum\n        AInfo *string\n        BInfo *string\n}\n\nf := fuzz.New().NilChance(0).Funcs(\n        func(e *MyInfo, c fuzz.Continue) {\n                switch c.Intn(2) {\n                case 0:\n                        e.Type = A\n                        c.Fuzz(\u0026e.AInfo)\n                case 1:\n                        e.Type = B\n                        c.Fuzz(\u0026e.BInfo)\n                }\n        },\n)\n\nvar myObject MyInfo\nf.Fuzz(\u0026myObject) // Type will correspond to whether A or B info is set.\n```\n\nSee more examples in ```example_test.go```.\n\n## dvyukov/go-fuzz integration\n\nYou can use this library for easier [go-fuzz](https://github.com/dvyukov/go-fuzz)ing.\ngo-fuzz provides the user a byte-slice, which should be converted to different inputs\nfor the tested function. This library can help convert the byte slice. Consider for\nexample a fuzz test for a the function `mypackage.MyFunc` that takes an int arguments:\n```go\n// +build gofuzz\npackage mypackage\n\nimport fuzz \"github.com/google/gofuzz\"\n\nfunc Fuzz(data []byte) int {\n        var i int\n        fuzz.NewFromGoFuzz(data).Fuzz(\u0026i)\n        MyFunc(i)\n        return 0\n}\n```\n\nHappy testing!\n","funding_links":[],"categories":["Fuzzing and delta-debugging/reducing/shrinking","测试相关","\u003ca id=\"683b645c2162a1fce5f24ac2abfa1973\"\u003e\u003c/a\u003e漏洞\u0026\u0026漏洞管理\u0026\u0026漏洞发现/挖掘\u0026\u0026漏洞开发\u0026\u0026漏洞利用\u0026\u0026Fuzzing","Testing","Go","Mock","测试","测试相关`测试库和测试数据集生成库`","\u003cspan id=\"测试-testing\"\u003e测试 Testing\u003c/span\u003e"],"sub_categories":["Mock","查询语","功能","Advanced Console UIs","HTTP Clients","Fuzzing and delta-debugging/reducing/shrinking.","HTTP客户端","Fuzzing and delta-debugging/reducing/shrinking","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","交流"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fgofuzz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fgofuzz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fgofuzz/lists"}