{"id":30464403,"url":"https://github.com/snorwin/k8s-generic-webhook","last_synced_at":"2025-08-24T01:19:33.846Z","repository":{"id":39588181,"uuid":"396005454","full_name":"snorwin/k8s-generic-webhook","owner":"snorwin","description":"The k8s-generic-webhook is a library to simplify the implementation of webhooks for arbitrary customer resources (CR) in the operator-sdk or controller-runtime.","archived":false,"fork":false,"pushed_at":"2025-08-19T07:06:09.000Z","size":298,"stargazers_count":16,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-19T09:44:55.956Z","etag":null,"topics":["admission-webhook","controller-runtime","k8s","kubernetes","openshift","operator-sdk","webhook"],"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/snorwin.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,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-08-14T12:40:49.000Z","updated_at":"2025-08-19T07:06:06.000Z","dependencies_parsed_at":"2023-12-27T13:44:42.201Z","dependency_job_id":"df253721-0145-4aaa-a26e-342458f32c7e","html_url":"https://github.com/snorwin/k8s-generic-webhook","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/snorwin/k8s-generic-webhook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snorwin%2Fk8s-generic-webhook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snorwin%2Fk8s-generic-webhook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snorwin%2Fk8s-generic-webhook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snorwin%2Fk8s-generic-webhook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snorwin","download_url":"https://codeload.github.com/snorwin/k8s-generic-webhook/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snorwin%2Fk8s-generic-webhook/sbom","scorecard":{"id":456229,"data":{"date":"2025-08-11","repo":{"name":"github.com/snorwin/k8s-generic-webhook","commit":"cd9714de2d6cc47cbe8f70ab2c97e46ee649c0f4"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":6,"reason":"8 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 6","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":-1,"reason":"Found no human activity in the last 15 changesets","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/snorwin/k8s-generic-webhook/test.yaml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yaml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/snorwin/k8s-generic-webhook/test.yaml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yaml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/snorwin/k8s-generic-webhook/test.yaml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/test.yaml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T09:45:18.185Z","repository_id":39588181,"created_at":"2025-08-19T09:45:18.185Z","updated_at":"2025-08-19T09:45:18.185Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271778237,"owners_count":24819265,"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","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["admission-webhook","controller-runtime","k8s","kubernetes","openshift","operator-sdk","webhook"],"created_at":"2025-08-24T01:19:31.347Z","updated_at":"2025-08-24T01:19:33.837Z","avatar_url":"https://github.com/snorwin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# k8s-generic-webhook\n\n[![GitHub Action](https://img.shields.io/badge/GitHub-Action-blue)](https://github.com/features/actions)\n[![Documentation](https://img.shields.io/badge/godoc-reference-5272B4.svg)](https://pkg.go.dev/github.com/snorwin/k8s-generic-webhook/pkg/webhook)\n[![Test](https://img.shields.io/github/actions/workflow/status/snorwin/k8s-generic-webhook/test.yaml?label=tests\u0026logo=github)](https://github.com/snorwin/k8s-generic-webhook/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/snorwin/k8s-generic-webhook)](https://goreportcard.com/report/github.com/snorwin/k8s-generic-webhook)\n[![Coverage Status](https://coveralls.io/repos/github/snorwin/k8s-generic-webhook/badge.svg?branch=main)](https://coveralls.io/github/snorwin/k8s-generic-webhook?branch=main)\n[![Releases](https://img.shields.io/github/v/release/snorwin/k8s-generic-webhook)](https://github.com/snorwin/k8s-generic-webhook/releases)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nThe **k8s-generic-webhook** is a library to simplify the implementation of webhooks for arbitrary customer resources (CR) in the [operator-sdk](https://sdk.operatorframework.io/) or [controller-runtime](https://github.com/kubernetes-sigs/controller-runtime).\nFurthermore, it provides full access to the `AdmissionReview` request and decodes the `Object` in the request automatically. More sophistic webhook logic is facilitated by using the injected `Client` of the webhook which provides full access to the Kubernetes API.\n\n## Quickstart\n1. Initialize a new manager using the [operator-sdk](https://sdk.operatorframework.io/).\n2. Create a pkg (e.g. `webhooks/pod`) and implement your webhook logic by embedding either the `ValidatingWebhook` or the `MuatatingWebhook`.\n\n#### Example `ValidatingWebhook`\n```go\npackage pod\n\nimport (\n\t\"context\"\n\n\tcorev1 \"k8s.io/api/core/v1\"\n\t\"k8s.io/apimachinery/pkg/runtime\"\n\t\"sigs.k8s.io/controller-runtime/pkg/log\"\n\t\"sigs.k8s.io/controller-runtime/pkg/manager\"\n\t\"sigs.k8s.io/controller-runtime/pkg/webhook/admission\"\n\n\t\"github.com/snorwin/k8s-generic-webhook/pkg/webhook\"\n)\n\ntype Webhook struct {\n\twebhook.ValidatingWebhook\n}\n\nfunc (w *Webhook) SetupWebhookWithManager(mgr manager.Manager) error {\n\treturn webhook.NewGenericWebhookManagedBy(mgr).\n\t\tFor(\u0026corev1.Pod{}).\n\t\tComplete(w)\n}\n\nfunc (w *Webhook) ValidateCreate(ctx context.Context, request admission.Request, object runtime.Object) admission.Response {\n\t_ = log.FromContext(ctx)\n\n\tpod := object.(*corev1.Pod)\n\t// TODO add your programmatic validation logic here\n\n\treturn admission.Allowed(\"\")\n}\n```\n\n#### Example `MutatingWebhook`\n```go\npackage pod\n\nimport (\n\t\"context\"\n\n\tcorev1 \"k8s.io/api/core/v1\"\n\t\"k8s.io/apimachinery/pkg/runtime\"\n\t\"sigs.k8s.io/controller-runtime/pkg/log\"\n\t\"sigs.k8s.io/controller-runtime/pkg/manager\"\n\t\"sigs.k8s.io/controller-runtime/pkg/webhook/admission\"\n\n\t\"github.com/snorwin/k8s-generic-webhook/pkg/webhook\"\n)\n\ntype Webhook struct {\n\twebhook.MutatingWebhook\n}\n\nfunc (w *Webhook) SetupWebhookWithManager(mgr manager.Manager) error {\n\treturn webhook.NewGenericWebhookManagedBy(mgr).\n\t\tFor(\u0026corev1.Pod{}).\n\t\tComplete(w)\n}\n\nfunc (w *Webhook) Mutate(ctx context.Context, request admission.Request, object runtime.Object) admission.Response {\n\t_ = log.FromContext(ctx)\n\n\tpod := object.(*corev1.Pod)\n\t// TODO add your programmatic mutation logic here\n\n\treturn admission.Allowed(\"\")\n}\n```\n\n3. Add the following snippet to `main()` in `main.go` in order to register the webhook in the manager.\n```go\nif err = (\u0026pod.Webhook{}).SetupWebhookWithManager(mgr); err != nil {\n    setupLog.Error(err, \"unable to create webhook\", \"webhook\", \"Pod\")\n    os.Exit(1)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnorwin%2Fk8s-generic-webhook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnorwin%2Fk8s-generic-webhook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnorwin%2Fk8s-generic-webhook/lists"}