├── .github └── settings.yml ├── LICENSE ├── README.md └── projects ├── README.md ├── argo ├── ancestry_fuzzer.go ├── argo-cd_db_fuzzer.go ├── argo-cd_rbac_fuzzer.go ├── argo-cd_resource_tracking_fuzzer.go ├── argo-cd_util_grpc_fuzzer.go ├── argo-cd_validate_project_fuzzer.go ├── artifacts_fuzzer.go ├── build.sh ├── dictionaries │ └── fuzz_slack_eventsource.dict ├── diff_fuzzer.go ├── events_argo_workflow_fuzzer.go ├── events_controllers_sensor_fuzzer.go ├── events_expr_fuzzer.go ├── events_sensors_fuzzer.go ├── gitops-eng_diff_fuzzer.go ├── gpg_fuzzer.go ├── normalizer_fuzzer.go ├── operator_fuzzer.go ├── project_fuzzer.go ├── repository_fuzzer.go ├── rollouts-analysis-fuzzer.go ├── rollouts-kayenta_fuzzer.go ├── rollouts-metrics_fuzzer.go ├── rollouts-prometheus_fuzzer.go ├── seeds │ ├── fuzz_expr │ │ ├── seed1 │ │ ├── seed2 │ │ └── seed3 │ └── workflow_server_fuzzer │ │ ├── seed1 │ │ ├── seed2 │ │ ├── seed3 │ │ ├── seed4 │ │ └── seed5 ├── sensors_fuzzer.go ├── sessionmanager_fuzzer.go ├── validate_event_source_fuzzer.go ├── workflow_controller_fuzzer.go ├── workflow_cron_fuzzer.go ├── workflow_parser_fuzzer.go ├── workflow_server_fuzzer.go ├── workflow_util_fuzzer.go ├── workflow_v1alpha1_fuzzers.go ├── workflow_validation_fuzzer.go ├── workflows_sso_fuzzer.go └── workflows_sync_fuzzer.go ├── cilium ├── OnData_fuzzer.go ├── bpf_fuzzer.go ├── build.sh ├── config_fuzzer.go ├── elf_fuzzer.go ├── format_fuzzer.go ├── fuzz_config_parse.options ├── fuzz_get_labels_from_yaml.options ├── hubble_parser_fuzzer.go ├── labels_fuzzer.go ├── labelsfilter_fuzzer.go ├── matchpattern_fuzzer.go └── policy_fuzzer.go ├── cluster-api ├── build.sh ├── crd-creation │ └── main.go ├── fuzz_bootstrap_kubeadm.go ├── fuzz_cluster_controller.go ├── fuzz_clusterclass_controller.go ├── fuzz_conditions.go ├── fuzz_internal_kubeadm_controller.go ├── fuzz_kubeadm_internal.go ├── fuzz_machine_controller.go ├── fuzz_machinedeployment_controller.go ├── fuzz_machinehealthcheck_controller.go ├── fuzz_machineset_controller.go ├── fuzz_patch.go ├── fuzz_topology_cluster_reconciler.go ├── fuzz_util_container.go ├── fuzz_v1beta1_machine_webhook.go ├── non-oss-fuzz │ ├── Dockerfile │ ├── build.sh │ ├── cluster_controller_fuzzer.go │ └── run_fuzzer.sh └── yaml_fuzzer.go ├── cri-o ├── ParseStoreReference_fuzzer.go ├── build.sh ├── config_apparmor_fuzzer.go ├── config_blockio_fuzzer.go ├── config_fuzzer.go ├── config_rdt_fuzzer.go ├── container_fuzzer.go ├── container_server_fuzzer.go ├── dicts │ └── fuzz_server_logsan.dict ├── fuzz_server.go ├── server_fuzzer2.go ├── storage_fuzzer.go ├── storage_fuzzer2.go ├── util │ └── mock_helpers_test.go └── utils_fuzzer.go ├── cubefs ├── build.sh ├── fuzz_client.go ├── fuzz_datanode.go ├── fuzz_master.go ├── fuzz_metanode.go └── fuzz_sdk.go ├── dapr ├── build.sh ├── fuzz_acl_apply_test.go ├── fuzz_acl_test.go ├── fuzz_actors_test.go ├── fuzz_aescbcaead_test.go ├── fuzz_components_contrib_azure_eventgrid_test.go ├── fuzz_components_contrib_dubbo_test.go ├── fuzz_components_contrib_graphql_test.go ├── fuzz_components_contrib_metadata_test.go ├── fuzz_components_contrib_mqtt3_test.go ├── fuzz_components_contrib_pubsub_pulsar_test.go ├── fuzz_components_contrib_ratelimiter_test.go ├── fuzz_components_contrib_state_query_test.go ├── fuzz_components_contrib_state_test.go ├── fuzz_expr_test.go ├── fuzz_grpc_endpoints_test.go ├── fuzz_http_endpoints_test.go ├── fuzz_http_server_endpoint_test.go ├── fuzz_http_server_test.go ├── fuzz_injector_test.go ├── fuzz_kit_crypto_test.go ├── fuzz_messaging_test.go ├── fuzz_placement_raft_test.go ├── fuzz_runtime_test.go ├── fuzz_sidecar_test.go └── pkcs7_padding.go ├── distribution ├── .gitignore ├── access_controller_fuzzer.go ├── app_fuzzer.go ├── authchallenge_fuzzer.go ├── build.sh ├── client_fuzzer.go ├── corpus │ └── parserFuzzer │ │ ├── configYamlV0_1 │ │ └── inmemoryConfigYamlV0_1 ├── errcode_fuzzer.go ├── file_driver_fuzzer.go ├── inmemory_fuzzer.go ├── manifestlist_fuzzer.go ├── native_reference_fuzzer.go ├── ocischema_fuzzer.go ├── parser_fuzzer.go ├── reference_fuzzer2.go ├── registry_fuzzer.go ├── registry_proxy_fuzzer.go ├── s3_aws_fuzzer.go ├── schema2_fuzzer.go └── storage_fuzzer.go ├── etcd ├── auth_store_fuzzer.go ├── backend_fuzzer.go ├── build.sh ├── etcdserver_fuzzer.go ├── filepurge_fuzzer.go ├── grpc_proxy_fuzzer.go ├── mvcc_fuzzer.go ├── proxy_fuzzer.go ├── raft_api_fuzzer.go ├── raft_fuzzer.go ├── snapshot_fuzzer.go ├── v3_grpc_fuzzer.go └── wal_fuzzer.go ├── helm ├── action_fuzzer.go ├── build.sh ├── chartutil_fuzzer.go ├── dicts │ ├── fuzz_create_from.dict │ └── fuzz_resolve.dict ├── driver_fuzzer.go ├── engine_fuzzer.go ├── fs_fuzzer.go ├── ignore_fuzzer_test.go ├── kube_fuzzer.go ├── lint_fuzzer.go ├── loaddir_fuzzer.go ├── plugin_fuzzer.go ├── provenance_fuzzer.go ├── registry_fuzzer.go ├── releaseutil_fuzzer.go ├── repo_fuzzer.go ├── resolver_fuzzer.go ├── seeds │ └── fuzz_resolve │ │ ├── seed1 │ │ ├── seed10 │ │ ├── seed2 │ │ ├── seed3 │ │ ├── seed4 │ │ ├── seed5 │ │ ├── seed6 │ │ ├── seed7 │ │ ├── seed8 │ │ └── seed9 └── storage_fuzzer.go ├── keycloak ├── AuthenticatorFuzzer.java ├── AuthzClientFuzzer.java ├── BaseHelper.java ├── CertificateUtilsProviderFuzzer.java ├── ClientSignatureVerifierProviderFuzzer.java ├── CommonCryptoUtilsFuzzer.java ├── CommonUtilsFuzzer.java ├── CredentialValidatorFuzzer.java ├── DefaultAuthenticationFlowsFuzzer.java ├── JoseParserFuzzer.java ├── JweAlgorithmProviderFuzzer.java ├── JweFuzzer.java ├── JwkParserFuzzer.java ├── JwksUtilsFuzzer.java ├── KeycloakModelUtilsFuzzer.java ├── KeycloakUriBuilderFuzzer.java ├── PemUtilsProviderFuzzer.java ├── SamlParserFuzzer.java ├── SamlProcessingUtilFuzzer.java ├── SamlValidationUtilFuzzer.java ├── SamlXmlUtilFuzzer.java ├── ServicesJwsFuzzer.java ├── ServicesUtilsFuzzer.java ├── TokenUtilFuzzer.java ├── TokenVerifierFuzzer.java ├── build.sh └── seeds │ ├── JwkParserFuzzer_seed_1 │ ├── SamlParserFuzzer_seed_1 │ ├── SamlParserFuzzer_seed_2 │ ├── SamlParserFuzzer_seed_3 │ ├── SamlParserFuzzer_seed_4 │ ├── json.dict │ ├── json.seed │ └── saml.dict ├── knative ├── build.sh ├── fuzz_activatornet.go ├── fuzz_configmaps.go ├── fuzz_domains.go ├── fuzz_eventing_filter.go ├── fuzz_knative_duck_v1.go ├── fuzz_knative_duck_v1beta1.go ├── fuzz_knative_eventing_v1.go ├── fuzz_knative_flows_v1.go ├── fuzz_knative_pkg_serving_v1.go ├── fuzz_kncloudevents.go ├── fuzz_messaging_v1.go ├── fuzz_messaging_v1_experimental.go ├── fuzz_pkg_kmeta.go ├── fuzz_pkg_metrics.go ├── fuzz_pkg_websocket.go ├── fuzz_removewithavailabilitynodepriority_test.go ├── fuzz_serving_route_reconciler.go ├── fuzz_sources_v1_experimental.go ├── fuzz_trigger_validation_test.go ├── fuzz_validation.go ├── fuzzer_funcs.go └── json_fuzzer.go ├── kubeedge ├── build.sh ├── cloudhub_messagehandler_fuzzer.go ├── csidriver_fuzzer.go ├── dictionaries │ ├── fuzz_ExtractMessage.dict │ ├── fuzz_extract_message.dict │ └── fuzz_rule_contains.dict ├── dtmanager_fuzzer.go ├── lane_fuzzer.go ├── metaserver_fuzzer.go ├── mqtt_broker_fuzzer.go ├── router_fuzzer.go ├── stream_fuzzer.go └── udsserver_fuzzer.go ├── kubernetes ├── .gitignore ├── README.md ├── aes_fuzzer.go ├── api_roundtrip_fuzzer.go ├── apiextensions_fuzzer.go ├── apiserver_fuzzer.go ├── autogenerate.py ├── build.sh ├── celcompile_fuzzer.go ├── celcompiledata_fuzzer.go ├── converter_fuzzer.go ├── deepcopy_fuzzer.go ├── deployment_util_fuzzer.go ├── fuzz_compile.dict ├── fuzz_compile_seed_corpus.zip ├── gofuzz-fuzzers.go ├── internal_kubelet_fuzzer.go ├── internal_kubelet_kuberuntime_fuzzer.go ├── internal_kubelet_server_fuzzer.go ├── kubelet_fuzzer.go ├── mount-utils_fuzzer.go ├── native_go_parser_fuzzers_test.go ├── parser_fuzzer.go ├── roundtrip.go ├── roundtrip_fuzzer.go └── validation_fuzzer.go ├── notary ├── build.sh ├── fuzz_cose.go ├── fuzz_handlers.go ├── fuzz_jws.go ├── fuzz_keydbstore.go ├── fuzz_notation_artifactref_parsing.go ├── fuzz_pkix_test.go ├── fuzz_server_storage.go ├── fuzz_trustmanager_test.go ├── fuzz_trustpolicy.go ├── fuzz_tuf_utils.go └── fuzz_verification.go ├── openyurt └── build.sh ├── runc ├── .gitignore ├── build.sh ├── devices_fuzzer.go ├── fs2_fuzzer.go ├── fscommon_fuzzer.go ├── intelrdt_fuzzer.go ├── libcontainer_fuzzer.go ├── libcontainer_utils_fuzzer.go └── specconv_fuzzer.go └── vitess ├── abstract_fuzzer.go ├── ast_fuzzer.go ├── autogenerate └── convert_grep_to_fuzzer.go ├── build.sh ├── collations_fuzzer.go ├── fuzz_keyspace_creation.go ├── fuzz_shard_creation.go ├── fuzz_tablet_test.go ├── grpcvtgateconn_fuzzer.go ├── mysql_fuzzer.go ├── parser_fuzzer.go ├── planbuilder_fuzzer.go ├── tablet_manager_fuzzer.go ├── tabletserver_fuzzer.go ├── tabletserver_rules_fuzzer.go ├── tabletserver_schema_fuzzer.go ├── vindexes_fuzzer.go ├── vreplication_fuzzer.go ├── vstreamer_fuzzer.go ├── vt_schema_fuzzer.go ├── vtctl_fuzzer.dict ├── vtctl_fuzzer.go ├── vtgate_engine_fuzzer.go └── vttablet_fuzzer.go /.github/settings.yml: -------------------------------------------------------------------------------- 1 | repository: 2 | # See https://developer.github.com/v3/repos/#edit for all available settings. 3 | 4 | # The name of the repository. Changing this will rename the repository 5 | name: cncf-fuzzing 6 | 7 | # A short description of the repository that will show up on GitHub 8 | description: ✨🔐 CNCF Fuzzers 9 | 10 | # A URL with more information about the repository 11 | homepage: https://cncf.io/projects 12 | 13 | # Collaborators: give specific users access to this repository. 14 | # Note: changing this file will update the users visible in Github UI 15 | # see /governance/roles.md for details on write access policy 16 | # note that the permissions below may provide wider access than needed for 17 | # a specific role, and we trust these individuals to act according to their 18 | # role. If there are questions, please contact one of the chairs. 19 | collaborators: 20 | # Admins 21 | - username: caniszczyk 22 | permission: admin 23 | 24 | - username: DavidKorczynski 25 | permission: admin 26 | 27 | -------------------------------------------------------------------------------- /projects/README.md: -------------------------------------------------------------------------------- 1 | # Projects 2 | Each folder contains the fuzzers as well as supporting scripts for the respective project. 3 | -------------------------------------------------------------------------------- /projects/argo/argo-cd_db_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package db 17 | 18 | import ( 19 | "context" 20 | fuzz "github.com/AdaLogics/go-fuzz-headers" 21 | "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" 22 | "github.com/argoproj/argo-cd/v2/util/settings" 23 | ) 24 | 25 | const ( 26 | fuzzTestNamespace = "default" 27 | ) 28 | 29 | func FuzzCreateRepoCertificate(data []byte) int { 30 | f := fuzz.NewConsumer(data) 31 | repocertlist := &v1alpha1.RepositoryCertificateList{} 32 | err := f.GenerateStruct(repocertlist) 33 | if err != nil { 34 | return 0 35 | } 36 | upsert, err := f.GetBool() 37 | if err != nil { 38 | return 0 39 | } 40 | clientset := getCertClientset() 41 | db := NewDB(fuzzTestNamespace, settings.NewSettingsManager(context.Background(), clientset, fuzzTestNamespace), clientset) 42 | _, _ = db.CreateRepoCertificate(context.Background(), repocertlist, upsert) 43 | return 1 44 | } 45 | -------------------------------------------------------------------------------- /projects/argo/argo-cd_rbac_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package rbac 17 | 18 | import ( 19 | fuzz "github.com/AdaLogics/go-fuzz-headers" 20 | "github.com/casbin/casbin/v2/model" 21 | ) 22 | 23 | func FuzzLoadPolicy(data []byte) int { 24 | f := fuzz.NewConsumer(data) 25 | m := model.Model{} 26 | err := f.GenerateStruct(&m) 27 | if err != nil { 28 | return 0 29 | } 30 | builtinPolicy, err := f.GetString() 31 | if err != nil { 32 | return 0 33 | } 34 | userDefinedPolicy, err := f.GetString() 35 | if err != nil { 36 | return 0 37 | } 38 | runtimePolicy, err := f.GetString() 39 | if err != nil { 40 | return 0 41 | } 42 | argocdAdapter := newAdapter(builtinPolicy, userDefinedPolicy, runtimePolicy) 43 | argocdAdapter.LoadPolicy(m) 44 | return 1 45 | } 46 | -------------------------------------------------------------------------------- /projects/argo/argo-cd_resource_tracking_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package argo 17 | 18 | import ( 19 | "github.com/argoproj/argo-cd/v2/common" 20 | "gopkg.in/yaml.v2" 21 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 22 | ) 23 | 24 | func FuzzParseAppInstanceValue(data []byte) int { 25 | resourceTracking := NewResourceTracking() 26 | _, _ = resourceTracking.ParseAppInstanceValue(string(data)) 27 | return 1 28 | } 29 | 30 | func FuzzGetAppName(data []byte) int { 31 | var obj unstructured.Unstructured 32 | err := yaml.Unmarshal(data, &obj) 33 | if err != nil { 34 | return 0 35 | } 36 | resourceTracking := NewResourceTracking() 37 | err = resourceTracking.SetAppInstance(&obj, common.LabelKeyAppInstance, "my-app", "", TrackingMethodLabel) 38 | if err != nil { 39 | return 0 40 | } 41 | _ = resourceTracking.GetAppName(&obj, common.LabelKeyAppInstance, TrackingMethodAnnotation) 42 | return 1 43 | } 44 | -------------------------------------------------------------------------------- /projects/argo/argo-cd_validate_project_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package v1alpha1 17 | 18 | import ( 19 | fuzz "github.com/AdaLogics/go-fuzz-headers" 20 | ) 21 | 22 | func FuzzValidateAppProject(data []byte) int { 23 | f := fuzz.NewConsumer(data) 24 | p := AppProject{} 25 | err := f.GenerateStruct(&p) 26 | if err != nil { 27 | return 0 28 | } 29 | p.ValidateProject() 30 | return 1 31 | } 32 | -------------------------------------------------------------------------------- /projects/argo/artifacts_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package artifacts 17 | 18 | import ( 19 | testhttp "github.com/stretchr/testify/http" 20 | "net/http" 21 | "net/url" 22 | "strings" 23 | ) 24 | 25 | func mustParseFuzz(text string) (*url.URL, error) { 26 | u, err := url.Parse(text) 27 | if err != nil { 28 | return nil, err 29 | } 30 | return u, nil 31 | } 32 | 33 | func FuzzGetOutputArtifact(data []byte) int { 34 | var url strings.Builder 35 | url.WriteString("/") 36 | url.WriteString(string(data)) 37 | s := newServer() 38 | r := &http.Request{} 39 | parsedUrl, err := mustParseFuzz(url.String()) 40 | if err != nil { 41 | return 0 42 | } 43 | r.URL = parsedUrl 44 | w := &testhttp.TestResponseWriter{} 45 | s.GetOutputArtifact(w, r) 46 | return 0 47 | } 48 | 49 | func FuzzGetOutputArtifactByUID(data []byte) int { 50 | var url strings.Builder 51 | url.WriteString("/") 52 | url.WriteString(string(data)) 53 | s := newServer() 54 | r := &http.Request{} 55 | parsedUrl, err := mustParseFuzz(url.String()) 56 | if err != nil { 57 | return 0 58 | } 59 | r.URL = parsedUrl 60 | w := &testhttp.TestResponseWriter{} 61 | s.GetInputArtifactByUID(w, r) 62 | s.GetOutputArtifactByUID(w, r) 63 | return 0 64 | } 65 | -------------------------------------------------------------------------------- /projects/argo/dictionaries/fuzz_slack_eventsource.dict: -------------------------------------------------------------------------------- 1 | "null" -------------------------------------------------------------------------------- /projects/argo/events_argo_workflow_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package argo_workflow 17 | 18 | import ( 19 | "context" 20 | "sigs.k8s.io/yaml" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" 23 | ) 24 | 25 | 26 | func bytesToUnstructuredFuzz(jsonBytes []byte) (*unstructured.Unstructured, error) { 27 | obj := make(map[string]interface{}) 28 | err := yaml.Unmarshal(jsonBytes, &obj) 29 | if err != nil { 30 | return nil, err 31 | } 32 | return &unstructured.Unstructured{Object: obj}, nil 33 | } 34 | func FuzzArgoWorkflowTriggerExecute(data []byte) int { 35 | ctx := context.Background() 36 | var actual string 37 | firstArg := "--foo" 38 | secondArg := "--bar" 39 | unstr, err := bytesToUnstructuredFuzz(data) 40 | if err != nil { 41 | return 0 42 | } 43 | trigger := storingCmdTrigger(&actual, firstArg, secondArg) 44 | _, err = namespacedClientFrom(trigger).Namespace(unstr.GetNamespace()).Create(ctx, unstr, metav1.CreateOptions{}) 45 | if err != nil { 46 | return 0 47 | } 48 | _, err = trigger.Execute(ctx, nil, unstr) 49 | if err != nil { 50 | } 51 | return 1 52 | } -------------------------------------------------------------------------------- /projects/argo/events_controllers_sensor_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package sensor 17 | 18 | import ( 19 | "github.com/ghodss/yaml" 20 | eventbusv1alpha1 "github.com/argoproj/argo-events/pkg/apis/eventbus/v1alpha1" 21 | "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1" 22 | fuzz "github.com/AdaLogics/go-fuzz-headers" 23 | ) 24 | 25 | func FuzzValidateSensor(data []byte) int { 26 | f := fuzz.NewConsumer(data) 27 | eventBus := &eventbusv1alpha1.EventBus{} 28 | err := f.GenerateStruct(eventBus) 29 | if err != nil { 30 | return 0 31 | } 32 | content, err := f.GetBytes() 33 | if err != nil { 34 | return 0 35 | } 36 | sensor := &v1alpha1.Sensor{} 37 | err = yaml.Unmarshal(content, &sensor) 38 | if err != nil { 39 | return 0 40 | } 41 | if sensor == nil { 42 | return 0 43 | } 44 | ValidateSensor(sensor, eventBus) 45 | return 1 46 | } -------------------------------------------------------------------------------- /projects/argo/events_expr_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package expr 17 | 18 | import ( 19 | "encoding/json" 20 | fuzz "github.com/AdaLogics/go-fuzz-headers" 21 | ) 22 | 23 | func FuzzExpr(data []byte) int { 24 | f := fuzz.NewConsumer(data) 25 | input, err := f.GetString() 26 | if err != nil { 27 | return 0 28 | } 29 | d, err := f.GetBytes() 30 | if err != nil { 31 | } 32 | env := make(map[string]interface{}) 33 | err = json.Unmarshal(d, &env) 34 | if err != nil { 35 | return 0 36 | } 37 | _, _ = EvalBool(input, env) 38 | return 1 39 | } 40 | -------------------------------------------------------------------------------- /projects/argo/events_sensors_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package sensors 17 | 18 | import ( 19 | "context" 20 | 21 | fuzz "github.com/AdaLogics/go-fuzz-headers" 22 | "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1" 23 | "gopkg.in/yaml.v2" 24 | ) 25 | 26 | func FuzzgetDependencyExpression(data []byte) int { 27 | f := fuzz.NewConsumer(data) 28 | templBytes, err := f.GetBytes() 29 | if err != nil { 30 | return 0 31 | } 32 | templ := &v1alpha1.TriggerTemplate{} 33 | err = yaml.Unmarshal(templBytes, templ) 34 | if err != nil { 35 | return 0 36 | } 37 | sensorObj := &v1alpha1.Sensor{} 38 | err = f.GenerateStruct(sensorObj) 39 | if err != nil { 40 | return 0 41 | } 42 | ft := &v1alpha1.Trigger{} 43 | if err != nil { 44 | return 0 45 | } 46 | ft.Template = templ 47 | sensorObj.Spec.Triggers = []v1alpha1.Trigger{*ft} 48 | sensorCtx := &SensorContext{ 49 | sensor: sensorObj, 50 | } 51 | _, err = sensorCtx.getDependencyExpression(context.Background(), *ft) 52 | if err != nil { 53 | return 0 54 | } 55 | return 1 56 | } 57 | -------------------------------------------------------------------------------- /projects/argo/repository_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package repository 17 | 18 | import ( 19 | "context" 20 | "os" 21 | 22 | fuzz "github.com/AdaLogics/go-fuzz-headers" 23 | 24 | argoappv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" 25 | "github.com/argoproj/argo-cd/v2/reposerver/apiclient" 26 | "github.com/argoproj/argo-cd/v2/util/git" 27 | "k8s.io/apimachinery/pkg/api/resource" 28 | ) 29 | 30 | func FuzzGenerateManifests(data []byte) int { 31 | dir, err := os.MkdirTemp("", "fuzz-") 32 | if err != nil { 33 | return 0 34 | } 35 | defer os.RemoveAll(dir) 36 | f := fuzz.NewConsumer(data) 37 | err = f.CreateFiles(dir) 38 | if err != nil { 39 | return 0 40 | } 41 | resString, err := f.GetString() 42 | if err != nil { 43 | return 0 44 | } 45 | res, err := resource.ParseQuantity(resString) 46 | if err != nil { 47 | return 0 48 | } 49 | src := argoappv1.ApplicationSource{Path: "manifests/base"} 50 | q := apiclient.ManifestRequest{Repo: &argoappv1.Repository{}, ApplicationSource: &src} 51 | _, _ = GenerateManifests(context.Background(), dir, "/", "", &q, false, &git.NoopCredsStore{}, res, nil) 52 | return 1 53 | } 54 | -------------------------------------------------------------------------------- /projects/argo/rollouts-analysis-fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package analysis 17 | 18 | import ( 19 | "testing" 20 | "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" 21 | 22 | fuzz "github.com/AdaLogics/go-fuzz-headers" 23 | ) 24 | 25 | func FuzzreconcileAnalysisRun(data []byte) int { 26 | f := fuzz.NewConsumer(data) 27 | run := &v1alpha1.AnalysisRun{} 28 | err := f.GenerateStruct(run) 29 | if err != nil { 30 | return 0 31 | } 32 | t := &testing.T{} 33 | fi := newFixture(t) 34 | defer fi.Close() 35 | c, _, _ := fi.newController(noResyncPeriodFunc) 36 | _ = c.reconcileAnalysisRun(run) 37 | return 1 38 | } -------------------------------------------------------------------------------- /projects/argo/rollouts-metrics_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package webmetric 17 | 18 | import ( 19 | fuzz "github.com/AdaLogics/go-fuzz-headers" 20 | 21 | "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" 22 | ) 23 | 24 | func FuzzNewWebMetricJsonParser(data []byte) int { 25 | f := fuzz.NewConsumer(data) 26 | metric := v1alpha1.Metric{} 27 | err := f.GenerateStruct(&metric) 28 | if err != nil { 29 | return 0 30 | } 31 | _, _ = NewWebMetricJsonParser(metric) 32 | return 1 33 | } 34 | -------------------------------------------------------------------------------- /projects/argo/rollouts-prometheus_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package prometheus 17 | 18 | import ( 19 | fuzz "github.com/AdaLogics/go-fuzz-headers" 20 | log "github.com/sirupsen/logrus" 21 | 22 | "github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1" 23 | ) 24 | 25 | func FuzzPrometheusProvider(data []byte) int { 26 | f := fuzz.NewConsumer(data) 27 | metric := v1alpha1.Metric{} 28 | err := f.GenerateStruct(&metric) 29 | if err != nil { 30 | return 0 31 | } 32 | e := log.Entry{} 33 | mock := &mockAPI{ 34 | value: newScalar(10), 35 | } 36 | p, err := NewPrometheusProvider(mock, e, metric) 37 | if err != nil { 38 | return 0 39 | } 40 | _ = p.Run(newAnalysisRun(), metric) 41 | return 1 42 | } 43 | -------------------------------------------------------------------------------- /projects/argo/seeds/fuzz_expr/seed1: -------------------------------------------------------------------------------- 1 | 0000000000171109352262938742..320!=8..32222222040\003{\012}1 -------------------------------------------------------------------------------- /projects/argo/seeds/fuzz_expr/seed2: -------------------------------------------------------------------------------- 1 | (id == 1) && (last_name == 'Doe') -------------------------------------------------------------------------------- /projects/argo/seeds/fuzz_expr/seed3: -------------------------------------------------------------------------------- 1 | (id == 2) || (gender == 'Female') -------------------------------------------------------------------------------- /projects/argo/seeds/workflow_server_fuzzer/seed1: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "default", 3 | "workflow": { 4 | "apiVersion": "argoproj.io/v1alpha1", 5 | "kind": "Workflow", 6 | "metadata": { 7 | "generateName": "hello-world-" 8 | }, 9 | "spec": { 10 | "entrypoint": "whalesay", 11 | "templates": [ 12 | { 13 | "name": "whalesay", 14 | "container": { 15 | "image": "docker/whalesay:latest", 16 | "command": [ 17 | "cowsay" 18 | ], 19 | "args": [ 20 | "hello world" 21 | ] 22 | } 23 | } 24 | ] 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /projects/argo/seeds/workflow_server_fuzzer/seed2: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "argoproj.io/v1alpha1", 3 | "kind": "Workflow", 4 | "metadata": { 5 | "name": "failed", 6 | "namespace": "workflows", 7 | "labels": { 8 | "workflows.argoproj.io/controller-instanceid": "my-instanceid" 9 | } 10 | }, 11 | "spec": { 12 | "entrypoint": "whalesay", 13 | "templates": [ 14 | { 15 | "container": { 16 | "image": "docker/whalesay:latest" 17 | }, 18 | "name": "whalesay" 19 | } 20 | ] 21 | }, 22 | "status": { 23 | "phase": "Failed" 24 | } 25 | } -------------------------------------------------------------------------------- /projects/argo/seeds/workflow_server_fuzzer/seed3: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "argoproj.io/v1alpha1", 3 | "kind": "WorkflowTemplate", 4 | "metadata": { 5 | "name": "workflow-template-whalesay-template", 6 | "namespace": "workflows" 7 | }, 8 | "spec": { 9 | "workflowMetadata": { 10 | "Labels": { 11 | "labelTest": "test" 12 | }, 13 | "annotations": { 14 | "annotationTest": "test" 15 | } 16 | }, 17 | "entrypoint": "whalesay-template", 18 | "arguments": { 19 | "parameters": [ 20 | { 21 | "name": "message" 22 | } 23 | ] 24 | }, 25 | "templates": [ 26 | { 27 | "name": "whalesay-template", 28 | "inputs": { 29 | "parameters": [ 30 | { 31 | "name": "message" 32 | } 33 | ] 34 | }, 35 | "container": { 36 | "image": "docker/whalesay", 37 | "command": [ 38 | "cowsay" 39 | ], 40 | "args": [ 41 | "{{inputs.parameters.message}}" 42 | ] 43 | } 44 | } 45 | ] 46 | } 47 | } -------------------------------------------------------------------------------- /projects/argo/seeds/workflow_server_fuzzer/seed4: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "argoproj.io/v1alpha1", 3 | "kind": "CronWorkflow", 4 | "metadata": { 5 | "name": "hello-world", 6 | "namespace": "workflows" 7 | }, 8 | "spec": { 9 | "schedule": "* * * * *", 10 | "timezone": "America/Los_Angeles", 11 | "startingDeadlineSeconds": 0, 12 | "concurrencyPolicy": "Replace", 13 | "successfulJobsHistoryLimit": 4, 14 | "failedJobsHistoryLimit": 4, 15 | "suspend": false, 16 | "workflowSpec": { 17 | "entrypoint": "whalesay", 18 | "templates": [ 19 | { 20 | "name": "whalesay", 21 | "container": { 22 | "image": "docker/whalesay:latest", 23 | "command": [ 24 | "cowsay" 25 | ], 26 | "args": [ 27 | "🕓 hello world" 28 | ] 29 | } 30 | } 31 | ] 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /projects/argo/seeds/workflow_server_fuzzer/seed5: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "argoproj.io/v1alpha1", 3 | "kind": "ClusterWorkflowTemplate", 4 | "metadata": { 5 | "name": "cluster-workflow-template-whalesay-template" 6 | }, 7 | "spec": { 8 | "workflowMetadata": { 9 | "Labels": { 10 | "labelTest": "test" 11 | }, 12 | "annotations": { 13 | "annotationTest": "test" 14 | } 15 | }, 16 | "entrypoint": "whalesay-template", 17 | "arguments": { 18 | "parameters": [ 19 | { 20 | "name": "message", 21 | "value": "hello world" 22 | } 23 | ] 24 | }, 25 | "templates": [ 26 | { 27 | "name": "whalesay-template", 28 | "inputs": { 29 | "parameters": [ 30 | { 31 | "name": "message" 32 | } 33 | ] 34 | }, 35 | "container": { 36 | "image": "docker/whalesay", 37 | "command": [ 38 | "cowsay" 39 | ], 40 | "args": [ 41 | "{{inputs.parameters.message}}" 42 | ] 43 | } 44 | } 45 | ] 46 | } 47 | } -------------------------------------------------------------------------------- /projects/argo/sensors_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package sensors 17 | 18 | import ( 19 | "context" 20 | fuzz "github.com/AdaLogics/go-fuzz-headers" 21 | "github.com/argoproj/argo-events/pkg/apis/sensor/v1alpha1" 22 | "gopkg.in/yaml.v2" 23 | ) 24 | 25 | func FuzzgetDependencyExpression(data []byte) int { 26 | f := fuzz.NewConsumer(data) 27 | templBytes, err := f.GetBytes() 28 | if err != nil { 29 | return 0 30 | } 31 | templ := &v1alpha1.TriggerTemplate{} 32 | err = yaml.Unmarshal(templBytes, templ) 33 | if err != nil { 34 | return 0 35 | } 36 | sensorObj := &v1alpha1.Sensor{} 37 | err = f.GenerateStruct(sensorObj) 38 | if err != nil { 39 | return 0 40 | } 41 | ft := &v1alpha1.Trigger{} 42 | if err != nil { 43 | return 0 44 | } 45 | ft.Template = templ 46 | sensorObj.Spec.Triggers = []v1alpha1.Trigger{*ft} 47 | sensorCtx := &SensorContext{ 48 | sensor: sensorObj, 49 | } 50 | _, err = sensorCtx.getDependencyExpression(context.Background(), *ft) 51 | if err != nil { 52 | return 0 53 | } 54 | return 1 55 | } 56 | -------------------------------------------------------------------------------- /projects/argo/sessionmanager_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package session 17 | 18 | import ( 19 | "context" 20 | "testing" 21 | 22 | "github.com/argoproj/argo-cd/v2/test" 23 | "github.com/argoproj/argo-cd/v2/util/settings" 24 | ) 25 | 26 | var ( 27 | mgr *SessionManager 28 | ) 29 | 30 | func init() { 31 | testing.Init() 32 | redisClient, _ := test.NewInMemoryRedis() 33 | 34 | settingsMgr := settings.NewSettingsManager(context.Background(), getKubeClient("pass", true), "argocd") 35 | mgr = newSessionManager(settingsMgr, getProjLister(), NewUserStateStorage(redisClient)) 36 | } 37 | 38 | func FuzzSessionmanagerParse(data []byte) int { 39 | _, _, _ = mgr.VerifyToken(string(data)) 40 | return 1 41 | } 42 | 43 | func FuzzVerifyUsernamePassword(data []byte) int { 44 | if !(len(data)%2 == 0) || len(data) < 10 { 45 | return 0 46 | } 47 | username := string(data[0 : len(data)/2]) 48 | password := string(data[(len(data)/2)+1:]) 49 | _ = mgr.VerifyUsernamePassword(username, password) 50 | return 1 51 | } 52 | -------------------------------------------------------------------------------- /projects/argo/validate_event_source_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package eventsource 17 | 18 | import ( 19 | fuzz "github.com/AdaLogics/go-fuzz-headers" 20 | "github.com/argoproj/argo-events/pkg/apis/eventsource/v1alpha1" 21 | ) 22 | 23 | func FuzzValidateEventSource(data []byte) int { 24 | f := fuzz.NewConsumer(data) 25 | eventSource := &v1alpha1.EventSource{} 26 | err := f.GenerateStruct(eventSource) 27 | if err != nil { 28 | return 0 29 | } 30 | _ = ValidateEventSource(eventSource) 31 | return 1 32 | } 33 | -------------------------------------------------------------------------------- /projects/argo/workflow_parser_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package common 17 | 18 | func FuzzParseObjects(data []byte) int { 19 | _ = ParseObjects(data, false) 20 | _ = ParseObjects(data, true) 21 | return 1 22 | } 23 | -------------------------------------------------------------------------------- /projects/argo/workflow_util_fuzzer.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | package util 16 | 17 | import ( 18 | "context" 19 | "reflect" 20 | "runtime" 21 | "strings" 22 | 23 | wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" 24 | argofake "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned/fake" 25 | ) 26 | 27 | func catchPanics() { 28 | if r := recover(); r != nil { 29 | var err string 30 | switch r.(type) { 31 | case string: 32 | err = r.(string) 33 | case runtime.Error: 34 | err = r.(runtime.Error).Error() 35 | case error: 36 | err = r.(error).Error() 37 | } 38 | if strings.Contains(err, "failed to unmarshal JSON") { 39 | return 40 | } else if strings.Contains(err, "failed to unmarshal YAML") { 41 | return 42 | } else if strings.Contains(err, "failed to read file") { 43 | return 44 | } else if strings.Contains(err, "no text to unmarshal") { 45 | return 46 | } else { 47 | panic(err) 48 | } 49 | } 50 | } 51 | 52 | func FuzzSubmitWorkflow(data []byte) int { 53 | defer catchPanics() 54 | ctx := context.Background() 55 | wf := wfv1.MustUnmarshalWorkflow(data) 56 | newWf := wf.DeepCopy() 57 | wfClientSet := argofake.NewSimpleClientset() 58 | newWf, err := SubmitWorkflow(ctx, nil, wfClientSet, "test-namespace", newWf, &wfv1.SubmitOpts{DryRun: true}) 59 | if err != nil { 60 | return 0 61 | } 62 | if !reflect.DeepEqual(wf.Spec, newWf.Spec) { 63 | panic("Spec should be equal but is not") 64 | } 65 | if !reflect.DeepEqual(wf.Status, newWf.Status) { 66 | panic("Status should be equal but is not") 67 | } 68 | return 1 69 | } 70 | -------------------------------------------------------------------------------- /projects/argo/workflow_v1alpha1_fuzzers.go: -------------------------------------------------------------------------------- 1 | // 2 | // Licensed under the Apache License, Version 2.0 (the "License"); 3 | // you may not use this file except in compliance with the License. 4 | // You may obtain a copy of the License at 5 | // 6 | // http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // Unless required by applicable law or agreed to in writing, software 9 | // distributed under the License is distributed on an "AS IS" BASIS, 10 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 | // See the License for the specific language governing permissions and 12 | // limitations under the License. 13 | // 14 | 15 | package v1alpha1 16 | 17 | import ( 18 | fuzz "github.com/AdaLogics/go-fuzz-headers" 19 | ) 20 | 21 | func FuzzContainerSetTemplateValidate(data []byte) int { 22 | in := &ContainerSetTemplate{} 23 | f := fuzz.NewConsumer(data) 24 | err := f.GenerateStruct(in) 25 | if err != nil { 26 | return 0 27 | } 28 | in.Validate() 29 | return 1 30 | } 31 | -------------------------------------------------------------------------------- /projects/argo/workflow_validation_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package validate 17 | 18 | import ( 19 | fuzz "github.com/AdaLogics/go-fuzz-headers" 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | 22 | wfv1 "github.com/argoproj/argo-workflows/v3/pkg/apis/workflow/v1alpha1" 23 | fakewfclientset "github.com/argoproj/argo-workflows/v3/pkg/client/clientset/versioned/fake" 24 | "github.com/argoproj/argo-workflows/v3/workflow/templateresolution" 25 | ) 26 | 27 | var ( 28 | wfClientsetFuzz = fakewfclientset.NewSimpleClientset() 29 | wftmplGetterFuzz = templateresolution.WrapWorkflowTemplateInterface(wfClientsetFuzz.ArgoprojV1alpha1().WorkflowTemplates(metav1.NamespaceDefault)) 30 | cwftmplGetterFuzz = templateresolution.WrapClusterWorkflowTemplateInterface(wfClientsetFuzz.ArgoprojV1alpha1().ClusterWorkflowTemplates()) 31 | ) 32 | 33 | func FuzzValidateWorkflow(data []byte) int { 34 | f := fuzz.NewConsumer(data) 35 | wf := &wfv1.Workflow{} 36 | err := f.GenerateStruct(wf) 37 | if err != nil { 38 | return 0 39 | } 40 | if wf.Spec.WorkflowTemplateRef == nil { 41 | return 0 42 | } 43 | opts := ValidateOpts{} 44 | _ = ValidateWorkflow(wftmplGetterFuzz, cwftmplGetterFuzz, wf, opts) 45 | return 1 46 | } 47 | -------------------------------------------------------------------------------- /projects/argo/workflows_sso_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package sso 17 | 18 | func FuzzSSOAuthorize(data []byte) int { 19 | _, _ = NullSSO.Authorize(string(data)) 20 | return 1 21 | } 22 | -------------------------------------------------------------------------------- /projects/argo/workflows_sync_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package sync 17 | 18 | func FuzzDecodeLockName(data []byte) int { 19 | _, _ = DecodeLockName(string(data)) 20 | return 1 21 | } 22 | -------------------------------------------------------------------------------- /projects/cilium/bpf_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package bpf 17 | 18 | import ( 19 | "github.com/cilium/ebpf" 20 | fuzz "github.com/AdaLogics/go-fuzz-headers" 21 | "os" 22 | ) 23 | 24 | var ( 25 | bpffsPath = "bpffFile" 26 | elfPath = "elfFile" 27 | targets = map[int]string{ 28 | 0: "StartBPFFSMigration", 29 | 1: "FinalizeBPFFSMigration", 30 | } 31 | ) 32 | 33 | func FuzzBpf(data []byte) int { 34 | f := fuzz.NewConsumer(data) 35 | bpffsData, err := f.GetBytes() 36 | if err != nil { 37 | return 0 38 | } 39 | 40 | coll := &ebpf.CollectionSpec{} 41 | f.GenerateStruct(coll) 42 | 43 | target, err := f.GetInt() 44 | if err != nil { 45 | return 0 46 | } 47 | 48 | // bpff File 49 | bpffFile, err := os.Create(bpffsPath) 50 | if err != nil { 51 | os.Remove(bpffsPath) 52 | return 0 53 | } 54 | defer bpffFile.Close() 55 | defer os.Remove(bpffsPath) 56 | bpffFile.Write(bpffsData) 57 | switch targets[target%len(targets)] { 58 | case "StartBPFFSMigration": 59 | StartBPFFSMigration(bpffsPath, coll) 60 | case "FinalizeBPFFSMigration": 61 | revert, err := f.GetBool() 62 | if err != nil { 63 | return 0 64 | } 65 | FinalizeBPFFSMigration(bpffsPath, coll, revert) 66 | } 67 | return 1 68 | } -------------------------------------------------------------------------------- /projects/cilium/config_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package config 17 | 18 | import ( 19 | "bytes" 20 | ) 21 | 22 | func FuzzConfigParse(data []byte) int { 23 | _, _ = Parse(bytes.NewReader(data)) 24 | return 1 25 | } 26 | -------------------------------------------------------------------------------- /projects/cilium/elf_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package elf 17 | 18 | import ( 19 | "bytes" 20 | "os" 21 | 22 | fuzz "github.com/AdaLogics/go-fuzz-headers" 23 | "github.com/sirupsen/logrus" 24 | ) 25 | 26 | func FuzzElfOpen(data []byte) int { 27 | f, err := os.Create("test_elf") 28 | if err != nil { 29 | os.Remove("test_elf") 30 | return 0 31 | } 32 | defer f.Close() 33 | defer os.Remove("test_elf") 34 | f.Write(data) 35 | e, err := Open("test_elf") 36 | if err == nil { 37 | e.Close() 38 | } 39 | return 1 40 | } 41 | 42 | func FuzzElfWrite(data []byte) int { 43 | f := fuzz.NewConsumer(data) 44 | d1, err := f.GetBytes() 45 | if err != nil { 46 | return 0 47 | } 48 | ra := bytes.NewReader(d1) 49 | 50 | logger := logrus.New() 51 | logger.Out = &bytes.Buffer{} 52 | entry := logrus.NewEntry(logger) 53 | 54 | e, err := NewELF(ra, entry) 55 | if err != nil { 56 | return 0 57 | } 58 | defer e.Close() 59 | 60 | intOptions := make(map[string]uint32) 61 | strOptions := make(map[string]string) 62 | 63 | p := "path_file" 64 | 65 | e.Write(p, intOptions, strOptions) 66 | defer os.Remove(p) 67 | 68 | return 1 69 | } 70 | -------------------------------------------------------------------------------- /projects/cilium/format_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package format 17 | 18 | import ( 19 | "runtime" 20 | 21 | "github.com/cilium/cilium/pkg/monitor/payload" 22 | 23 | fuzz "github.com/AdaLogics/go-fuzz-headers" 24 | ) 25 | 26 | /* 27 | This fuzzer invokes the garbage collector, because 28 | fmt.Sprintf() seemingly will not free memory between 29 | runs. The GC slows down the fuzzer significantly. 30 | */ 31 | func FuzzFormatEvent(data []byte) int { 32 | f := fuzz.NewConsumer(data) 33 | pl := &payload.Payload{} 34 | err := f.GenerateStruct(pl) 35 | if err != nil { 36 | return 0 37 | } 38 | 39 | // Invalid pl.Data. Leave here to avoid 40 | // invoking the GC. 41 | if len(pl.Data) == 0 { 42 | return 0 43 | } 44 | 45 | defer func() { 46 | if r := recover(); r != nil { 47 | } 48 | runtime.GC() 49 | }() 50 | 51 | mf := NewMonitorFormatter(0, nil) 52 | 53 | mf.FormatEvent(pl) 54 | return 1 55 | } 56 | -------------------------------------------------------------------------------- /projects/cilium/fuzz_config_parse.options: -------------------------------------------------------------------------------- 1 | [libfuzzer] 2 | max_len = 1200000 -------------------------------------------------------------------------------- /projects/cilium/fuzz_get_labels_from_yaml.options: -------------------------------------------------------------------------------- 1 | [libfuzzer] 2 | max_len = 1200000 -------------------------------------------------------------------------------- /projects/cilium/hubble_parser_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package parser 17 | 18 | import ( 19 | "io" 20 | 21 | observerTypes "github.com/cilium/cilium/pkg/hubble/observer/types" 22 | "github.com/sirupsen/logrus" 23 | 24 | fuzz "github.com/AdaLogics/go-fuzz-headers" 25 | ) 26 | 27 | var ( 28 | log *logrus.Logger 29 | payloads = map[int]string{ 30 | 0: "PerfEvent", 31 | 1: "AgentEvent", 32 | 2: "LostEvent", 33 | } 34 | ) 35 | 36 | func init() { 37 | log = logrus.New() 38 | log.SetOutput(io.Discard) 39 | } 40 | 41 | func FuzzParserDecode(data []byte) int { 42 | p, err := New(log, nil, nil, nil, nil, nil, nil, nil) 43 | if err != nil { 44 | return 0 45 | } 46 | 47 | f := fuzz.NewConsumer(data) 48 | payloadType, err := f.GetInt() 49 | if err != nil { 50 | return 0 51 | } 52 | 53 | mo := &observerTypes.MonitorEvent{} 54 | 55 | switch payloads[payloadType%len(payloads)] { 56 | case "PerfEvent": 57 | pe := &observerTypes.PerfEvent{} 58 | f.GenerateStruct(pe) 59 | mo.Payload = pe 60 | case "AgentEvent": 61 | ae := &observerTypes.AgentEvent{} 62 | f.GenerateStruct(ae) 63 | mo.Payload = ae 64 | case "LostEvent": 65 | le := &observerTypes.LostEvent{} 66 | f.GenerateStruct(le) 67 | mo.Payload = le 68 | } 69 | _, _ = p.Decode(mo) 70 | return 0 71 | } 72 | -------------------------------------------------------------------------------- /projects/cilium/labels_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package labels 17 | 18 | func FuzzLabelsParse(data []byte) int { 19 | _, _ = Parse(string(data)) 20 | return 1 21 | } 22 | -------------------------------------------------------------------------------- /projects/cilium/labelsfilter_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package labelsfilter 17 | 18 | import ( 19 | "encoding/json" 20 | "fmt" 21 | "os" 22 | 23 | fuzz "github.com/AdaLogics/go-fuzz-headers" 24 | "github.com/cilium/cilium/pkg/labels" 25 | ) 26 | 27 | func FuzzLabelsfilterPkg(data []byte) int { 28 | f := fuzz.NewConsumer(data) 29 | 30 | prefixes := make([]string, 0) 31 | err := f.CreateSlice(&prefixes) 32 | if err != nil { 33 | return 0 34 | } 35 | lpc := &labelPrefixCfg{} 36 | err = f.GenerateStruct(lpc) 37 | if err != nil { 38 | return 0 39 | } 40 | lpc.Version = LPCfgFileVersion 41 | fileBytes, err := json.Marshal(lpc) 42 | 43 | if err != nil { 44 | return 0 45 | } 46 | stringMap := make(map[string]string) 47 | err = f.FuzzMap(&stringMap) 48 | if err != nil { 49 | return 0 50 | } 51 | 52 | source, err := f.GetString() 53 | if err != nil { 54 | return 0 55 | } 56 | 57 | lbls := labels.Map2Labels(stringMap, source) 58 | 59 | file, err := os.Create("file") 60 | defer file.Close() 61 | if err != nil { 62 | return 0 63 | } 64 | 65 | _, err = file.Write(fileBytes) 66 | if err != nil { 67 | return 0 68 | } 69 | 70 | err = ParseLabelPrefixCfg(prefixes, "file") 71 | if err != nil { 72 | fmt.Println(err) 73 | return 0 74 | } 75 | _, _ = Filter(lbls) 76 | return 1 77 | } 78 | -------------------------------------------------------------------------------- /projects/cilium/matchpattern_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package matchpattern 17 | 18 | func FuzzMatchpatternValidate(data []byte) int { 19 | _, _ = Validate(string(data)) 20 | return 1 21 | } 22 | 23 | func FuzzMatchpatternValidateWithoutCache(data []byte) int { 24 | _, _ = ValidateWithoutCache(string(data)) 25 | return 1 26 | } 27 | -------------------------------------------------------------------------------- /projects/cilium/policy_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package policy 17 | 18 | func FuzzNewVisibilityPolicy(data []byte) int { 19 | _, _ = NewVisibilityPolicy(string(data)) 20 | return 1 21 | } 22 | -------------------------------------------------------------------------------- /projects/cluster-api/fuzz_conditions.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package conditions 17 | 18 | import ( 19 | "testing" 20 | fuzz "github.com/AdaLogics/go-fuzz-headers" 21 | clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" 22 | ) 23 | 24 | func FuzzPatchApply(f *testing.F) { 25 | f.Fuzz(func (t *testing.T, data []byte){ 26 | fdp := fuzz.NewConsumer(data) 27 | getterBefore := &clusterv1.Cluster{} 28 | err := fdp.GenerateStruct(getterBefore) 29 | if err != nil { 30 | return 31 | } 32 | getterAfter := &clusterv1.Cluster{} 33 | err = fdp.GenerateStruct(getterAfter) 34 | if err != nil { 35 | return 36 | } 37 | 38 | setter := &clusterv1.Cluster{} 39 | err = fdp.GenerateStruct(setter) 40 | if err != nil { 41 | return 42 | } 43 | 44 | var options []ApplyOption 45 | err = fdp.CreateSlice(&options) 46 | if err != nil { 47 | return 48 | } 49 | patch, err := NewPatch(getterBefore, getterAfter) 50 | if err != nil { 51 | return 52 | } 53 | patch.Apply(setter, options...) 54 | }) 55 | } 56 | -------------------------------------------------------------------------------- /projects/cluster-api/fuzz_util_container.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package container 17 | 18 | import "testing" 19 | 20 | func FuzzModifyImageRepository(f *testing.F) { 21 | f.Fuzz(func (t *testing.T, imageName, repositoryName string){ 22 | ModifyImageRepository(imageName, repositoryName) 23 | }) 24 | } 25 | func FuzzModifyImageTag(f *testing.F) { 26 | f.Fuzz(func (t *testing.T, imageName, repositoryName string){ 27 | ModifyImageRepository(imageName, repositoryName) 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /projects/cluster-api/non-oss-fuzz/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gcr.io/oss-fuzz-base/base-builder-go 2 | RUN git clone --depth 1 https://github.com/kubernetes-sigs/cluster-api 3 | RUN cd $SRC && go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest 4 | RUN git clone --depth 1 --branch cluster-api https://github.com/AdamKorcz/cncf-fuzzing $SRC/cncf-fuzzing 5 | RUN mv $SRC/cncf-fuzzing/projects/cluster-api/non-oss-fuzz/build.sh $SRC/ 6 | WORKDIR $SRC/cluster-api 7 | ENV FUZZING_LANGUAGE go 8 | ENV FUZZER fuzz_cluster_controller 9 | ENV FUZZ_TIME 600 10 | RUN compile 11 | RUN mkdir -p /usr/local/kubebuilder/bin 12 | CMD ["sh", "-c", "export KUBEBUILDER_BINARIES=$(setup-envtest use -p path) && mv ${KUBEBUILDER_BINARIES}/* /usr/local/kubebuilder/bin/ && /out/${FUZZER} -max_total_time=${FUZZ_TIME}"] 13 | 14 | -------------------------------------------------------------------------------- /projects/cluster-api/non-oss-fuzz/build.sh: -------------------------------------------------------------------------------- 1 | # Setup CRDs for the controller fuzzers 2 | cd $SRC/cncf-fuzzing/projects/cluster-api/crd-creation 3 | go mod init create-fuzz-env 4 | go mod tidy 5 | go run main.go 6 | 7 | cd $SRC/cluster-api 8 | sed -i 's/root := path.Join(path.Dir(filename), "..", "..", "..")/root := "."/g' $SRC/cluster-api/internal/test/envtest/environment.go 9 | sed -i '120 a code := 1' $SRC/cluster-api/internal/test/envtest/environment.go 10 | sed -i 's/code := input.M.Run()/return 1/g' $SRC/cluster-api/internal/test/envtest/environment.go 11 | sed -i 's/"path"/\/\/"path"/g' $SRC/cluster-api/internal/test/envtest/environment.go 12 | sed -i 's/_, filename, _, _/\/\/_, filename, _, _/g' $SRC/cluster-api/internal/test/envtest/environment.go 13 | #sed -i 's/err = kerrors.NewAggregate([]error{err, env.Stop()})/\/\/err = kerrors.NewAggregate([]error{err, env.Stop()})/g' $SRC/cluster-api/internal/test/envtest/environment.go 14 | 15 | sed -i 's/root := path.Join(path.Dir(filename), "..", "..", "..")/root := "."/g' $SRC/cluster-api/internal/test/envtest/webhooks.go 16 | sed -i 's/"path"/\/\/"path"/g' $SRC/cluster-api/internal/test/envtest/webhooks.go 17 | sed -i 's/_, filename, _, _/\/\/_, filename, _, _/g' $SRC/cluster-api/internal/test/envtest/webhooks.go 18 | sed -i 's/goruntime "runtime"/\/\/goruntime "runtime"/g' $SRC/cluster-api/internal/test/envtest/webhooks.go 19 | 20 | 21 | cp $SRC/cncf-fuzzing/projects/cluster-api/cluster_controller_fuzzer.go \ 22 | $SRC/cluster-api/internal/controllers/cluster/ 23 | compile_go_fuzzer sigs.k8s.io/cluster-api/internal/controllers/cluster FuzzClusterController fuzz_cluster_controller 24 | exit 0 -------------------------------------------------------------------------------- /projects/cluster-api/non-oss-fuzz/run_fuzzer.sh: -------------------------------------------------------------------------------- 1 | sudo docker build -t cluster_controller_fuzzer . 2 | sudo docker run cluster_controller_fuzzer -------------------------------------------------------------------------------- /projects/cluster-api/yaml_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package yaml 17 | 18 | import ( 19 | "os" 20 | "testing" 21 | ) 22 | 23 | func FuzzYamlParse(f *testing.F) { 24 | f.Fuzz(func (t *testing.T, data []byte){ 25 | file, err := os.Create("fuzz") 26 | if err != nil { 27 | return 28 | } 29 | defer func() { 30 | file.Close() 31 | os.Remove("fuzz") 32 | }() 33 | _, err = file.Write(data) 34 | if err != nil { 35 | return 36 | } 37 | Parse(ParseInput{File: "fuzz"}) 38 | }) 39 | } 40 | -------------------------------------------------------------------------------- /projects/cri-o/config_apparmor_fuzzer.go: -------------------------------------------------------------------------------- 1 | package apparmor 2 | 3 | import ( 4 | fuzz "github.com/AdaLogics/go-fuzz-headers" 5 | "os" 6 | ) 7 | 8 | func FuzzLoadConfig(data []byte) int { 9 | c := Config{} 10 | c.enabled = true 11 | 12 | f := fuzz.NewConsumer(data) 13 | confBytes, err := f.GetBytes() 14 | if err != nil { 15 | return 0 16 | } 17 | 18 | randomFile, err := os.Create("apparmor_fuzz.config") 19 | if err != nil { 20 | return 0 21 | } 22 | defer os.Remove("apparmor_fuzz.config") 23 | 24 | _, err = randomFile.Write(confBytes) 25 | if err != nil { 26 | randomFile.Close() 27 | return 0 28 | } 29 | 30 | c.LoadProfile("apparmor_fuzz.config") 31 | randomFile.Close() 32 | 33 | return 1 34 | } 35 | -------------------------------------------------------------------------------- /projects/cri-o/config_blockio_fuzzer.go: -------------------------------------------------------------------------------- 1 | package blockio 2 | 3 | import ( 4 | fuzz "github.com/AdaLogics/go-fuzz-headers" 5 | "os" 6 | ) 7 | 8 | func FuzzLoadConfig(data []byte) int { 9 | c := Config{} 10 | c.enabled = true 11 | 12 | f := fuzz.NewConsumer(data) 13 | confBytes, err := f.GetBytes() 14 | if err != nil { 15 | return 0 16 | } 17 | 18 | randomFile, err := os.Create("blockio_fuzz.config") 19 | if err != nil { 20 | return 0 21 | } 22 | defer os.Remove("blockio_fuzz.config") 23 | 24 | _, err = randomFile.Write(confBytes) 25 | if err != nil { 26 | randomFile.Close() 27 | return 0 28 | } 29 | 30 | c.Load("blockio_fuzz.config") 31 | randomFile.Close() 32 | 33 | return 1 34 | } 35 | -------------------------------------------------------------------------------- /projects/cri-o/config_fuzzer.go: -------------------------------------------------------------------------------- 1 | package config 2 | 3 | import ( 4 | "context" 5 | fuzz "github.com/AdaLogics/go-fuzz-headers" 6 | "github.com/sirupsen/logrus" 7 | "os" 8 | ) 9 | 10 | func FuzzLoadConfig(data []byte) int { 11 | logrus.SetLevel(logrus.ErrorLevel) 12 | 13 | c, err := DefaultConfig() 14 | if err != nil { 15 | return 0 16 | } 17 | 18 | f := fuzz.NewConsumer(data) 19 | confBytes, err := f.GetBytes() 20 | if err != nil { 21 | return 0 22 | } 23 | 24 | randomFile, err := os.Create("cri-o.config") 25 | if err != nil { 26 | return 0 27 | } 28 | defer os.Remove("cri-o.config") 29 | 30 | _, err = randomFile.Write(confBytes) 31 | if err != nil { 32 | randomFile.Close() 33 | return 0 34 | } 35 | 36 | if err = c.UpdateFromFile(context.Background(), "cri-o.config"); err != nil { 37 | randomFile.Close() 38 | return 0 39 | } 40 | 41 | if err = c.Validate(false); err != nil { 42 | randomFile.Close() 43 | return 0 44 | } 45 | 46 | devNullFile, err := os.Open(os.DevNull) 47 | if err != nil { 48 | randomFile.Close() 49 | return 0 50 | } 51 | 52 | if err = c.WriteTemplate(true, devNullFile); err != nil { 53 | return 0 54 | } 55 | 56 | randomFile.Close() 57 | devNullFile.Close() 58 | 59 | return 1 60 | } 61 | -------------------------------------------------------------------------------- /projects/cri-o/config_rdt_fuzzer.go: -------------------------------------------------------------------------------- 1 | package rdt 2 | 3 | import ( 4 | fuzz "github.com/AdaLogics/go-fuzz-headers" 5 | "os" 6 | ) 7 | 8 | func FuzzLoadConfig(data []byte) int { 9 | c := Config{} 10 | c.enabled = true 11 | c.supported = true 12 | 13 | f := fuzz.NewConsumer(data) 14 | confBytes, err := f.GetBytes() 15 | if err != nil { 16 | return 0 17 | } 18 | 19 | randomFile, err := os.Create("rdt_fuzz.config") 20 | if err != nil { 21 | return 0 22 | } 23 | defer os.Remove("rdt_fuzz.config") 24 | 25 | _, err = randomFile.Write(confBytes) 26 | if err != nil { 27 | randomFile.Close() 28 | return 0 29 | } 30 | 31 | c.Load("rdt_fuzz.config") 32 | randomFile.Close() 33 | 34 | return 1 35 | } 36 | -------------------------------------------------------------------------------- /projects/cri-o/dicts/fuzz_server_logsan.dict: -------------------------------------------------------------------------------- 1 | "INFOFUZZ[" 2 | "WARNFUZZ[" 3 | "DEBUFUZZ[" 4 | "FATAFUZZ[" 5 | "INFO[0Fuz]" 6 | "WARN[0Fuz]" 7 | "DEBU[0Fuz]" 8 | "FATA[0Fuz]" -------------------------------------------------------------------------------- /projects/cri-o/server_fuzzer2.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | fuzz "github.com/AdaLogics/go-fuzz-headers" 5 | "github.com/containers/storage/pkg/idtools" 6 | "os" 7 | ) 8 | 9 | func FuzzgetDecryptionKeys(data []byte) int { 10 | keysPath := "/tmp/keysPath" 11 | err := os.MkdirAll(keysPath, 0777) 12 | if err != nil { 13 | return 0 14 | } 15 | defer os.RemoveAll(keysPath) 16 | f := fuzz.NewConsumer(data) 17 | err = f.CreateFiles(keysPath) 18 | if err != nil { 19 | return 0 20 | } 21 | return 1 22 | } 23 | 24 | func FuzzIdtoolsParseIDMap(data []byte) int { 25 | f := fuzz.NewConsumer(data) 26 | mapSec := make([]string, 0) 27 | err := f.CreateSlice(&mapSec) 28 | if err != nil { 29 | return 0 30 | } 31 | mapSetting, err := f.GetString() 32 | if err != nil { 33 | return 0 34 | } 35 | _, _ = idtools.ParseIDMap(mapSec, mapSetting) 36 | return 1 37 | } 38 | -------------------------------------------------------------------------------- /projects/cri-o/storage_fuzzer.go: -------------------------------------------------------------------------------- 1 | package storage 2 | 3 | import ( 4 | "os" 5 | "github.com/containers/image/v5/types" 6 | "github.com/containers/image/v5/transports/alltransports" 7 | "github.com/containers/image/v5/pkg/shortnames" 8 | 9 | fuzz "github.com/AdaLogics/go-fuzz-headers" 10 | ) 11 | 12 | func FuzzParseImageName(data []byte) int { 13 | _, _ = alltransports.ParseImageName(string(data)) 14 | return 1 15 | } 16 | 17 | func FuzzShortnamesResolve(data []byte) int { 18 | f := fuzz.NewConsumer(data) 19 | confBytes, err := f.GetBytes() 20 | if err != nil { 21 | return 0 22 | } 23 | name, err := f.GetString() 24 | if err != nil { 25 | return 0 26 | } 27 | confFile, err := os.Create("registries.conf") 28 | if err != nil { 29 | return 0 30 | } 31 | defer os.Remove("registries.conf") 32 | _, err = confFile.Write(confBytes) 33 | if err != nil { 34 | return 0 35 | } 36 | 37 | ctx := &types.SystemContext{ 38 | SystemRegistriesConfPath: "registries.conf", 39 | } 40 | _, _ = shortnames.Resolve(ctx, name) 41 | return 1 42 | } -------------------------------------------------------------------------------- /projects/cri-o/utils_fuzzer.go: -------------------------------------------------------------------------------- 1 | package utils 2 | 3 | import ( 4 | fuzz "github.com/AdaLogics/go-fuzz-headers" 5 | "os" 6 | ) 7 | 8 | func FuzzGeneratePasswd(data []byte) int { 9 | etcDir := "/tmp/etcDir" 10 | err := os.MkdirAll(etcDir, 0777) 11 | if err != nil { 12 | return 0 13 | } 14 | defer os.RemoveAll(etcDir) 15 | f := fuzz.NewConsumer(data) 16 | err = f.CreateFiles(etcDir) 17 | if err != nil { 18 | return 0 19 | } 20 | uid, gid, _, err := GetUserInfo(etcDir, "root") 21 | if err != nil { 22 | return 0 23 | } 24 | username, err := f.GetString() 25 | if err != nil { 26 | return 0 27 | } 28 | _, _ = GeneratePasswd(username, uid, gid, "", etcDir, etcDir) 29 | 30 | return 1 31 | } 32 | -------------------------------------------------------------------------------- /projects/cubefs/build.sh: -------------------------------------------------------------------------------- 1 | set -o nounset 2 | set -o pipefail 3 | set -o errexit 4 | set -x 5 | 6 | mv $SRC/cncf-fuzzing/projects/cubefs/fuzz_master.go $SRC/cubefs/master/ 7 | 8 | go mod tidy 9 | go mod vendor 10 | go get github.com/AdaLogics/go-fuzz-headers 11 | source $SRC/cubefs/build/cgo_env.sh 12 | compile_go_fuzzer github.com/cubefs/cubefs/master FuzzCreateVol fuzz_create_vol 13 | compile_go_fuzzer github.com/cubefs/cubefs/master FuzzNewMetaNode fuzz_new_metanode 14 | 15 | mv $SRC/cncf-fuzzing/projects/cubefs/fuzz_metanode.go $SRC/cubefs/metanode/ 16 | compile_go_fuzzer github.com/cubefs/cubefs/metanode FuzzNewInode fuzz_new_inode 17 | compile_go_fuzzer github.com/cubefs/cubefs/metanode FuzzNewExtend fuzz_new_extend 18 | 19 | mv $SRC/cncf-fuzzing/projects/cubefs/fuzz_datanode.go $SRC/cubefs/datanode/ 20 | compile_go_fuzzer github.com/cubefs/cubefs/datanode FuzzNewDisk fuzz_new_disk 21 | 22 | mv $SRC/cncf-fuzzing/projects/cubefs/fuzz_client.go $SRC/cubefs/client/fs/ 23 | compile_go_fuzzer github.com/cubefs/cubefs/client/fs FuzzNewFile fuzz_new_file 24 | 25 | mv $SRC/cncf-fuzzing/projects/cubefs/fuzz_sdk.go $SRC/cubefs/sdk/meta/ 26 | compile_go_fuzzer github.com/cubefs/cubefs/sdk/meta FuzzNewMeta fuzz_new_meta 27 | -------------------------------------------------------------------------------- /projects/cubefs/fuzz_client.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | // Copyright 2023 ADA Logics Ltd 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | package fs 19 | 20 | import ( 21 | fuzz "github.com/AdaLogics/go-fuzz-headers" 22 | "github.com/cubefs/cubefs/proto" 23 | ) 24 | 25 | type NewFileParam struct { 26 | Pino uint64 27 | Flag uint32 28 | FileName string 29 | Info *proto.InodeInfo 30 | Super *Super 31 | } 32 | 33 | type NewDirParam struct { 34 | Pino uint64 35 | FileName string 36 | Info *proto.InodeInfo 37 | Super *Super 38 | } 39 | 40 | func FuzzNewFile(data []byte) int { 41 | f := fuzz.NewConsumer(data) 42 | param := NewFileParam{} 43 | 44 | err := f.GenerateStruct(¶m) 45 | if err != nil { 46 | return 0 47 | } 48 | 49 | file := NewFile(param.Super, param.Info, param.Flag, param.Pino, param.FileName) 50 | if file == nil { 51 | return 0 52 | } 53 | return 1 54 | } 55 | 56 | func FuzzNewDir(data []byte) int { 57 | f := fuzz.NewConsumer(data) 58 | param := NewDirParam{} 59 | 60 | err := f.GenerateStruct(¶m) 61 | if err != nil { 62 | return 0 63 | } 64 | 65 | dir := NewDir(param.Super, param.Info, param.Pino, param.FileName) 66 | if dir == nil { 67 | return 0 68 | } 69 | return 1 70 | } 71 | -------------------------------------------------------------------------------- /projects/cubefs/fuzz_datanode.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | // Copyright 2023 ADA Logics Ltd 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | package datanode 19 | 20 | import ( 21 | fuzz "github.com/AdaLogics/go-fuzz-headers" 22 | ) 23 | 24 | type NewDiskParam struct { 25 | Path string 26 | ReservedSpace uint64 27 | DiskRdonlySpace uint64 28 | MaxErrCnt int 29 | Space *SpaceManager 30 | } 31 | 32 | func FuzzNewDisk(data []byte) int { 33 | f := fuzz.NewConsumer(data) 34 | param := NewDiskParam{ 35 | Space: &SpaceManager{}, 36 | } 37 | param.Space.dataNode = &DataNode{} 38 | 39 | err := f.GenerateStruct(¶m) 40 | if err != nil { 41 | return 0 42 | } 43 | 44 | disk, err := NewDisk(param.Path, param.ReservedSpace, param.DiskRdonlySpace, param.MaxErrCnt, param.Space) 45 | if disk == nil { 46 | return 0 47 | } 48 | 49 | if err != nil { 50 | return 0 51 | } 52 | return 1 53 | } 54 | -------------------------------------------------------------------------------- /projects/cubefs/fuzz_master.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | // Copyright 2023 ADA Logics Ltd 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | package master 20 | 21 | import ( 22 | fuzz "github.com/AdaLogics/go-fuzz-headers" 23 | ) 24 | 25 | type MetaNodeParam struct { 26 | Addr string 27 | ZoneName string 28 | ClusterID string 29 | } 30 | 31 | func FuzzCreateVol(data []byte) int { 32 | f := fuzz.NewConsumer(data) 33 | vv := volValue{} 34 | 35 | err := f.GenerateStruct(&vv) 36 | if err != nil { 37 | return 0 38 | } 39 | 40 | vol := newVol(vv) 41 | if vol == nil { 42 | return 0 43 | } 44 | return 1 45 | } 46 | 47 | func FuzzNewMetaNode(data []byte) int { 48 | f := fuzz.NewConsumer(data) 49 | param := MetaNodeParam{} 50 | 51 | err := f.GenerateStruct(¶m) 52 | if err != nil { 53 | return 0 54 | } 55 | 56 | node := newMetaNode(param.Addr, param.ZoneName, param.ClusterID) 57 | if node == nil { 58 | return 0 59 | } 60 | return 1 61 | } 62 | -------------------------------------------------------------------------------- /projects/cubefs/fuzz_metanode.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | // Copyright 2023 ADA Logics Ltd 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | package metanode 19 | 20 | import ( 21 | fuzz "github.com/AdaLogics/go-fuzz-headers" 22 | ) 23 | 24 | type InodeParam struct { 25 | Ino uint64 26 | Type uint32 27 | } 28 | 29 | func FuzzNewInode(data []byte) int { 30 | f := fuzz.NewConsumer(data) 31 | param := InodeParam{} 32 | 33 | err := f.GenerateStruct(¶m) 34 | if err != nil { 35 | return 0 36 | } 37 | 38 | ino := NewInode(param.Ino, param.Type) 39 | if ino == nil { 40 | return 0 41 | } 42 | return 1 43 | } 44 | 45 | func FuzzNewExtend(data []byte) int { 46 | f := fuzz.NewConsumer(data) 47 | var ino uint64 48 | 49 | err := f.GenerateStruct(&ino) 50 | if err != nil { 51 | return 0 52 | } 53 | 54 | extend := NewExtend(ino) 55 | if extend == nil { 56 | return 0 57 | } 58 | return 1 59 | } 60 | -------------------------------------------------------------------------------- /projects/cubefs/fuzz_sdk.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | // Copyright 2023 ADA Logics Ltd 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | package meta 19 | 20 | import ( 21 | fuzz "github.com/AdaLogics/go-fuzz-headers" 22 | ) 23 | 24 | func FuzzNewMeta(data []byte) int { 25 | f := fuzz.NewConsumer(data) 26 | config := MetaConfig{} 27 | 28 | err := f.GenerateStruct(&config) 29 | if err != nil { 30 | return 0 31 | } 32 | 33 | _, err = NewMetaWrapper(&config) 34 | if err != nil { 35 | return 0 36 | } 37 | return 1 38 | } 39 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_acl_apply_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package acl 17 | 18 | import ( 19 | "testing" 20 | fuzz "github.com/AdamKorcz/go-fuzz-headers-1" 21 | "github.com/dapr/dapr/pkg/config" 22 | commonv1pb "github.com/dapr/dapr/pkg/proto/common/v1" 23 | ) 24 | 25 | func FuzzIsOperationAllowedByAccessControlPolicy(f *testing.F) { 26 | f.Fuzz(func(t *testing.T, data []byte) { 27 | ff := fuzz.NewConsumer(data) 28 | spiffeID := &config.SpiffeID{} 29 | ff.GenerateStruct(spiffeID) 30 | srcAppID, err := ff.GetString() 31 | if err != nil { 32 | return 33 | } 34 | if srcAppID == "" { 35 | return 36 | } 37 | inputOperation, err := ff.GetString() 38 | if err != nil { 39 | return 40 | } 41 | httpVerbInd, err := ff.GetInt() 42 | if err != nil { 43 | return 44 | } 45 | httpVerbInt32 := int32(httpVerbInd%10) 46 | httpVerb := commonv1pb.HTTPExtension_Verb(httpVerbInt32) 47 | isHTTP, err := ff.GetBool() 48 | if err != nil { 49 | return 50 | } 51 | accessControlList := &config.AccessControlList{} 52 | ff.GenerateStruct(accessControlList) 53 | accessControlList.DefaultAction = config.DenyAccess 54 | _, _ = IsOperationAllowedByAccessControlPolicy(spiffeID, srcAppID, inputOperation, httpVerb, isHTTP, accessControlList) 55 | }) 56 | } 57 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_acl_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package acl 17 | 18 | import ( 19 | fuzz "github.com/AdaLogics/go-fuzz-headers" 20 | "github.com/dapr/dapr/pkg/config" 21 | "github.com/dapr/kit/logger" 22 | "github.com/PuerkitoBio/purell" 23 | "testing" 24 | ) 25 | 26 | func init() { 27 | log.SetOutputLevel(logger.FatalLevel) 28 | } 29 | 30 | func FuzzParseAccessControlSpec(f *testing.F) { 31 | f.Fuzz(func(t *testing.T, specData []byte) { 32 | ff := fuzz.NewConsumer(specData) 33 | s := &config.AccessControlSpec{} 34 | ff.GenerateStruct(s) 35 | b, err := ff.GetBool() 36 | if err != nil { 37 | return 38 | } 39 | _, _ = ParseAccessControlSpec(*s, b) 40 | }) 41 | } 42 | 43 | func FuzzPurellTest(f *testing.F) { 44 | f.Fuzz(func(t *testing.T, operation string) { 45 | _, _ = purell.NormalizeURLString(operation, purell.FlagsUsuallySafeGreedy|purell.FlagRemoveDuplicateSlashes) 46 | }) 47 | } 48 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_components_contrib_azure_eventgrid_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package eventgrid 17 | 18 | import ( 19 | "context" 20 | "testing" 21 | "github.com/dapr/kit/logger" 22 | "github.com/dapr/components-contrib/bindings" 23 | ) 24 | 25 | var ( 26 | log = logger.NewLogger("test") 27 | eh = AzureEventGrid{} 28 | m = bindings.Metadata{} 29 | ) 30 | 31 | func init() { 32 | log.SetOutputLevel(logger.FatalLevel) 33 | eh.logger = log 34 | m.Properties = map[string]string { 35 | "azureClientID": "fuzz", 36 | } 37 | meta, err := eh.parseMetadata(m) 38 | if err != nil { 39 | panic(err) 40 | } 41 | eh.metadata = meta 42 | } 43 | 44 | 45 | func FuzzAzureEventGridTest(f *testing.F) { 46 | f.Fuzz(func(t *testing.T, authorizationHeader string) { 47 | eh.validateAuthHeader(context.Background(), authorizationHeader) 48 | }) 49 | } 50 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_components_contrib_dubbo_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package dubbo 17 | 18 | import ( 19 | "testing" 20 | dubboImpl "dubbo.apache.org/dubbo-go/v3/protocol/dubbo/impl" 21 | ) 22 | 23 | func FuzzDubboSerialization(f *testing.F) { 24 | f.Fuzz(func(t *testing.T, input []byte) { 25 | p := &dubboImpl.DubboPackage{} 26 | HessianSerializer{}.Unmarshal(input, p) 27 | }) 28 | } 29 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_components_contrib_graphql_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package graphql 17 | 18 | import ( 19 | "regexp" 20 | "strings" 21 | "testing" 22 | ) 23 | 24 | func FuzzGraphqlRETest(f *testing.F) { 25 | f.Fuzz(func(t *testing.T, requestString, requestKey string) { 26 | re, err := regexp.Compile(`(?m)` + requestKey + `\b`) 27 | if err != nil { 28 | return 29 | } 30 | requestString = strings.TrimSpace(requestString) 31 | _ = re.FindAllStringIndex(requestString, 1) 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_components_contrib_metadata_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package metadata 17 | 18 | import ( 19 | "testing" 20 | fuzz "github.com/AdamKorcz/go-fuzz-headers-1" 21 | ) 22 | 23 | type FuzzStruct struct { 24 | Name1 string 25 | Name2 string 26 | Name3 string 27 | Int1 int 28 | Int2 int 29 | Float1 float64 30 | } 31 | 32 | func FuzzDecodeMetadata(f *testing.F) { 33 | f.Fuzz(func(t *testing.T, data []byte) { 34 | ff := fuzz.NewConsumer(data) 35 | m := make(map[string]string) 36 | ff.FuzzMap(&m) 37 | if len(m) == 0 { 38 | return 39 | } 40 | fs := &FuzzStruct{} 41 | DecodeMetadata(m, fs) 42 | }) 43 | } -------------------------------------------------------------------------------- /projects/dapr/fuzz_components_contrib_mqtt3_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package mqtt 17 | 18 | import ( 19 | "regexp" 20 | "testing" 21 | ) 22 | 23 | func FuzzAddTopic(f *testing.F) { 24 | f.Fuzz(func(t *testing.T, origTopicName string) { 25 | m := &mqttPubSub{} 26 | m.topics = make(map[string]mqttPubSubSubscription) 27 | topicName := origTopicName 28 | if found := sharedSubscriptionMatch.FindStringIndex(origTopicName); found != nil && found[0] == 0 { 29 | topicName = topicName[(found[1] - 1):] 30 | } 31 | 32 | regexStr := buildRegexForTopic(topicName) 33 | if regexStr != "" { 34 | _, err := regexp.Compile(regexStr) 35 | if err != nil { 36 | return 37 | } 38 | m.addTopic(origTopicName, nil) 39 | } 40 | 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_components_contrib_pubsub_pulsar_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package pulsar 17 | 18 | import ( 19 | "testing" 20 | 21 | "github.com/dapr/components-contrib/pubsub" 22 | fuzz "github.com/AdamKorcz/go-fuzz-headers-1" 23 | ) 24 | 25 | var ( 26 | protocols = map[int]string { 27 | 0: jsonProtocol, 28 | 1: avroProtocol, 29 | } 30 | ) 31 | 32 | 33 | func FuzzAvroTest(f *testing.F) { 34 | f.Fuzz(func(t *testing.T, data []byte) { 35 | ff := fuzz.NewConsumer(data) 36 | 37 | req := &pubsub.PublishRequest{} 38 | ff.GenerateStruct(req) 39 | 40 | i, err := ff.GetInt() 41 | if err != nil { 42 | return 43 | } 44 | protocol := protocols[i%len(protocols)] 45 | 46 | value, err := ff.GetString() 47 | if err != nil { 48 | return 49 | } 50 | 51 | schema := schemaMetadata{ 52 | protocol: protocol, 53 | value: value, 54 | } 55 | 56 | parsePublishMetadata(req, schema) 57 | }) 58 | } 59 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_components_contrib_state_query_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package query 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzQuery(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, data []byte) { 24 | q := &Query{} 25 | q.UnmarshalJSON(data) 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_components_contrib_state_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package state 17 | 18 | import ( 19 | "testing" 20 | fuzz "github.com/AdamKorcz/go-fuzz-headers-1" 21 | ) 22 | 23 | func FuzzCheckRequestOptions(f *testing.F) { 24 | f.Fuzz(func(t *testing.T, data []byte, callType int) { 25 | ff := fuzz.NewConsumer(data) 26 | switch callType%3 { 27 | case 0: 28 | o := &GetStateOption{} 29 | ff.GenerateStruct(o) 30 | CheckRequestOptions(*o) 31 | case 1: 32 | o := &DeleteStateOption{} 33 | ff.GenerateStruct(o) 34 | CheckRequestOptions(*o) 35 | case 2: 36 | o := &SetStateOption{} 37 | ff.GenerateStruct(o) 38 | CheckRequestOptions(*o) 39 | } 40 | }) 41 | } 42 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_expr_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package expr 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzExprDecodeString(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, code string) { 24 | var e Expr 25 | e.DecodeString(code) 26 | }) 27 | } 28 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_http_server_endpoint_test.go: -------------------------------------------------------------------------------- 1 | package http 2 | 3 | import ( 4 | "testing" 5 | "github.com/dapr/dapr/pkg/config" 6 | fuzz "github.com/AdamKorcz/go-fuzz-headers-1" 7 | ) 8 | 9 | func FuzzIsEndpointAllowed(f *testing.F) { 10 | f.Fuzz(func(t *testing.T, data []byte) { 11 | ff := fuzz.NewConsumer(data) 12 | endpoint := Endpoint{} 13 | ff.GenerateStruct(&endpoint) 14 | if endpoint.Version == "" { 15 | return 16 | } 17 | if endpoint.Route == "" { 18 | return 19 | } 20 | rule := config.APIAccessRule{} 21 | ff.GenerateStruct(&rule) 22 | if rule.Version == "" { 23 | return 24 | } 25 | if rule.Version != endpoint.Version { 26 | return 27 | } 28 | if rule.Name == "" { 29 | return 30 | } 31 | 32 | if len(endpoint.Route) < 2 { 33 | return 34 | } 35 | 36 | if len(rule.Name) < 2 { 37 | return 38 | } 39 | 40 | if endpoint.Route[0] == rule.Name[0] { 41 | return 42 | } 43 | 44 | if endpoint.Route[1] == rule.Name[1] { 45 | return 46 | } 47 | 48 | if endpointMatchesAPIAccessRule(endpoint, rule) == true { 49 | panic("Should not be true") 50 | } 51 | }) 52 | } 53 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_http_server_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package http 17 | 18 | import ( 19 | "regexp" 20 | "testing" 21 | ) 22 | 23 | func FuzzHTTPRegex(f *testing.F) { 24 | f.Fuzz(func(t *testing.T, path string) { 25 | parameterFinder, _ := regexp.Compile("/{.*}") 26 | _ = parameterFinder.MatchString(path) 27 | }) 28 | } 29 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_placement_raft_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package raft 17 | 18 | import ( 19 | "testing" 20 | 21 | fuzz "github.com/AdaLogics/go-fuzz-headers" 22 | "github.com/hashicorp/raft" 23 | 24 | "github.com/dapr/kit/logger" 25 | ) 26 | 27 | func init() { 28 | logging.SetOutputLevel(logger.FatalLevel) 29 | } 30 | 31 | func FuzzFSMPlacementState(f *testing.F) { 32 | f.Fuzz(func(t *testing.T, data []byte) { 33 | ff := fuzz.NewConsumer(data) 34 | rl := &raft.Log{} 35 | err := ff.GenerateStruct(rl) 36 | if err != nil { 37 | return 38 | } 39 | fsm := newFSM() 40 | fsm.Apply(rl) 41 | 42 | _ = fsm.PlacementState() 43 | }) 44 | } 45 | -------------------------------------------------------------------------------- /projects/dapr/fuzz_sidecar_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package sidecar 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzParseEnvString(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, envStr string) { 24 | _, _ = ParseEnvString(envStr) 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /projects/dapr/pkcs7_padding.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2023 The Dapr Authors 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | http://www.apache.org/licenses/LICENSE-2.0 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | */ 13 | 14 | package padding 15 | 16 | /*! 17 | This code is adapted from https://github.com/mergermarket/go-pkcs7/tree/153b18ea13c9b94f698070cadb23701e51a55b3e 18 | Copyright (c) 2017 Richard Zadorozny 19 | License: MIT https://github.com/mergermarket/go-pkcs7/blob/153b18ea13c9b94f698070cadb23701e51a55b3e/LICENSE 20 | */ 21 | 22 | import ( 23 | "bytes" 24 | "errors" 25 | ) 26 | 27 | var ( 28 | ErrInvalidPKCS7BlockSize = errors.New("pkcs7: invalid block size") 29 | ErrInvalidPKCS7Padding = errors.New("pkcs7: incorrect padding") 30 | ) 31 | 32 | // PadPKCS7 adds PKCS#7 padding to a message. 33 | func PadPKCS7(buf []byte, size int) ([]byte, error) { 34 | if size <= 1 || size >= 256 { 35 | return nil, ErrInvalidPKCS7BlockSize 36 | } 37 | bufLen := len(buf) 38 | padLen := size - bufLen%size 39 | padding := bytes.Repeat([]byte{byte(padLen)}, padLen) 40 | var padded bytes.Buffer 41 | padded.Write(buf) 42 | padded.Write(padding) 43 | return padded.Bytes(), nil 44 | } 45 | 46 | // UnpadPKCS7 removes PKCS#7 from a message. 47 | func UnpadPKCS7(buf []byte, size int) ([]byte, error) { 48 | if size <= 1 || size >= 256 { 49 | return nil, ErrInvalidPKCS7BlockSize 50 | } 51 | l := len(buf) 52 | if l == 0 { 53 | return []byte{}, nil 54 | } 55 | if l%size != 0 { 56 | return nil, ErrInvalidPKCS7Padding 57 | } 58 | 59 | padLen := int(buf[l-1]) 60 | if padLen <= 0 || padLen > size { 61 | return nil, ErrInvalidPKCS7Padding 62 | } 63 | padLenB := byte(padLen) 64 | for i := l - padLen; i < l; i++ { 65 | if buf[i] != padLenB { 66 | return nil, ErrInvalidPKCS7Padding 67 | } 68 | } 69 | return buf[:l-padLen], nil 70 | } 71 | -------------------------------------------------------------------------------- /projects/distribution/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore 2 | -------------------------------------------------------------------------------- /projects/distribution/authchallenge_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package challenge 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzParseValueAndParams(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, data []byte) { 24 | _, _ = parseValueAndParams(string(data)) 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /projects/distribution/corpus/parserFuzzer/configYamlV0_1: -------------------------------------------------------------------------------- 1 | version: 0.1 2 | log: 3 | level: info 4 | fields: 5 | environment: test 6 | storage: 7 | s3: 8 | region: us-east-1 9 | bucket: my-bucket 10 | rootdirectory: /registry 11 | encrypt: true 12 | secure: false 13 | accesskey: SAMPLEACCESSKEY 14 | secretkey: SUPERSECRET 15 | host: ~ 16 | port: 42 17 | auth: 18 | silly: 19 | realm: silly 20 | service: silly 21 | notifications: 22 | endpoints: 23 | - name: endpoint-1 24 | url: http://example.com 25 | headers: 26 | Authorization: [Bearer ] 27 | ignoredmediatypes: 28 | - application/octet-stream 29 | ignore: 30 | mediatypes: 31 | - application/octet-stream 32 | actions: 33 | - pull 34 | reporting: 35 | bugsnag: 36 | apikey: BugsnagApiKey 37 | http: 38 | clientcas: 39 | - /path/to/ca.pem 40 | headers: 41 | X-Content-Type-Options: [nosniff] -------------------------------------------------------------------------------- /projects/distribution/corpus/parserFuzzer/inmemoryConfigYamlV0_1: -------------------------------------------------------------------------------- 1 | version: 0.1 2 | log: 3 | level: info 4 | storage: inmemory 5 | auth: 6 | silly: 7 | realm: silly 8 | service: silly 9 | notifications: 10 | endpoints: 11 | - name: endpoint-1 12 | url: http://example.com 13 | headers: 14 | Authorization: [Bearer ] 15 | ignoredmediatypes: 16 | - application/octet-stream 17 | ignore: 18 | mediatypes: 19 | - application/octet-stream 20 | actions: 21 | - pull 22 | http: 23 | headers: 24 | X-Content-Type-Options: [nosniff] -------------------------------------------------------------------------------- /projects/distribution/errcode_fuzzer.go: -------------------------------------------------------------------------------- 1 | package errcode 2 | 3 | import ( 4 | "encoding/json" 5 | fuzz "github.com/AdaLogics/go-fuzz-headers" 6 | "testing" 7 | ) 8 | 9 | func FuzzErrcode(f *testing.F) { 10 | f.Fuzz(func(t *testing.T, data []byte) { 11 | fdp := fuzz.NewConsumer(data) 12 | fuzzErrorCode, err := fdp.GetBool() 13 | if err != nil { 14 | return 15 | } 16 | if fuzzErrorCode { 17 | var ec ErrorCode 18 | if err := json.Unmarshal(data, &ec); err != nil { 19 | return 20 | } 21 | _ = ec.Error() 22 | _ = ec.String() 23 | _ = ec.Message() 24 | _, _ = ec.MarshalText() 25 | 26 | _ = ParseErrorCode(string(data)) 27 | } else { 28 | var er Errors 29 | err = fdp.GenerateStruct(&er) 30 | if err == nil { 31 | d, err := fdp.GetBytes() 32 | if err != nil { 33 | return 34 | } 35 | er.UnmarshalJSON(d) 36 | _, _ = er.MarshalJSON() 37 | } 38 | 39 | } 40 | return 41 | }) 42 | } 43 | -------------------------------------------------------------------------------- /projects/distribution/manifestlist_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package manifestlist 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzUnmarshalJSON(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, data []byte) { 24 | m := new(DeserializedManifestList) 25 | err := m.UnmarshalJSON(b) 26 | if err != nil { 27 | return 0 28 | } 29 | b, err := m.MarshalSON() 30 | if err != nil { 31 | return 0 32 | } 33 | _, _, _ = m.Payload() 34 | _ = m.References() 35 | }) 36 | } 37 | -------------------------------------------------------------------------------- /projects/distribution/native_reference_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package reference 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzParseNormalizedNamedNative(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, data string) { 24 | _, _ = ParseNormalizedNamed(data) 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /projects/distribution/parser_fuzzer.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | package configuration 5 | 6 | import ( 7 | "bytes" 8 | "os" 9 | "testing" 10 | ) 11 | 12 | // ParserFuzzer implements a fuzzer that targets Parser() 13 | // Export before building 14 | // nolint:deadcode 15 | func parserFuzzer(f *testing.F) { 16 | f.Fuzz(func(t *testing.T, rdData []byte, envKey, envValue string) { 17 | os.Setenv(envKey, envValue) 18 | defer os.Unsetenv(envKey) 19 | rd := bytes.NewReader(rdData) 20 | _, _ = Parse(rd) 21 | }) 22 | } 23 | -------------------------------------------------------------------------------- /projects/distribution/reference_fuzzer2.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package reference 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzWithNameAndWithTag(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, name, tag string) { 24 | named, err := WithName(name) 25 | if err != nil { 26 | return 27 | } 28 | _, _ = WithTag(named, tag) 29 | }) 30 | } 31 | 32 | func FuzzAllNormalizeApis(f *testing.F) { 33 | f.Fuzz(func(t *testing.T, ref string) { 34 | _, _ = ParseAnyReference(ref) 35 | n, err := ParseDockerRef(ref) 36 | if err != nil { 37 | return 38 | } 39 | _ = TagNameOnly(n) 40 | }) 41 | } 42 | -------------------------------------------------------------------------------- /projects/distribution/schema2_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package schema2 17 | 18 | import ( 19 | "context" 20 | "testing" 21 | 22 | "github.com/opencontainers/go-digest" 23 | 24 | "github.com/distribution/distribution/v3" 25 | 26 | fuzz "github.com/AdaLogics/go-fuzz-headers" 27 | ) 28 | 29 | func FuzzUnmarshalJSON(f *testing.F) { 30 | f.Fuzz(func(t *testing.T, data []byte) { 31 | m := new(DeserializedManifest) 32 | err := m.UnmarshalJSON(b) 33 | if err != nil { 34 | return 35 | } 36 | b, err := m.MarshalSON() 37 | if err != nil { 38 | return 39 | } 40 | }) 41 | } 42 | 43 | func FuzzNewManifestBuilder(f *testing.F) { 44 | f.Fuzz(func(t *testing.T, data []byte) { 45 | fdp := fuzz.NewConsumer(data) 46 | annotations := make(map[string]string) 47 | err := f.FuzzMap(&annotations) 48 | if err != nil { 49 | return 0 50 | } 51 | 52 | configJSON, err := fdp.GetBytes() 53 | if err != nil { 54 | return 55 | } 56 | 57 | configMediaType, err := fdp.GetString() 58 | if err != nil { 59 | return 60 | } 61 | 62 | bs := &mockBlobService{descriptors: make(map[digest.Digest]distribution.Descriptor)} 63 | builder := NewManifestBuilder(bs, configMediaType, configJSON) 64 | builder.Build(context.Background()) 65 | }) 66 | } 67 | -------------------------------------------------------------------------------- /projects/etcd/filepurge_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package fileutil 17 | 18 | import ( 19 | "os" 20 | "time" 21 | 22 | fuzz "github.com/AdaLogics/go-fuzz-headers" 23 | "go.uber.org/zap" 24 | ) 25 | 26 | func FuzzPurgeFile(data []byte) int { 27 | dir, err := os.MkdirTemp("", "purgefile") 28 | if err != nil { 29 | panic(err) 30 | } 31 | defer os.RemoveAll(dir) 32 | 33 | f := fuzz.NewConsumer(data) 34 | 35 | err = f.CreateFiles(dir) 36 | if err != nil { 37 | return 0 38 | } 39 | 40 | stop, purgec := make(chan struct{}), make(chan string, 10) 41 | 42 | // keep 3 most recent files 43 | _ = purgeFile(zap.NewExample(), dir, "test", 3, time.Millisecond, stop, purgec, nil, false) 44 | return 1 45 | } 46 | -------------------------------------------------------------------------------- /projects/etcd/proxy_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package proxy 17 | 18 | import ( 19 | "net/url" 20 | "os" 21 | "testing" 22 | 23 | "go.etcd.io/etcd/client/pkg/v3/transport" 24 | "go.uber.org/zap" 25 | ) 26 | 27 | func init() { 28 | testing.Init() 29 | } 30 | 31 | var fuzzLogger = zap.NewExample() 32 | 33 | func FuzzProxyServer(data []byte) int { 34 | t := &testing.T{} 35 | scheme := "unix" 36 | srcAddr, dstAddr := newUnixAddr(), newUnixAddr() 37 | defer func() { 38 | os.RemoveAll(srcAddr) 39 | os.RemoveAll(dstAddr) 40 | }() 41 | tlsInfo := transport.TLSInfo{} 42 | ln := listen(t, scheme, dstAddr, transport.TLSInfo{}) 43 | defer ln.Close() 44 | 45 | p := NewServer(ServerConfig{ 46 | Logger: fuzzLogger, 47 | From: url.URL{Scheme: scheme, Host: srcAddr}, 48 | To: url.URL{Scheme: scheme, Host: dstAddr}, 49 | }) 50 | <-p.Ready() 51 | defer p.Close() 52 | 53 | send(t, data, scheme, srcAddr, tlsInfo) 54 | return 1 55 | } 56 | -------------------------------------------------------------------------------- /projects/etcd/raft_api_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package rafthttp 17 | 18 | import ( 19 | "bytes" 20 | "net/http" 21 | "net/http/httptest" 22 | 23 | "go.etcd.io/etcd/api/v3/version" 24 | "go.etcd.io/etcd/client/pkg/v3/types" 25 | "go.etcd.io/raft/v3/raftpb" 26 | "go.uber.org/zap" 27 | 28 | fuzz "github.com/AdaLogics/go-fuzz-headers" 29 | ) 30 | 31 | func FuzzRaftHttpRequests(data []byte) int { 32 | body := bytes.NewReader(data) 33 | req, err := http.NewRequest("POST", "foo", body) 34 | if err != nil { 35 | return 0 36 | } 37 | req.Header.Set("X-Etcd-Cluster-ID", "0") 38 | req.Header.Set("X-Server-Version", version.Version) 39 | rw := httptest.NewRecorder() 40 | r := &fakeRaft{} 41 | h := newPipelineHandler(&Transport{Logger: zap.NewExample()}, r, types.ID(0)) 42 | 43 | // goroutine because the handler panics to disconnect on raft error 44 | donec := make(chan struct{}) 45 | go func() { 46 | defer func() { 47 | recover() 48 | close(donec) 49 | }() 50 | h.ServeHTTP(rw, req) 51 | }() 52 | <-donec 53 | return 1 54 | } 55 | 56 | func FuzzMessageEncodeDecode(data []byte) int { 57 | f := fuzz.NewConsumer(data) 58 | msg := raftpb.Message{} 59 | err := f.GenerateStruct(&msg) 60 | if err != nil { 61 | return 0 62 | } 63 | b := &bytes.Buffer{} 64 | enc := &messageEncoder{w: b} 65 | if err := enc.encode(&msg); err != nil { 66 | return 0 67 | } 68 | dec := &messageDecoder{r: b} 69 | _, _ = dec.decode() 70 | return 1 71 | } 72 | -------------------------------------------------------------------------------- /projects/etcd/snapshot_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package snap 17 | 18 | import ( 19 | "os" 20 | "path/filepath" 21 | 22 | "go.uber.org/zap" 23 | "go.uber.org/zap/zapcore" 24 | 25 | fuzz "github.com/AdaLogics/go-fuzz-headers" 26 | ) 27 | 28 | func silentLogger(options ...zap.Option) *zap.Logger { 29 | encoderCfg := zapcore.EncoderConfig{ 30 | MessageKey: "msg", 31 | LevelKey: "level", 32 | NameKey: "logger", 33 | EncodeLevel: zapcore.LowercaseLevelEncoder, 34 | EncodeTime: zapcore.ISO8601TimeEncoder, 35 | EncodeDuration: zapcore.StringDurationEncoder, 36 | } 37 | core := zapcore.NewCore(zapcore.NewJSONEncoder(encoderCfg), os.Stdout, zap.FatalLevel) 38 | return zap.New(core).WithOptions(options...) 39 | } 40 | 41 | func FuzzSnapLoad(data []byte) int { 42 | f := fuzz.NewConsumer(data) 43 | dir := filepath.Join(os.TempDir(), "snapshot") 44 | err := os.Mkdir(dir, 0700) 45 | if err != nil { 46 | return -1 47 | } 48 | defer os.RemoveAll(dir) 49 | 50 | err = f.CreateFiles(dir) 51 | if err != nil { 52 | return 0 53 | } 54 | 55 | ss := New(silentLogger(), dir) 56 | _, _ = ss.Load() 57 | return 1 58 | } 59 | -------------------------------------------------------------------------------- /projects/helm/dicts/fuzz_create_from.dict: -------------------------------------------------------------------------------- 1 | "values.yaml" 2 | "Chart.yaml" 3 | "LICENSE" 4 | "README.md" 5 | "values.schema.json" 6 | "charts" 7 | "crds" 8 | "templates" 9 | "apiVersion" 10 | "name" 11 | "version" 12 | "kubeVersion" 13 | "description" 14 | "type" 15 | "keywords" 16 | "-" 17 | "home" 18 | ":" 19 | "sources" 20 | "dependencies" 21 | "repository" 22 | "condition" 23 | "tags" 24 | "import-values" 25 | "alias" 26 | "maintainers" 27 | "email" 28 | "url" 29 | "icon" 30 | "appVersion" 31 | "deprecated" 32 | "annotations" 33 | "example" 34 | ".tgz" 35 | "enabled" 36 | "import-values" 37 | "exports" 38 | "data" 39 | "myint" 40 | "mybool" 41 | "mystring" 42 | "." 43 | "{" 44 | "}" 45 | "|" 46 | "section" 47 | ".yaml" 48 | ".tpl" 49 | ".txt" -------------------------------------------------------------------------------- /projects/helm/dicts/fuzz_resolve.dict: -------------------------------------------------------------------------------- 1 | "file://" 2 | "values.yaml" 3 | "Chart.yaml" 4 | "values.schema.json" 5 | "templates" 6 | "charts" 7 | "tests" 8 | ".helmignore" 9 | "ingress.yaml" 10 | "deployment.yaml" 11 | "service.yaml" 12 | "serviceaccount.yaml" 13 | "hpa.yaml" 14 | "NOTES.txt" 15 | "_helpers.tpl" 16 | "test-connection.yaml" -------------------------------------------------------------------------------- /projects/helm/engine_fuzzer.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | // Copyright 2022 ADA Logics Ltd 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | package engine 20 | 21 | import ( 22 | "helm.sh/helm/v3/pkg/chart" 23 | "helm.sh/helm/v3/pkg/chartutil" 24 | 25 | fuzz "github.com/AdaLogics/go-fuzz-headers" 26 | ) 27 | 28 | func FuzzEngineRender(data []byte) int { 29 | f := fuzz.NewConsumer(data) 30 | chrt := &chart.Chart{} 31 | err := f.GenerateStruct(chrt) 32 | if err != nil { 33 | return 0 34 | } 35 | valuesBytes, err := f.GetBytes() 36 | if err != nil { 37 | return 0 38 | } 39 | values, err := chartutil.ReadValues(valuesBytes) 40 | if err != nil { 41 | return 0 42 | } 43 | _, _ = Render(chrt, values) 44 | return 1 45 | } 46 | 47 | func FuzzEngineFiles(data []byte) int { 48 | f := fuzz.NewConsumer(data) 49 | noOfEntries, err := f.GetInt() 50 | if err != nil { 51 | return 0 52 | } 53 | files := make(files, 0) 54 | for i:=0;i.fullname" . }}-test-connection" 5 | labels: 6 | {{- include ".labels" . | nindent 4 }} 7 | annotations: 8 | "helm.sh/hook": test 9 | spec: 10 | containers: 11 | - name: wget 12 | image: busybox 13 | command: ['wget'] 14 | args: ['{{ include ".fullname" . }}:{{ .Values.service.port }}'] 15 | restartPolicy: Never -------------------------------------------------------------------------------- /projects/helm/seeds/fuzz_resolve/seed2: -------------------------------------------------------------------------------- 1 | # Default values for %s. 2 | # This is a YAML-formatted file. 3 | # Declare variables to be passed into your templates. 4 | replicaCount: 1 5 | image: 6 | repository: nginx 7 | pullPolicy: IfNotPresent 8 | # Overrides the image tag whose default is the chart appVersion. 9 | tag: "" 10 | imagePullSecrets: [] 11 | nameOverride: "" 12 | fullnameOverride: "" 13 | serviceAccount: 14 | # Specifies whether a service account should be created 15 | create: true 16 | # Annotations to add to the service account 17 | annotations: {} 18 | # The name of the service account to use. 19 | # If not set and create is true, a name is generated using the fullname template 20 | name: "" 21 | podAnnotations: {} 22 | podSecurityContext: {} 23 | # fsGroup: 2000 24 | securityContext: {} 25 | # capabilities: 26 | # drop: 27 | # - ALL 28 | # readOnlyRootFilesystem: true 29 | # runAsNonRoot: true 30 | # runAsUser: 1000 31 | service: 32 | type: ClusterIP 33 | port: 80 34 | ingress: 35 | enabled: false 36 | className: "" 37 | annotations: {} 38 | # kubernetes.io/ingress.class: nginx 39 | # kubernetes.io/tls-acme: "true" 40 | hosts: 41 | - host: chart-example.local 42 | paths: 43 | - path: / 44 | pathType: ImplementationSpecific 45 | tls: [] 46 | # - secretName: chart-example-tls 47 | # hosts: 48 | # - chart-example.local 49 | resources: {} 50 | # We usually recommend not to specify default resources and to leave this as a conscious 51 | # choice for the user. This also increases chances charts run on environments with little 52 | # resources, such as Minikube. If you do want to specify resources, uncomment the following 53 | # lines, adjust them as necessary, and remove the curly braces after 'resources:'. 54 | # limits: 55 | # cpu: 100m 56 | # memory: 128Mi 57 | # requests: 58 | # cpu: 100m 59 | # memory: 128Mi 60 | autoscaling: 61 | enabled: false 62 | minReplicas: 1 63 | maxReplicas: 100 64 | targetCPUUtilizationPercentage: 80 65 | # targetMemoryUtilizationPercentage: 80 66 | nodeSelector: {} 67 | tolerations: [] 68 | affinity: {} -------------------------------------------------------------------------------- /projects/helm/seeds/fuzz_resolve/seed4: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: {{ include ".fullname" . }} 5 | labels: 6 | {{- include ".labels" . | nindent 4 }} 7 | spec: 8 | {{- if not .Values.autoscaling.enabled }} 9 | replicas: {{ .Values.replicaCount }} 10 | {{- end }} 11 | selector: 12 | matchLabels: 13 | {{- include ".selectorLabels" . | nindent 6 }} 14 | template: 15 | metadata: 16 | {{- with .Values.podAnnotations }} 17 | annotations: 18 | {{- toYaml . | nindent 8 }} 19 | {{- end }} 20 | labels: 21 | {{- include ".selectorLabels" . | nindent 8 }} 22 | spec: 23 | {{- with .Values.imagePullSecrets }} 24 | imagePullSecrets: 25 | {{- toYaml . | nindent 8 }} 26 | {{- end }} 27 | serviceAccountName: {{ include ".serviceAccountName" . }} 28 | securityContext: 29 | {{- toYaml .Values.podSecurityContext | nindent 8 }} 30 | containers: 31 | - name: {{ .Chart.Name }} 32 | securityContext: 33 | {{- toYaml .Values.securityContext | nindent 12 }} 34 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" 35 | imagePullPolicy: {{ .Values.image.pullPolicy }} 36 | ports: 37 | - name: http 38 | containerPort: 80 39 | protocol: TCP 40 | livenessProbe: 41 | httpGet: 42 | path: / 43 | port: http 44 | readinessProbe: 45 | httpGet: 46 | path: / 47 | port: http 48 | resources: 49 | {{- toYaml .Values.resources | nindent 12 }} 50 | {{- with .Values.nodeSelector }} 51 | nodeSelector: 52 | {{- toYaml . | nindent 8 }} 53 | {{- end }} 54 | {{- with .Values.affinity }} 55 | affinity: 56 | {{- toYaml . | nindent 8 }} 57 | {{- end }} 58 | {{- with .Values.tolerations }} 59 | tolerations: 60 | {{- toYaml . | nindent 8 }} 61 | {{- end }} -------------------------------------------------------------------------------- /projects/helm/seeds/fuzz_resolve/seed5: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ include ".fullname" . }} 5 | labels: 6 | {{- include ".labels" . | nindent 4 }} 7 | spec: 8 | type: {{ .Values.service.type }} 9 | ports: 10 | - port: {{ .Values.service.port }} 11 | targetPort: http 12 | protocol: TCP 13 | name: http 14 | selector: 15 | {{- include ".selectorLabels" . | nindent 4 }} -------------------------------------------------------------------------------- /projects/helm/seeds/fuzz_resolve/seed6: -------------------------------------------------------------------------------- 1 | {{- if .Values.serviceAccount.create -}} 2 | apiVersion: v1 3 | kind: ServiceAccount 4 | metadata: 5 | name: {{ include ".serviceAccountName" . }} 6 | labels: 7 | {{- include ".labels" . | nindent 4 }} 8 | {{- with .Values.serviceAccount.annotations }} 9 | annotations: 10 | {{- toYaml . | nindent 4 }} 11 | {{- end }} 12 | {{- end }} -------------------------------------------------------------------------------- /projects/helm/seeds/fuzz_resolve/seed7: -------------------------------------------------------------------------------- 1 | {{- if .Values.autoscaling.enabled }} 2 | apiVersion: autoscaling/v2beta1 3 | kind: HorizontalPodAutoscaler 4 | metadata: 5 | name: {{ include ".fullname" . }} 6 | labels: 7 | {{- include ".labels" . | nindent 4 }} 8 | spec: 9 | scaleTargetRef: 10 | apiVersion: apps/v1 11 | kind: Deployment 12 | name: {{ include ".fullname" . }} 13 | minReplicas: {{ .Values.autoscaling.minReplicas }} 14 | maxReplicas: {{ .Values.autoscaling.maxReplicas }} 15 | metrics: 16 | {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} 17 | - type: Resource 18 | resource: 19 | name: cpu 20 | targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} 21 | {{- end }} 22 | {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} 23 | - type: Resource 24 | resource: 25 | name: memory 26 | targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} 27 | {{- end }} 28 | {{- end }} -------------------------------------------------------------------------------- /projects/helm/seeds/fuzz_resolve/seed8: -------------------------------------------------------------------------------- 1 | 1. Get the application URL by running these commands: 2 | {{- if .Values.ingress.enabled }} 3 | {{- range $host := .Values.ingress.hosts }} 4 | {{- range .paths }} 5 | http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} 6 | {{- end }} 7 | {{- end }} 8 | {{- else if contains "NodePort" .Values.service.type }} 9 | export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include ".fullname" . }}) 10 | export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") 11 | echo http://$NODE_IP:$NODE_PORT 12 | {{- else if contains "LoadBalancer" .Values.service.type }} 13 | NOTE: It may take a few minutes for the LoadBalancer IP to be available. 14 | You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include ".fullname" . }}' 15 | export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include ".fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") 16 | echo http://$SERVICE_IP:{{ .Values.service.port }} 17 | {{- else if contains "ClusterIP" .Values.service.type }} 18 | export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include ".name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") 19 | export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") 20 | echo "Visit http://127.0.0.1:8080 to use your application" 21 | kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT 22 | {{- end }} -------------------------------------------------------------------------------- /projects/helm/seeds/fuzz_resolve/seed9: -------------------------------------------------------------------------------- 1 | {{/* 2 | Expand the name of the chart. 3 | */}} 4 | {{- define ".name" -}} 5 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} 6 | {{- end }} 7 | {{/* 8 | Create a default fully qualified app name. 9 | We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). 10 | If release name contains chart name it will be used as a full name. 11 | */}} 12 | {{- define ".fullname" -}} 13 | {{- if .Values.fullnameOverride }} 14 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} 15 | {{- else }} 16 | {{- $name := default .Chart.Name .Values.nameOverride }} 17 | {{- if contains $name .Release.Name }} 18 | {{- .Release.Name | trunc 63 | trimSuffix "-" }} 19 | {{- else }} 20 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} 21 | {{- end }} 22 | {{- end }} 23 | {{- end }} 24 | {{/* 25 | Create chart name and version as used by the chart label. 26 | */}} 27 | {{- define ".chart" -}} 28 | {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} 29 | {{- end }} 30 | {{/* 31 | Common labels 32 | */}} 33 | {{- define ".labels" -}} 34 | helm.sh/chart: {{ include ".chart" . }} 35 | {{ include ".selectorLabels" . }} 36 | {{- if .Chart.AppVersion }} 37 | app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} 38 | {{- end }} 39 | app.kubernetes.io/managed-by: {{ .Release.Service }} 40 | {{- end }} 41 | {{/* 42 | Selector labels 43 | */}} 44 | {{- define ".selectorLabels" -}} 45 | app.kubernetes.io/name: {{ include ".name" . }} 46 | app.kubernetes.io/instance: {{ .Release.Name }} 47 | {{- end }} 48 | {{/* 49 | Create the name of the service account to use 50 | */}} 51 | {{- define ".serviceAccountName" -}} 52 | {{- if .Values.serviceAccount.create }} 53 | {{- default (include ".fullname" .) .Values.serviceAccount.name }} 54 | {{- else }} 55 | {{- default "default" .Values.serviceAccount.name }} 56 | {{- end }} 57 | {{- end }} -------------------------------------------------------------------------------- /projects/keycloak/JoseParserFuzzer.java: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | /////////////////////////////////////////////////////////////////////////// 16 | import com.code_intelligence.jazzer.api.FuzzedDataProvider; 17 | import org.keycloak.jose.JOSEParser; 18 | 19 | /** 20 | * This fuzzer targets the parse method of JOSEParser. It calls the JOSEParser.parse method with 21 | * random string to fuzz its parsing ability. 22 | */ 23 | public class JoseParserFuzzer { 24 | public static void fuzzerTestOneInput(FuzzedDataProvider data) { 25 | try { 26 | // Call the JOSEParser.parse method with random 27 | // string generated from the FuzzedDataProvider 28 | JOSEParser.parse(data.consumeRemainingAsString()); 29 | } catch (RuntimeException e) { 30 | // Known exception 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /projects/keycloak/TokenVerifierFuzzer.java: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | /////////////////////////////////////////////////////////////////////////// 16 | import com.code_intelligence.jazzer.api.FuzzedDataProvider; 17 | import org.keycloak.TokenVerifier; 18 | import org.keycloak.common.VerificationException; 19 | import org.keycloak.representations.JsonWebToken; 20 | 21 | public class TokenVerifierFuzzer { 22 | public static void fuzzerTestOneInput(FuzzedDataProvider data) { 23 | try { 24 | TokenVerifier verifier = TokenVerifier.create(data.consumeRemainingAsString(), JsonWebToken.class); 25 | if ((verifier.getHeader() == null) || (verifier.getHeader().getAlgorithm() == null)) { 26 | // Malformed JsonWebToken, skipping to next iteration. 27 | return; 28 | } 29 | verifier.verify(); 30 | } catch (VerificationException e) { 31 | // Known exception 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /projects/keycloak/seeds/JwkParserFuzzer_seed_1: -------------------------------------------------------------------------------- 1 | {"jwk": 2 | [ 3 | {"alg":"EC", 4 | "crv":"P-256", 5 | "x":"MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4", 6 | "y":"4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM", 7 | "use":"enc", 8 | "kid":"1"}, 9 | 10 | {"alg":"RSA", 11 | "mod": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx 12 | 4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMs 13 | tn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2 14 | QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbI 15 | SD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqb 16 | w0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw", 17 | "exp":"AQAB", 18 | "kid":"2011-04-29"} 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /projects/keycloak/seeds/SamlParserFuzzer_seed_1: -------------------------------------------------------------------------------- 1 | 2 | http://sp.example.com/demo1/metadata.php 3 | 4 | 5 | urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport 6 | 7 | 8 | -------------------------------------------------------------------------------- /projects/keycloak/seeds/SamlParserFuzzer_seed_2: -------------------------------------------------------------------------------- 1 | 7 | 10 | 13 | 14 | 16 | user@idp.example.org 17 | 18 | 19 | 20 | urn:oasis:names:tc:SAML:1.0:cm:bearer 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /projects/keycloak/seeds/SamlParserFuzzer_seed_3: -------------------------------------------------------------------------------- 1 | 6 | http://sp.example.com/demo1/metadata.php 7 | 8 | 9 | urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport 10 | 11 | 12 | -------------------------------------------------------------------------------- /projects/keycloak/seeds/SamlParserFuzzer_seed_4: -------------------------------------------------------------------------------- 1 | 6 | ... 8 | 9 | 10 | 11 | 17 | 20 | 23 | 24 | 26 | user@idp.example.org 27 | 28 | 29 | 30 | urn:oasis:names:tc:SAML:1.0:cm:bearer 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /projects/keycloak/seeds/json.dict: -------------------------------------------------------------------------------- 1 | "0" 2 | "7" 3 | "," 4 | ":" 5 | "2.1e24" 6 | 7 | "true" 8 | "false" 9 | "null" 10 | 11 | "\"\"" 12 | "\"\":" 13 | 14 | "{}" 15 | ",{}" 16 | ":{}" 17 | "{\"\":0}" 18 | "{{}}" 19 | 20 | "[]" 21 | ",[]" 22 | ":[]" 23 | "[0]" 24 | "[[]]" 25 | 26 | "''" 27 | "\\" 28 | "\\b" 29 | "\\f" 30 | "\\n" 31 | "\\r" 32 | "\\t" 33 | "\\u0000" 34 | "\\x00" 35 | "\\0" 36 | "\\uD800\\uDC00" 37 | "\\uDBFF\\uDFFF" 38 | 39 | "\"\":0" 40 | "//" 41 | "/**/" 42 | 43 | 44 | # Things like geojson, json-ld, ... 45 | "$ref" 46 | "type" 47 | "coordinates" 48 | "@context" 49 | "@id" 50 | "@type" 51 | 52 | # Strings with truncated special values 53 | "{\"foo\":fa" 54 | "{\"foo\":t" 55 | "{\"foo\":nul" 56 | 57 | "{" 58 | "}" 59 | "\"qty\": 1, \"qty\": -1" 60 | "\"qty\": 1, \"qty\\ud800\": -1" 61 | "\"qty\": 1, \"qt\\y\": -1" 62 | "/*" 63 | "*/" 64 | "\"" 65 | "1.7976931348623157e+308" 66 | "5e-324" 67 | "9007199254740991" 68 | "-9007199254740991" 69 | 70 | "}=" 71 | 72 | ",," 73 | "{\"\":" 74 | -------------------------------------------------------------------------------- /projects/keycloak/seeds/json.seed: -------------------------------------------------------------------------------- 1 | { 2 | "test": "one" 3 | } 4 | -------------------------------------------------------------------------------- /projects/knative/fuzz_configmaps.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package configmaps 17 | 18 | import ( 19 | "context" 20 | fuzz "github.com/AdaLogics/go-fuzz-headers" 21 | "testing" 22 | stdTesting "testing" 23 | admissionv1 "k8s.io/api/admission/v1" 24 | ) 25 | 26 | func FuzzAdmit(f *testing.F) { 27 | f.Fuzz(func(t *testing.T, data []byte) { 28 | req := &admissionv1.AdmissionRequest{} 29 | ff := fuzz.NewConsumer(data) 30 | ff.GenerateStruct(req) 31 | 32 | stdT := &stdTesting.T{} 33 | _, ac := newNonRunningTestConfigValidationController(stdT) 34 | ac.Admit(context.Background(), req) 35 | }) 36 | } 37 | -------------------------------------------------------------------------------- /projects/knative/fuzz_domains.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package domains 17 | 18 | import ( 19 | "context" 20 | "knative.dev/serving/pkg/apis/serving" 21 | "knative.dev/serving/pkg/reconciler/route/config" 22 | "testing" 23 | fuzz "github.com/AdaLogics/go-fuzz-headers" 24 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 25 | netapi "knative.dev/networking/pkg/apis/networking" 26 | ) 27 | 28 | func FuzzDomainNameFromTemplate(f *testing.F) { 29 | f.Fuzz(func(t *testing.T, template, name string, configData, objectMetaData []byte) { 30 | cfg := &config.Config{} 31 | ff := fuzz.NewConsumer(configData) 32 | ff.GenerateStruct(cfg) 33 | if cfg.Network == nil { 34 | t.Skip() 35 | } 36 | if cfg.Network.DomainTemplate == "" { 37 | t.Skip() 38 | } 39 | meta := metav1.ObjectMeta{} 40 | ff.GenerateStruct(&meta) 41 | if meta.Labels == nil { 42 | t.Skip() 43 | } 44 | ctx := context.Background() 45 | ctx = config.ToContext(ctx, cfg) 46 | 47 | meta.Labels[netapi.VisibilityLabelKey] = serving.VisibilityClusterLocal 48 | 49 | _, _ = DomainNameFromTemplate(ctx, meta, name) 50 | }) 51 | } 52 | -------------------------------------------------------------------------------- /projects/knative/fuzz_eventing_filter.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package filter 17 | 18 | import ( 19 | "context" 20 | fuzz "github.com/AdaLogics/go-fuzz-headers" 21 | cloudevents "github.com/cloudevents/sdk-go/v2" 22 | eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1" 23 | "testing" 24 | ) 25 | 26 | func FuzzFilters(f *testing.F) { 27 | f.Fuzz(func(t *testing.T, data []byte, apiCall int) { 28 | ff := fuzz.NewConsumer(data) 29 | event := &cloudevents.Event{} 30 | ff.GenerateStruct(event) 31 | ctx := context.Background() 32 | switch apiCall % 2 { 33 | case 0: 34 | trigger := &eventingv1.Trigger{} 35 | ff.GenerateStruct(trigger) 36 | _ = applySubscriptionsAPIFilters(ctx, trigger, *event) 37 | case 1: 38 | filter := &eventingv1.TriggerFilter{} 39 | ff.GenerateStruct(filter) 40 | _ = applyAttributesFilter(ctx, filter, *event) 41 | } 42 | }) 43 | } 44 | -------------------------------------------------------------------------------- /projects/knative/fuzz_knative_duck_v1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package v1 17 | 18 | import ( 19 | "github.com/AdamKorcz/kubefuzzing/pkg/roundtrip" 20 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 21 | "knative.dev/pkg/apis" 22 | "testing" 23 | 24 | fuzz "github.com/AdaLogics/go-fuzz-headers" 25 | ) 26 | 27 | func init() { 28 | utilruntime.Must(AddToScheme(roundtrip.Scheme)) 29 | roundtrip.AddFuncs(roundtrip.GenericFuzzerFuncs()) 30 | roundtrip.AddFuncs(roundtrip.V1FuzzerFuncs()) 31 | roundtrip.AddFuncs(roundtrip.V1beta1FuzzerFuncs()) 32 | roundtrip.AddFuncs(roundtrip.FuzzerFuncs()) 33 | roundtrip.AddFuncs(FuzzerFuncs) 34 | addKnownTypes(roundtrip.Scheme) 35 | } 36 | 37 | var testConditions = apis.Conditions{{Type: apis.ConditionReady}, {Type: apis.ConditionSucceeded}} 38 | 39 | func FuzzDuckV1RoundTripTypesToJSONExperimental(f *testing.F) { 40 | f.Fuzz(func(t *testing.T, data []byte, typeToTest int) { 41 | roundtrip.ExternalTypesViaJSON(data, typeToTest) 42 | }) 43 | } 44 | 45 | var FuzzerFuncs = []interface{}{ 46 | func(status *Status, c fuzz.Continue) error { 47 | _ = c.F.GenerateWithCustom(status) // fuzz the source 48 | // Clear the random fuzzed condition 49 | status.SetConditions(testConditions) 50 | err := roundtrip.FuzzConditions(status, c) 51 | return err 52 | }, 53 | } 54 | -------------------------------------------------------------------------------- /projects/knative/fuzz_knative_duck_v1beta1.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package v1beta1 17 | 18 | import ( 19 | "github.com/AdamKorcz/kubefuzzing/pkg/roundtrip" 20 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 21 | "knative.dev/pkg/apis" 22 | "testing" 23 | 24 | fuzz "github.com/AdaLogics/go-fuzz-headers" 25 | ) 26 | 27 | func init() { 28 | utilruntime.Must(AddToScheme(roundtrip.Scheme)) 29 | roundtrip.AddFuncs(roundtrip.GenericFuzzerFuncs()) 30 | roundtrip.AddFuncs(roundtrip.V1FuzzerFuncs()) 31 | roundtrip.AddFuncs(roundtrip.V1beta1FuzzerFuncs()) 32 | roundtrip.AddFuncs(roundtrip.FuzzerFuncs()) 33 | roundtrip.AddFuncs(FuzzerFuncs) 34 | addKnownTypes(roundtrip.Scheme) 35 | } 36 | 37 | var testConditions = apis.Conditions{{Type: apis.ConditionReady}, {Type: apis.ConditionSucceeded}} 38 | 39 | func FuzzDuckV1beta1RoundTripTypesToJSONExperimental(f *testing.F) { 40 | f.Fuzz(func(t *testing.T, data []byte, typeToTest int) { 41 | roundtrip.ExternalTypesViaJSON(data, typeToTest) 42 | }) 43 | } 44 | 45 | var FuzzerFuncs = []interface{}{ 46 | func(status *Status, c fuzz.Continue) error { 47 | _ = c.F.GenerateWithCustom(status) // fuzz the source 48 | status.SetConditions(testConditions) 49 | err := roundtrip.FuzzConditions(status, c) 50 | return err 51 | }, 52 | } 53 | -------------------------------------------------------------------------------- /projects/knative/fuzz_kncloudevents.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package kncloudevents 17 | 18 | import ( 19 | "bytes" 20 | "github.com/hashicorp/go-retryablehttp" 21 | "net/http" 22 | "testing" 23 | ) 24 | 25 | func FuzzRetryablehttpFromRequest(f *testing.F) { 26 | f.Fuzz(func(t *testing.T, httpBody []byte) { 27 | req, err := http.NewRequest("GET", "", bytes.NewReader(httpBody)) 28 | if err != nil { 29 | t.Skip() 30 | } 31 | _, _ = retryablehttp.FromRequest(req) 32 | }) 33 | } 34 | -------------------------------------------------------------------------------- /projects/knative/fuzz_messaging_v1_experimental.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package v1 17 | 18 | import ( 19 | "testing" 20 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 21 | "github.com/AdamKorcz/kubefuzzing/pkg/roundtrip" 22 | ) 23 | 24 | 25 | 26 | func init() { 27 | utilruntime.Must(AddToScheme(roundtrip.Scheme)) 28 | roundtrip.AddFuncs(fuzzerFuncsGfh()) 29 | roundtrip.AddFuncs(roundtrip.GenericFuzzerFuncs()) 30 | roundtrip.AddFuncs(roundtrip.V1FuzzerFuncs()) 31 | roundtrip.AddFuncs(roundtrip.V1beta1FuzzerFuncs()) 32 | roundtrip.AddFuncs(roundtrip.FuzzerFuncs()) 33 | addKnownTypes(roundtrip.Scheme) 34 | } 35 | 36 | func FuzzMessagingRoundTripTypesToJSONExperimental(f *testing.F) { 37 | f.Fuzz(func(t *testing.T, data []byte, typeToTest int) { 38 | roundtrip.ExternalTypesViaJSON(data, typeToTest) 39 | }) 40 | } 41 | -------------------------------------------------------------------------------- /projects/knative/fuzz_pkg_kmeta.go: -------------------------------------------------------------------------------- 1 | package kmeta 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func FuzzChildName(f *testing.F) { 8 | f.Fuzz(func(t *testing.T, parent, suffix string) { 9 | _ = ChildName(parent, suffix) 10 | }) 11 | } 12 | -------------------------------------------------------------------------------- /projects/knative/fuzz_pkg_metrics.go: -------------------------------------------------------------------------------- 1 | package metrics 2 | 3 | import ( 4 | fuzz "github.com/AdaLogics/go-fuzz-headers" 5 | corev1 "k8s.io/api/core/v1" 6 | "testing" 7 | ) 8 | 9 | func FuzzNewObservabilityConfigFromConfigMap(f *testing.F) { 10 | f.Fuzz(func(t *testing.T, configMapData []byte) { 11 | ff := fuzz.NewConsumer(configMapData) 12 | cm := &corev1.ConfigMap{} 13 | ff.GenerateStruct(cm) 14 | _, _ = NewObservabilityConfigFromConfigMap(cm) 15 | }) 16 | } 17 | -------------------------------------------------------------------------------- /projects/knative/fuzz_removewithavailabilitynodepriority_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package removewithavailabilitynodepriority 17 | 18 | import ( 19 | "context" 20 | "k8s.io/apimachinery/pkg/types" 21 | state "knative.dev/eventing/pkg/scheduler/state" 22 | "testing" 23 | 24 | fuzz "github.com/AdaLogics/go-fuzz-headers" 25 | ) 26 | 27 | func FuzzRemoveWithAvailabilityNodePriorityScore(f *testing.F) { 28 | f.Fuzz(func(t *testing.T, args string, data []byte) { 29 | ff := fuzz.NewConsumer(data) 30 | args, err := ff.GetString() 31 | if err != nil { 32 | return 33 | } 34 | states := &state.State{} 35 | ff.GenerateStruct(states) 36 | 37 | key := &types.NamespacedName{} 38 | ff.GenerateStruct(key) 39 | 40 | podID, err := ff.GetInt() 41 | if err != nil { 42 | return 43 | } 44 | 45 | feasiblePods := make([]int32, 0) 46 | noOfFP, err := ff.GetInt() 47 | if err != nil { 48 | return 49 | } 50 | for i := 0; i < noOfFP%20; i++ { 51 | newPod, err := ff.GetInt() 52 | if err != nil { 53 | return 54 | } 55 | feasiblePods = append(feasiblePods, int32(newPod)) 56 | } 57 | 58 | pl := &RemoveWithAvailabilityNodePriority{} 59 | pl.Score(context.Background(), args, states, feasiblePods, *key, int32(podID)) 60 | }) 61 | } 62 | -------------------------------------------------------------------------------- /projects/knative/fuzz_serving_route_reconciler.go: -------------------------------------------------------------------------------- 1 | package route 2 | 3 | import ( 4 | "testing" 5 | nativeTesting "testing" 6 | 7 | v1 "knative.dev/serving/pkg/apis/serving/v1" 8 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 9 | 10 | fakeservingclient "knative.dev/serving/pkg/client/injection/client/fake" 11 | fakerevisioninformer "knative.dev/serving/pkg/client/injection/informers/serving/v1/revision/fake" 12 | fakerouteinformer "knative.dev/serving/pkg/client/injection/informers/serving/v1/route/fake" 13 | . "knative.dev/serving/pkg/testing/v1" 14 | 15 | fuzz "github.com/AdaLogics/go-fuzz-headers" 16 | "k8s.io/client-go/tools/cache" 17 | ) 18 | 19 | func FuzzRouteReconciler(f *testing.F) { 20 | f.Fuzz(func(t *testing.T, data []byte) { 21 | ff := fuzz.NewConsumer(data) 22 | tt := v1.TrafficTarget{} 23 | ff.GenerateStruct(&tt) 24 | l := make(map[string]string) 25 | ff.FuzzMap(&l) 26 | 27 | testRouteName, err := ff.GetString() 28 | if err != nil { 29 | t.Skip() 30 | } 31 | 32 | newT := &nativeTesting.T{} 33 | ctx, _, ctl, _, cf := newTestSetup(newT) 34 | defer cf() 35 | 36 | rev := Revision(testNamespace, "test-rev", MarkRevisionReady, 37 | MarkInactive("NoTraffic", "no message")) 38 | 39 | fakeservingclient.Get(ctx).ServingV1().Revisions(testNamespace).Create(ctx, rev, metav1.CreateOptions{}) 40 | fakerevisioninformer.Get(ctx).Informer().GetIndexer().Add(rev) 41 | 42 | route := Route(testNamespace, testRouteName, WithSpecTraffic(tt), WithRouteLabel(l)) 43 | 44 | fakeservingclient.Get(ctx).ServingV1().Routes(testNamespace).Create(ctx, route, metav1.CreateOptions{}) 45 | 46 | fakerouteinformer.Get(ctx).Informer().GetIndexer().Add(route) 47 | 48 | key, err := cache.MetaNamespaceKeyFunc(route) 49 | if err != nil { 50 | t.Skip() 51 | } 52 | ctl.Reconciler.Reconcile(ctx, key) 53 | }) 54 | } 55 | -------------------------------------------------------------------------------- /projects/knative/fuzz_trigger_validation_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package v1 17 | 18 | import ( 19 | "context" 20 | "testing" 21 | ) 22 | 23 | func FuzzValidateCESQLExpression(f *testing.F) { 24 | f.Fuzz(func(t *testing.T, expr string) { 25 | ValidateCESQLExpression(context.Background(), expr) 26 | }) 27 | } -------------------------------------------------------------------------------- /projects/knative/fuzzer_funcs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package v1 17 | 18 | import ( 19 | "knative.dev/eventing/pkg/apis/messaging" 20 | 21 | gfh "github.com/AdaLogics/go-fuzz-headers" 22 | ) 23 | 24 | func fuzzerFuncsGfh() []interface{} { 25 | return []interface{}{ 26 | func(ch *Channel, c gfh.Continue) error { 27 | c.F.GenerateWithCustom(ch) 28 | if ch != nil { 29 | if ch.Annotations == nil { 30 | ch.Annotations = make(map[string]string) 31 | } 32 | ch.Annotations[messaging.SubscribableDuckVersionAnnotation] = "v1" 33 | } 34 | ch.Status.SetConditions(nil) 35 | 36 | ch.Status.InitializeConditions() 37 | return nil 38 | }, 39 | func(imc *InMemoryChannel, c gfh.Continue) error { 40 | c.F.GenerateWithCustom(imc) 41 | if imc != nil { 42 | if imc.Annotations == nil { 43 | imc.Annotations = make(map[string]string) 44 | } 45 | imc.Annotations[messaging.SubscribableDuckVersionAnnotation] = "v1" 46 | } 47 | imc.Status.SetConditions(nil) 48 | 49 | imc.Status.InitializeConditions() 50 | return nil 51 | }, 52 | func(s *SubscriptionStatus, c gfh.Continue) error { 53 | c.F.GenerateWithCustom(s) 54 | 55 | s.Status.SetConditions(nil) 56 | 57 | s.InitializeConditions() 58 | return nil 59 | }, 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /projects/knative/json_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package json 17 | 18 | func FuzzJsonDecode(data []byte) int { 19 | Decode(data, &fixture{}, true) 20 | return 1 21 | } 22 | -------------------------------------------------------------------------------- /projects/kubeedge/cloudhub_messagehandler_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package common 17 | 18 | func FuzzVolumeRegExp(data []byte) int { 19 | VolumeRegExp.MatchString(string(data)) 20 | return 1 21 | } 22 | -------------------------------------------------------------------------------- /projects/kubeedge/csidriver_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package csidriver 17 | 18 | // This fuzzer mimicks the usage of extractMessage() found here: 19 | // https://github.com/kubeedge/kubeedge/blob/master/cloud/pkg/csidriver/utils.go. 20 | func FuzzextractMessage(data []byte) int { 21 | result, err := extractMessage(string(data)) 22 | if err == nil { 23 | _ = result.GetContent().(string) 24 | _ = result.GetOperation() 25 | } 26 | return 1 27 | } -------------------------------------------------------------------------------- /projects/kubeedge/dictionaries/fuzz_ExtractMessage.dict: -------------------------------------------------------------------------------- 1 | "{" 2 | "}" 3 | "[" 4 | "]" 5 | ":" 6 | "," 7 | "null" -------------------------------------------------------------------------------- /projects/kubeedge/dictionaries/fuzz_extract_message.dict: -------------------------------------------------------------------------------- 1 | "{" 2 | "}" 3 | "[" 4 | "]" 5 | ":" 6 | "," 7 | "null" -------------------------------------------------------------------------------- /projects/kubeedge/dictionaries/fuzz_rule_contains.dict: -------------------------------------------------------------------------------- 1 | "/" 2 | "{" 3 | "}" -------------------------------------------------------------------------------- /projects/kubeedge/metaserver_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package metaserver 17 | 18 | func FuzzParseKey(data []byte) int { 19 | _, _, _ = ParseKey(string(data)) 20 | return 1 21 | } -------------------------------------------------------------------------------- /projects/kubeedge/router_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package utils 17 | 18 | import ( 19 | fuzz "github.com/AdaLogics/go-fuzz-headers" 20 | ) 21 | 22 | func FuzzRuleContains(data []byte) int { 23 | f := fuzz.NewConsumer(data) 24 | path1, err := f.GetString() 25 | if err != nil { 26 | return 0 27 | } 28 | path2, err := f.GetString() 29 | if err != nil { 30 | return 0 31 | } 32 | RuleContains(path1, path2) 33 | return 1 34 | } 35 | -------------------------------------------------------------------------------- /projects/kubeedge/stream_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package stream 17 | 18 | import "bytes" 19 | 20 | func FuzzReadMessageFromTunnel(data []byte) int { 21 | _, _ = ReadMessageFromTunnel(bytes.NewReader(data)) 22 | return 1 23 | } -------------------------------------------------------------------------------- /projects/kubeedge/udsserver_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package udsserver 17 | 18 | // Tests ExtractMessage found here: 19 | // https://github.com/kubeedge/kubeedge/blob/master/cloud/pkg/cloudhub/servers/udsserver/server.go#L52 20 | func FuzzExtractMessage(data []byte) int { 21 | msg, err := ExtractMessage(string(data)) 22 | if err != nil { 23 | _ = feedbackError(err, msg) 24 | } 25 | return 1 26 | } -------------------------------------------------------------------------------- /projects/kubernetes/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore 2 | -------------------------------------------------------------------------------- /projects/kubernetes/README.md: -------------------------------------------------------------------------------- 1 | # Kubernetes fuzzers 2 | 3 | ## api_marshaling_fuzzer 4 | The api_marshaling_fuzzer is created automatically by `autogenerate.py`. The reason that this particular fuzzer is created by a script and not explicitly available is that it is more than 35k lines long. Maintaining such a large fuzzer becomes tedious, when new APIs in Kubernetes get introduced or old ones removed. 5 | ### `autogenerate.py` usage 6 | ```bash 7 | cd kubernetes 8 | grep -r ") Marshal()" . > /tmp/grep_result.txt 9 | python3 autogenerate.py --input_file /tmp/grep_result.txt 10 | ``` 11 | The fuzzer is now available and can be built. 12 | -------------------------------------------------------------------------------- /projects/kubernetes/celcompile_fuzzer.go: -------------------------------------------------------------------------------- 1 | package fuzzing 2 | 3 | import ( 4 | "fmt" 5 | 6 | admissioncel "k8s.io/apiserver/pkg/admission/plugin/cel" 7 | 8 | celgo "github.com/google/cel-go/cel" 9 | 10 | "k8s.io/apimachinery/pkg/util/version" 11 | "k8s.io/apiserver/pkg/cel/environment" 12 | "k8s.io/apiserver/pkg/cel/library" 13 | 14 | fuzz "github.com/AdaLogics/go-fuzz-headers" 15 | ) 16 | 17 | type fakeValidationCondition struct { 18 | Expression string 19 | } 20 | 21 | func (v *fakeValidationCondition) GetExpression() string { 22 | return v.Expression 23 | } 24 | 25 | func (v *fakeValidationCondition) ReturnTypes() []*celgo.Type { 26 | return []*celgo.Type{celgo.BoolType} 27 | } 28 | 29 | func FuzzCelCompile(data []byte) int { 30 | f := fuzz.NewConsumer(data) 31 | expr, err := f.GetString() 32 | if err != nil { 33 | //fmt.Println(err) 34 | return 0 35 | } 36 | 37 | // Include the test library, which includes the test() function in the storage environment during test 38 | base := environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion(), true) 39 | extended, err := base.Extend(environment.VersionedOptions{ 40 | IntroducedVersion: version.MajorMinor(1, 999), 41 | EnvOptions: []celgo.EnvOption{library.Test()}, 42 | }) 43 | if err != nil { 44 | fmt.Println(err) 45 | return 0 46 | } 47 | compiler := admissioncel.NewCompiler(extended) 48 | 49 | options := admissioncel.OptionalVariableDeclarations{HasParams: true, HasAuthorizer: true} 50 | result := compiler.CompileCELExpression(&fakeValidationCondition{ 51 | Expression: expr, 52 | }, options, environment.NewExpressions) 53 | if result.Error != nil { 54 | fmt.Sprintf("Got error: %s", result.Error) 55 | return 1 56 | } 57 | return 0 58 | } 59 | -------------------------------------------------------------------------------- /projects/kubernetes/fuzz_compile.dict: -------------------------------------------------------------------------------- 1 | object 2 | in 3 | [1, 2, 4 | [1, 2, 3] 5 | test() 6 | == 7 | = 8 | + 9 | - 10 | < 11 | > 12 | >= 13 | <= 14 | true 15 | 100 16 | 0 17 | 0.0 18 | 1.0 19 | "\"okay\"" 20 | .replicas 21 | string(test()) 22 | string() 23 | string(self) 24 | size(self) 25 | fakeFunction('abc') 26 | has() 27 | .value() 28 | .orValue(1) 29 | .minReplicas 30 | .maxReplicas 31 | .startsWith('s') 32 | .endsWith('s') 33 | .all(x, x.all(y, x[y].key == x[y].key)) 34 | .contains('keyword') 35 | .value 36 | .matches(r"""^(\*\.)?[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$""") 37 | .exists(f, f.type == ''RequestRedirect'') 38 | .filter(f, f.type == 'RequestHeaderModifier') 39 | -------------------------------------------------------------------------------- /projects/kubernetes/fuzz_compile_seed_corpus.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncf/cncf-fuzzing/28bd6312a53e106808809d662eccda8ec3913e19/projects/kubernetes/fuzz_compile_seed_corpus.zip -------------------------------------------------------------------------------- /projects/kubernetes/internal_kubelet_kuberuntime_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package kuberuntime 17 | 18 | import ( 19 | "context" 20 | v1 "k8s.io/api/core/v1" 21 | kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" 22 | 23 | fuzz "github.com/AdaLogics/go-fuzz-headers" 24 | ) 25 | 26 | func FuzzKubeRuntime(data []byte) int { 27 | f := fuzz.NewConsumer(data) 28 | pod := &v1.Pod{} 29 | status := &kubecontainer.PodStatus{} 30 | err := f.GenerateStruct(pod) 31 | if err != nil { 32 | return 0 33 | } 34 | err = f.GenerateStruct(status) 35 | if err != nil { 36 | return 0 37 | } 38 | _, _, m, err := createTestRuntimeManager() 39 | if err != nil { 40 | return 0 41 | } 42 | _ = m.computePodActions(context.Background(), pod, status) 43 | return 1 44 | } 45 | -------------------------------------------------------------------------------- /projects/kubernetes/internal_kubelet_server_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package server 17 | 18 | import ( 19 | "fmt" 20 | "net/http" 21 | "testing" 22 | "time" 23 | 24 | "k8s.io/apimachinery/pkg/util/httpstream/spdy" 25 | 26 | fuzz "github.com/AdaLogics/go-fuzz-headers" 27 | ) 28 | 29 | func init() { 30 | testing.Init() 31 | } 32 | 33 | func errorHandler() { 34 | if r := recover(); r != nil { 35 | fmt.Println(r) 36 | } 37 | } 38 | 39 | func FuzzRequest(data []byte) int { 40 | defer errorHandler() 41 | t := &testing.T{} 42 | f := fuzz.NewConsumer(data) 43 | urlString, err := f.GetString() 44 | if err != nil { 45 | return 0 46 | } 47 | ss, err := newTestStreamingServer(100 * time.Millisecond) 48 | if err != nil { 49 | return 0 50 | } 51 | defer ss.testHTTPServer.Close() 52 | fw := newServerTestWithDebug(true, ss) 53 | defer fw.testHTTPServer.Close() 54 | 55 | url := fw.testHTTPServer.URL + urlString 56 | 57 | upgradeRoundTripper, err := spdy.NewRoundTripper(nil) 58 | if err != nil { 59 | return 0 60 | } 61 | c := &http.Client{Transport: upgradeRoundTripper} 62 | 63 | resp, err := c.Do(makeReq(t, "POST", url, "v4.channel.k8s.io")) 64 | if err != nil { 65 | return 0 66 | } 67 | defer resp.Body.Close() 68 | return 1 69 | } 70 | -------------------------------------------------------------------------------- /projects/kubernetes/mount-utils_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | // place in kubernetes/staging/src/k8s.io/mount-utils 17 | package mount 18 | 19 | import ( 20 | "io/ioutil" 21 | "os" 22 | ) 23 | 24 | func FuzzSearchMountPoints(data []byte) int { 25 | tmpFile, err := ioutil.TempFile("", "test-get-filetype") 26 | if err != nil { 27 | panic(err) 28 | } 29 | defer os.Remove(tmpFile.Name()) 30 | defer tmpFile.Close() 31 | tmpFile.Truncate(0) 32 | tmpFile.Seek(0, 0) 33 | tmpFile.WriteString(string(data)) 34 | tmpFile.Sync() 35 | _, _ = SearchMountPoints("/mnt/disks/vol1", tmpFile.Name()) 36 | return 1 37 | } 38 | -------------------------------------------------------------------------------- /projects/notary/fuzz_cose.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package cose 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzSignatureCose(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, envelopeBytes []byte, shouldVerify bool) { 24 | e, err := ParseEnvelope(envelopeBytes) 25 | if err != nil { 26 | t.Skip() 27 | } 28 | 29 | if shouldVerify { 30 | _, _ = e.Verify() 31 | } else { 32 | _, _ = e.Content() 33 | } 34 | }) 35 | } 36 | -------------------------------------------------------------------------------- /projects/notary/fuzz_jws.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package jws 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzSignatureJws(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, envelopeBytes []byte, shouldVerify bool) { 24 | e, err := ParseEnvelope(envelopeBytes) 25 | if err != nil { 26 | t.Skip() 27 | } 28 | 29 | if shouldVerify { 30 | _, _ = e.Verify() 31 | } else { 32 | _, _ = e.Content() 33 | } 34 | }) 35 | } 36 | -------------------------------------------------------------------------------- /projects/notary/fuzz_notation_artifactref_parsing.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package notation 17 | 18 | import ( 19 | "testing" 20 | 21 | orasRegistry "oras.land/oras-go/v2/registry" 22 | ) 23 | 24 | func FuzzArtifactReferenceParsing(f *testing.F) { 25 | f.Fuzz(func(t *testing.T, artifactRef string) { 26 | ref, err := orasRegistry.ParseReference(artifactRef) 27 | if err != nil { 28 | t.Skip() 29 | } 30 | if ref.Reference == "" { 31 | t.Skip() 32 | } 33 | ref.ValidateReferenceAsDigest() 34 | }) 35 | } 36 | -------------------------------------------------------------------------------- /projects/notary/fuzz_pkix_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package pkix 17 | 18 | import ( 19 | "testing" 20 | ) 21 | 22 | func FuzzParseDistinguishedName(f *testing.F) { 23 | f.Fuzz(func(t *testing.T, name string) { 24 | _, _ = ParseDistinguishedName(name) 25 | }) 26 | } 27 | -------------------------------------------------------------------------------- /projects/notary/fuzz_trustmanager_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package trustmanager 17 | 18 | import ( 19 | "bytes" 20 | "encoding/pem" 21 | "sync" 22 | "testing" 23 | 24 | "github.com/sirupsen/logrus" 25 | 26 | fuzz "github.com/AdaLogics/go-fuzz-headers" 27 | ) 28 | 29 | var initter sync.Once 30 | 31 | func muteLogging() { 32 | logrus.SetLevel(logrus.PanicLevel) 33 | } 34 | 35 | func FuzzImportKeysSimple(f *testing.F) { 36 | f.Fuzz(func(t *testing.T, from []byte, fallbackRole, fallbackGUN string) { 37 | initter.Do(muteLogging) 38 | s := NewTestImportStore() 39 | 40 | in := bytes.NewReader(from) 41 | ImportKeys(in, []Importer{s}, fallbackRole, fallbackGUN, passphraseRetriever) 42 | }) 43 | } 44 | 45 | func FuzzImportKeysStructured(f *testing.F) { 46 | f.Fuzz(func(t *testing.T, from, fuzzData []byte) { 47 | initter.Do(muteLogging) 48 | 49 | ff := fuzz.NewConsumer(fuzzData) 50 | 51 | b := &pem.Block{} 52 | headerMap1 := make(map[string]string) 53 | ff.FuzzMap(&headerMap1) 54 | b.Headers = headerMap1 55 | b.Bytes = from 56 | 57 | c := &pem.Block{} 58 | headerMap2 := make(map[string]string) 59 | ff.FuzzMap(&headerMap2) 60 | c.Bytes = from 61 | c.Headers = headerMap2 62 | 63 | bBytes := pem.EncodeToMemory(b) 64 | cBytes := pem.EncodeToMemory(c) 65 | 66 | byt := append(bBytes, cBytes...) 67 | 68 | in := bytes.NewBuffer(byt) 69 | 70 | s := NewTestImportStore() 71 | ImportKeys(in, []Importer{s}, "", "", passphraseRetriever) 72 | }) 73 | } -------------------------------------------------------------------------------- /projects/notary/fuzz_trustpolicy.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package trustpolicy 17 | 18 | import ( 19 | "testing" 20 | 21 | fuzz "github.com/AdaLogics/go-fuzz-headers" 22 | ) 23 | 24 | func FuzzDocumentValidate(f *testing.F) { 25 | f.Fuzz(func(t *testing.T, documentData []byte) { 26 | ff := fuzz.NewConsumer(documentData) 27 | policyDoc := &Document{} 28 | ff.GenerateStruct(policyDoc) 29 | policyDoc.Validate() 30 | }) 31 | } 32 | -------------------------------------------------------------------------------- /projects/openyurt/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | # set -o nounset 3 | # set -o pipefail 4 | # set -o errexit 5 | # set -x 6 | 7 | PROJECT_ROOT="${GOPATH:-/root/go}/src/github.com/openyurtio" 8 | 9 | # Build the fuzzers for all cloned sub-projects 10 | find "${PROJECT_ROOT}/" -type f -name oss_fuzz_build.sh | xargs chmod +x 11 | 12 | find "${PROJECT_ROOT}/" -type f -name oss_fuzz_build.sh | bash -e 13 | -------------------------------------------------------------------------------- /projects/runc/.gitignore: -------------------------------------------------------------------------------- 1 | !.gitignore 2 | -------------------------------------------------------------------------------- /projects/runc/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -eu 2 | set -o nounset 3 | set -o pipefail 4 | set -o errexit 5 | set -x 6 | 7 | go clean --modcache 8 | go mod tidy 9 | go mod vendor 10 | 11 | # This one has a fuzzer that breaks 12 | #rm /root/go/pkg/mod/github.com/cilium/ebpf@v0.7.0/internal/btf/fuzz.go 13 | 14 | rm -r $SRC/runc/vendor 15 | go get github.com/AdaLogics/go-fuzz-headers 16 | 17 | export RUNC_PATH=github.com/opencontainers/runc 18 | export RUNC_FUZZERS=/src/cncf-fuzzing/projects/runc 19 | 20 | 21 | mv $RUNC_FUZZERS/libcontainer_utils_fuzzer.go $SRC/runc/libcontainer/utils/ 22 | compile_go_fuzzer $RUNC_PATH/libcontainer/utils FuzzstripRoot fuzz_strip_root 23 | 24 | mv $RUNC_FUZZERS/fs2_fuzzer.go $SRC/runc/libcontainer/cgroups/fs2/ 25 | compile_go_fuzzer $RUNC_PATH/libcontainer/cgroups/fs2 FuzzGetStats get_stats_fuzzer 26 | compile_go_fuzzer $RUNC_PATH/libcontainer/cgroups/fs2 FuzzCgroupReader cgroup_reader_fuzzer 27 | 28 | mv $RUNC_FUZZERS/specconv_fuzzer.go $SRC/runc/libcontainer/specconv/ 29 | compile_go_fuzzer $RUNC_PATH/libcontainer/specconv Fuzz specconv_fuzzer 30 | 31 | mv $RUNC_FUZZERS/devices_fuzzer.go $SRC/runc/libcontainer/cgroups/devices 32 | compile_go_fuzzer $RUNC_PATH/libcontainer/cgroups/devices Fuzz devices_fuzzer 33 | 34 | mv $RUNC_FUZZERS/fscommon_fuzzer.go $SRC/runc/libcontainer/cgroups/fscommon/ 35 | compile_go_fuzzer $RUNC_PATH/libcontainer/cgroups/fscommon FuzzSecurejoin securejoin_fuzzer 36 | 37 | mv $RUNC_FUZZERS/intelrdt_fuzzer.go $SRC/runc/libcontainer/intelrdt/ 38 | mv $SRC/runc/libcontainer/intelrdt/util_test.go $SRC/runc/libcontainer/intelrdt/util_test_fuzz.go 39 | compile_go_fuzzer $RUNC_PATH/libcontainer/intelrdt FuzzSetCacheScema set_cache_schema_fuzzer 40 | compile_go_fuzzer $RUNC_PATH/libcontainer/intelrdt FuzzParseMonFeatures parse_mon_features_fuzzer 41 | 42 | mv $RUNC_FUZZERS/libcontainer_fuzzer.go $SRC/runc/libcontainer/ 43 | mv $SRC/runc/libcontainer/container_linux_test.go \ 44 | $SRC/runc/libcontainer/container_linux_test_fuzz.go 45 | CFLAGS=-O1 make -B runc-dmz || echo -n >runc-dmz 46 | compile_go_fuzzer $RUNC_PATH/libcontainer FuzzStateApi state_api_fuzzer 47 | -------------------------------------------------------------------------------- /projects/runc/devices_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package devices 17 | 18 | import ( 19 | gofuzzheaders "github.com/AdaLogics/go-fuzz-headers" 20 | "strings" 21 | ) 22 | 23 | func Fuzz(data []byte) int { 24 | c := gofuzzheaders.NewConsumer(data) 25 | str1, err := c.GetString() 26 | if err != nil { 27 | return -1 28 | } 29 | reader1 := strings.NewReader(str1) 30 | emu1, err := emulatorFromList(reader1) 31 | if err != nil { 32 | return -1 33 | } 34 | 35 | str2, err := c.GetString() 36 | if err != nil { 37 | return -1 38 | } 39 | reader2 := strings.NewReader(str2) 40 | emu2, err := emulatorFromList(reader2) 41 | if err != nil { 42 | return -1 43 | } 44 | emu1.Transition(emu2) 45 | return 1 46 | } 47 | -------------------------------------------------------------------------------- /projects/runc/fscommon_fuzzer.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | // Copyright 2021 ADA Logics Ltd 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | package fscommon 20 | 21 | import ( 22 | gofuzzheaders "github.com/AdaLogics/go-fuzz-headers" 23 | securejoin "github.com/cyphar/filepath-securejoin" 24 | ) 25 | 26 | func FuzzSecurejoin(data []byte) int { 27 | c := gofuzzheaders.NewConsumer(data) 28 | dir, err := c.GetString() 29 | if err != nil { 30 | return 0 31 | } 32 | file, err := c.GetString() 33 | if err != nil { 34 | return 0 35 | } 36 | _, err = securejoin.SecureJoin(dir, file) 37 | if err != nil { 38 | return 0 39 | } 40 | return 1 41 | } 42 | -------------------------------------------------------------------------------- /projects/runc/intelrdt_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2021 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package intelrdt 17 | 18 | import ( 19 | "strings" 20 | "testing" 21 | ) 22 | 23 | func init() { 24 | testing.Init() 25 | } 26 | 27 | func FuzzParseMonFeatures(data []byte) int { 28 | _, _ = parseMonFeatures( 29 | strings.NewReader(string(data))) 30 | return 1 31 | } 32 | 33 | func FuzzSetCacheScema(data []byte) int { 34 | t := &testing.T{} 35 | if (len(data) % 2) != 0 { 36 | return -1 37 | } 38 | halfLen := len(data) / 2 39 | firstHalf := data[:halfLen] 40 | secondHalf := data[halfLen:] 41 | 42 | helper := NewIntelRdtTestUtil(t) 43 | 44 | l3CacheSchemaBefore := string(firstHalf) 45 | l3CacheSchemeAfter := string(secondHalf) 46 | 47 | helper.writeFileContents(map[string]string{ 48 | "schemata": l3CacheSchemaBefore + "\n", 49 | }) 50 | 51 | helper.config.IntelRdt.L3CacheSchema = l3CacheSchemeAfter 52 | intelrdt := NewManager(helper.config, "", helper.IntelRdtPath) 53 | intelrdt.Set(helper.config) 54 | 55 | return 1 56 | } -------------------------------------------------------------------------------- /projects/runc/libcontainer_utils_fuzzer.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | // Copyright 2022 ADA Logics Ltd 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | package utils 20 | 21 | import ( 22 | fuzz "github.com/AdaLogics/go-fuzz-headers" 23 | ) 24 | 25 | func FuzzstripRoot(data []byte) int { 26 | f := fuzz.NewConsumer(data) 27 | root, err := f.GetString() 28 | if err != nil { 29 | return 0 30 | } 31 | path, err := f.GetString() 32 | if err != nil { 33 | return 0 34 | } 35 | 36 | _ = stripRoot(root, path) 37 | return 1 38 | } 39 | -------------------------------------------------------------------------------- /projects/vitess/abstract_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package operators 17 | 18 | import ( 19 | "vitess.io/vitess/go/vt/sqlparser" 20 | "vitess.io/vitess/go/vt/vtgate/semantics" 21 | "vitess.io/vitess/go/vt/vtgate/planbuilder/plancontext" 22 | ) 23 | 24 | // FuzzAnalyse implements the fuzzer 25 | func FuzzAnalyse(data []byte) int { 26 | tree, err := sqlparser.NewTestParser().Parse(string(data)) 27 | if err != nil { 28 | return -1 29 | } 30 | semTable, err := semantics.Analyze(tree, "", &semantics.FakeSI{}) 31 | if err != nil { 32 | return 0 33 | } 34 | ctx := &plancontext.PlanningContext{ 35 | SemTable: semTable, 36 | } 37 | _ = translateQueryToOp(ctx, tree) 38 | /*switch stmt := tree.(type) { 39 | case *sqlparser.Select: 40 | semTable, err := semantics.Analyze(stmt, "", &semantics.FakeSI{}) 41 | if err != nil { 42 | return 0 43 | } 44 | ctx := &plancontext.PlanningContext{ 45 | SemTable: semTable, 46 | } 47 | _ = createOperatorFromSelect(ctx, stmt) 48 | 49 | default: 50 | return 0 51 | }*/ 52 | return 1 53 | } 54 | -------------------------------------------------------------------------------- /projects/vitess/ast_fuzzer.go: -------------------------------------------------------------------------------- 1 | //go:build gofuzz 2 | // +build gofuzz 3 | 4 | // Copyright 2022 ADA Logics Ltd 5 | // 6 | // Licensed under the Apache License, Version 2.0 (the "License"); 7 | // you may not use this file except in compliance with the License. 8 | // You may obtain a copy of the License at 9 | // 10 | // http://www.apache.org/licenses/LICENSE-2.0 11 | // 12 | // Unless required by applicable law or agreed to in writing, software 13 | // distributed under the License is distributed on an "AS IS" BASIS, 14 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | // See the License for the specific language governing permissions and 16 | // limitations under the License. 17 | // 18 | 19 | package fuzzing 20 | 21 | import ( 22 | "vitess.io/vitess/go/vt/sqlparser" 23 | ) 24 | 25 | // FuzzEqualsSQLNode implements the fuzzer 26 | func FuzzEqualsSQLNode(data []byte) int { 27 | if len(data) < 10 { 28 | return 0 29 | } 30 | parser := sqlparser.NewTestParser() 31 | expr, err := parser.Parse(string(data)) 32 | if err != nil { 33 | return 0 34 | } 35 | _ = sqlparser.RewritePredicate(expr) 36 | return 1 37 | } 38 | -------------------------------------------------------------------------------- /projects/vitess/collations_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package colldata 17 | 18 | import ( 19 | fuzz "github.com/AdaLogics/go-fuzz-headers" 20 | ) 21 | 22 | var ( 23 | fuzzCollations = []string{"utf8mb4_bin", "utf8mb4_0900_ai_ci", 24 | "utf8mb4_0900_as_ci", "utf8mb4_0900_as_cs", 25 | "utf8mb4_0900_ai_ci", "utf8mb4_0900_as_ci", 26 | "utf8mb4_0900_ai_ci", "utf8mb4_0900_ai_ci", 27 | "utf8mb4_hu_0900_as_cs", "utf8mb4_ja_0900_as_cs", 28 | "utf8mb4_ja_0900_as_cs_ks", "utf8mb4_zh_0900_as_cs", 29 | "utf8mb4_zh_0900_as_cs"} 30 | ) 31 | 32 | func FuzzCollations(data []byte) int { 33 | testinit() 34 | f := fuzz.NewConsumer(data) 35 | collIndex, err := f.GetInt() 36 | if err != nil { 37 | return 0 38 | } 39 | collString := fuzzCollations[collIndex%len(fuzzCollations)] 40 | coll := testcollationMap[collString] 41 | left, err := f.GetBytes() 42 | if err != nil { 43 | return 0 44 | } 45 | right, err := f.GetBytes() 46 | if err != nil { 47 | return 0 48 | } 49 | _ = coll.Collate(left, right, false) 50 | return 1 51 | } 52 | -------------------------------------------------------------------------------- /projects/vitess/fuzz_keyspace_creation.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package topotests 17 | 18 | import ( 19 | "context" 20 | "testing" 21 | 22 | fuzz "github.com/AdaLogics/go-fuzz-headers" 23 | 24 | _flag "vitess.io/vitess/go/internal/flag" 25 | topodatapb "vitess.io/vitess/go/vt/proto/topodata" 26 | "vitess.io/vitess/go/vt/topo/memorytopo" 27 | ) 28 | 29 | func init() { 30 | _flag.TrickGlog() 31 | } 32 | 33 | func FuzzKeyspaceCreation(f *testing.F) { 34 | f.Fuzz(func(t *testing.T, data []byte) { 35 | ff := fuzz.NewConsumer(data) 36 | ks := make([]string, 0) 37 | ff.CreateSlice(&ks) 38 | if len(ks) < 2 { 39 | return 40 | } 41 | ctx := context.Background() 42 | ts := memorytopo.NewServer(ctx, "zone1") 43 | var createdKs []string 44 | createdKs = make([]string, 0) 45 | for _, k := range ks { 46 | err := ts.CreateKeyspace(ctx, k, &topodatapb.Keyspace{}) 47 | if err == nil { 48 | createdKs = append(createdKs, k) 49 | } 50 | } 51 | 52 | for _, k := range createdKs { 53 | _, err := ts.GetKeyspace(ctx, k) 54 | if err != nil { 55 | panic(err) 56 | } 57 | if ks == nil { 58 | panic("ks was nil") 59 | } 60 | } 61 | }) 62 | } 63 | -------------------------------------------------------------------------------- /projects/vitess/fuzz_shard_creation.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package topotests 17 | 18 | import ( 19 | "context" 20 | "testing" 21 | 22 | fuzz "github.com/AdaLogics/go-fuzz-headers" 23 | 24 | _flag "vitess.io/vitess/go/internal/flag" 25 | topodatapb "vitess.io/vitess/go/vt/proto/topodata" 26 | "vitess.io/vitess/go/vt/topo/memorytopo" 27 | ) 28 | 29 | func init() { 30 | _flag.TrickGlog() 31 | } 32 | 33 | var ( 34 | ks = "ks1" 35 | ) 36 | 37 | func FuzzShardCreation(f *testing.F) { 38 | f.Fuzz(func(t *testing.T, data []byte) { 39 | ff := fuzz.NewConsumer(data) 40 | s := make([]string, 0) 41 | ff.CreateSlice(&s) 42 | sUpdate := make([]string, 0) 43 | ff.CreateSlice(&sUpdate) 44 | if len(s) < 2 { 45 | return 46 | } 47 | var createdS []string 48 | createdS = make([]string, 0) 49 | ctx := context.Background() 50 | ts := memorytopo.NewServer(ctx, "zone1") 51 | err := ts.CreateKeyspace(ctx, ks, &topodatapb.Keyspace{}) 52 | if err != nil { 53 | panic(err) 54 | } 55 | defer func() { 56 | for _, sh := range createdS { 57 | ts.DeleteShard(ctx, ks, sh) 58 | } 59 | }() 60 | 61 | for _, sh := range s { 62 | err := ts.CreateShard(ctx, ks, sh) 63 | if err == nil { 64 | createdS = append(createdS, sh) 65 | } 66 | } 67 | 68 | for _, sh := range createdS { 69 | _, err := ts.GetShard(ctx, ks, sh) 70 | if err != nil { 71 | panic(err) 72 | } 73 | } 74 | }) 75 | } 76 | -------------------------------------------------------------------------------- /projects/vitess/fuzz_tablet_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 the cncf-fuzzing authors 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package topotests 17 | 18 | import ( 19 | "context" 20 | "testing" 21 | 22 | fuzz "github.com/AdamKorcz/go-fuzz-headers-1" 23 | 24 | topodatapb "vitess.io/vitess/go/vt/proto/topodata" 25 | "vitess.io/vitess/go/vt/topo/memorytopo" 26 | ) 27 | 28 | func FuzzTabletCreation(f *testing.F) { 29 | f.Fuzz(func(t *testing.T, data []byte) { 30 | ff := fuzz.NewConsumer(data) 31 | tablets := make([]*topodatapb.Tablet, 0) 32 | ff.CreateSlice(&tablets) 33 | if len(tablets) < 2 { 34 | return 35 | } 36 | aliases := make([]*topodatapb.TabletAlias, 0) 37 | ctx := context.Background() 38 | ts := memorytopo.NewServer(ctx, "cell1") 39 | for _, tablet := range tablets { 40 | err := ts.CreateTablet(ctx, tablet) 41 | if err == nil { 42 | aliases = append(aliases, tablet.Alias) 43 | } 44 | } 45 | for _, alias := range aliases { 46 | _, _ = ts.GetTablet(ctx, alias) 47 | } 48 | }) 49 | } 50 | -------------------------------------------------------------------------------- /projects/vitess/tablet_manager_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package fuzzing 17 | 18 | import ( 19 | "context" 20 | "sync" 21 | "testing" 22 | 23 | "vitess.io/vitess/go/mysql" 24 | "vitess.io/vitess/go/mysql/fakesqldb" 25 | "vitess.io/vitess/go/sqltypes" 26 | "vitess.io/vitess/go/vt/dbconfigs" 27 | "vitess.io/vitess/go/vt/mysqlctl" 28 | "vitess.io/vitess/go/vt/vttablet/tabletmanager" 29 | "vitess.io/vitess/go/vt/vttablet/tabletservermock" 30 | 31 | tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata" 32 | ) 33 | 34 | var fuzzInitter sync.Once 35 | 36 | func initTesting() { 37 | testing.Init() 38 | } 39 | 40 | func FuzzTabletManagerExecuteFetchAsDba(data []byte) int { 41 | fuzzInitter.Do(initTesting) 42 | t := &testing.T{} 43 | ctx := context.Background() 44 | cp := mysql.ConnParams{} 45 | db := fakesqldb.New(t) 46 | db.AddQueryPattern(".*", &sqltypes.Result{}) 47 | daemon := mysqlctl.NewFakeMysqlDaemon(db) 48 | 49 | dbName := "dbname" 50 | tm := &tabletmanager.TabletManager{ 51 | MysqlDaemon: daemon, 52 | DBConfigs: dbconfigs.NewTestDBConfigs(cp, cp, dbName), 53 | QueryServiceControl: tabletservermock.NewController(), 54 | } 55 | _, _ = tm.ExecuteFetchAsDba(ctx, &tabletmanagerdatapb.ExecuteFetchAsDbaRequest{ 56 | Query: data, 57 | DbName: dbName, 58 | MaxRows: 10, 59 | DisableBinlogs: false, 60 | ReloadSchema: false, 61 | }) 62 | return 1 63 | } 64 | -------------------------------------------------------------------------------- /projects/vitess/tabletserver_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package tabletserver 17 | 18 | import ( 19 | "context" 20 | "sync" 21 | "testing" 22 | 23 | fuzz "github.com/AdaLogics/go-fuzz-headers" 24 | 25 | "vitess.io/vitess/go/mysql/fakesqldb" 26 | "vitess.io/vitess/go/vt/vtenv" 27 | "vitess.io/vitess/go/sqltypes" 28 | "vitess.io/vitess/go/vt/vttablet/tabletserver/schema" 29 | "vitess.io/vitess/go/vt/vttablet/tabletserver/tabletenv" 30 | ) 31 | 32 | var initter sync.Once 33 | 34 | func initForFuzzing() { 35 | testing.Init() 36 | } 37 | 38 | // FuzzGetPlan implements a fuzzer that tests GetPlan. 39 | func FuzzGetPlan(data []byte) int { 40 | initter.Do(initForFuzzing) 41 | t := &testing.T{} 42 | f := fuzz.NewConsumer(data) 43 | query1, err := f.GetSQLString() 44 | if err != nil { 45 | return 0 46 | } 47 | query2, err := f.GetString() 48 | if err != nil { 49 | return 0 50 | } 51 | db := fakesqldb.New(t) 52 | defer db.Close() 53 | 54 | // Add a query 55 | db.AddQuery(query1, &sqltypes.Result{}) 56 | 57 | // Set up the environment 58 | config := tabletenv.NewDefaultConfig() 59 | config.DB = newDBConfigs(db) 60 | env := tabletenv.NewEnv(vtenv.NewTestEnv(), config, "TabletServerTest") 61 | se := schema.NewEngine(env) 62 | qe := NewQueryEngine(env, se) 63 | defer qe.Close() 64 | qe.Open() 65 | 66 | logStats := tabletenv.NewLogStats(context.Background(), "GetPlanStats") 67 | // Call target 68 | _, _ = qe.GetPlan(context.Background(), logStats, query2, true) 69 | return 1 70 | } 71 | -------------------------------------------------------------------------------- /projects/vitess/tabletserver_rules_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package fuzzing 17 | 18 | import ( 19 | "vitess.io/vitess/go/vt/vttablet/tabletserver/rules" 20 | ) 21 | 22 | func FuzzUnmarshalJSON(data []byte) int { 23 | qrs := rules.New() 24 | _ = qrs.UnmarshalJSON(data) 25 | return 1 26 | } 27 | -------------------------------------------------------------------------------- /projects/vitess/tabletserver_schema_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package schema 17 | 18 | import ( 19 | "fmt" 20 | "testing" 21 | 22 | "vitess.io/vitess/go/sqltypes" 23 | "vitess.io/vitess/go/mysql/fakesqldb" 24 | ) 25 | 26 | 27 | func FuzzLoadTable(f *testing.F) { 28 | f.Fuzz(func(t *testing.T, comment, query, tableType string) { 29 | defer func() { 30 | if r := recover(); r != nil { 31 | fmt.Println("Recovered. Error:\n", r) 32 | } 33 | }() 34 | db := fakesqldb.New(t) 35 | defer db.Close() 36 | db.AddQuery(query, &sqltypes.Result{}) 37 | _, _ = newTestLoadTable(tableType, comment, db) 38 | }) 39 | 40 | } -------------------------------------------------------------------------------- /projects/vitess/vstreamer_fuzzer.go: -------------------------------------------------------------------------------- 1 | // Copyright 2022 ADA Logics Ltd 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | 16 | package vstreamer 17 | 18 | import ( 19 | "fmt" 20 | fuzz "github.com/AdaLogics/go-fuzz-headers" 21 | 22 | binlogdatapb "vitess.io/vitess/go/vt/proto/binlogdata" 23 | vschemapb "vitess.io/vitess/go/vt/proto/vschema" 24 | "vitess.io/vitess/go/vt/vtenv" 25 | "vitess.io/vitess/go/vt/sqlparser" 26 | "vitess.io/vitess/go/vt/vtgate/vindexes" 27 | ) 28 | 29 | // Fuzz implements the fuzzer 30 | func FuzzbuildPlan(data []byte) int { 31 | defer func() { 32 | if r := recover(); r != nil { 33 | fmt.Println("Recovered. Error:\n", r) 34 | } 35 | }() 36 | var kspb vschemapb.Keyspace 37 | c := fuzz.NewConsumer(data) 38 | err := c.GenerateStruct(&kspb) 39 | if err != nil { 40 | return -1 41 | } 42 | srvVSchema := &vschemapb.SrvVSchema{ 43 | Keyspaces: map[string]*vschemapb.Keyspace{ 44 | "ks": &kspb, 45 | }, 46 | } 47 | vschema := vindexes.BuildVSchema(srvVSchema, sqlparser.NewTestParser()) 48 | if err != nil { 49 | return -1 50 | } 51 | 52 | // Create a fuzzed Table 53 | t1 := &Table{} 54 | err = c.GenerateStruct(t1) 55 | if err != nil { 56 | return -1 57 | } 58 | 59 | testLocalVSchema := &localVSchema{ 60 | keyspace: "ks", 61 | vschema: vschema, 62 | } 63 | 64 | str1, err := c.GetString() 65 | if err != nil { 66 | return -1 67 | } 68 | str2, err := c.GetString() 69 | if err != nil { 70 | return -1 71 | } 72 | _, _ = buildPlan(vtenv.NewTestEnv(), t1, testLocalVSchema, &binlogdatapb.Filter{ 73 | Rules: []*binlogdatapb.Rule{ 74 | {Match: str1, Filter: str2}, 75 | }, 76 | }) 77 | return 1 78 | } 79 | -------------------------------------------------------------------------------- /projects/vitess/vtctl_fuzzer.dict: -------------------------------------------------------------------------------- 1 | "insert into" 2 | "(" 3 | ")" 4 | "values" 5 | "create" 6 | "table" 7 | "bigint" 8 | "char" 9 | "NOT NULL" 10 | "varbinary" 11 | "primary key" 12 | "constraint" 13 | "references" 14 | "where" 15 | "from" 16 | "as" 17 | "select" 18 | "and" 19 | "group" 20 | "order" 21 | "by" 22 | "$"" 23 | "_" 24 | "'" 25 | "inner" 26 | "left" 27 | "right" 28 | "full" 29 | "outer" 30 | "join" 31 | "on" 32 | 33 | 34 | "=" 35 | ":" 36 | ";" 37 | "," 38 | "-allow_update" 39 | "-allow_primary" 40 | "-allow_different_shard" 41 | "-allow_master_override" 42 | "-parent" 43 | "-db_name_override" 44 | "-dry-run" 45 | "-hostname" 46 | "-mysql_port" 47 | "-port" 48 | "-grpc_port" 49 | "-tags" 50 | "-keyspace" 51 | "-shard" 52 | "-cells" 53 | "-json" 54 | "-use_pool" 55 | "-max_rows" 56 | "-concurrency" 57 | "-disable_binlogs" --------------------------------------------------------------------------------