knative: move fuzzers to cncf-fuzzing (#9330)

The fuzzers have been moved to cncf-fuzzing:
https://github.com/cncf/cncf-fuzzing/tree/main/projects/knative. This PR
removes them from OSS-Fuzz.
Signed-off-by: AdamKorcz <adam@adalogics.com>

Signed-off-by: AdamKorcz <adam@adalogics.com>
This commit is contained in:
AdamKorcz 2023-01-02 14:16:04 +00:00 committed by GitHub
parent 27d88acfd0
commit c6f990956e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 192 deletions

View File

@ -19,9 +19,4 @@ RUN git clone --depth 1 https://github.com/cncf/cncf-fuzzing
RUN git clone --depth 1 https://github.com/knative/pkg
RUN git clone --depth 1 https://github.com/knative/serving
WORKDIR $SRC/pkg
COPY build.sh \
json_fuzzer.go \
fuzz_activatornet.go \
fuzz_pkg_metrics.go \
fuzz_pkg_websocket.go \
$SRC/
COPY build.sh $SRC/

View File

@ -1,94 +0,0 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package net
import (
"context"
"os"
"testing"
fuzz "github.com/AdaLogics/go-fuzz-headers"
"go.uber.org/zap"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
pkgnet "knative.dev/networking/pkg/apis/networking"
"knative.dev/serving/pkg/queue"
"knative.dev/pkg/injection"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
"knative.dev/pkg/controller"
)
func NewFuzzLogger() *zap.SugaredLogger {
var config zap.Config
config = zap.NewProductionConfig()
// Config customization goes here if any
config.OutputPaths = []string{os.DevNull}
logger, err := config.Build()
if err != nil {
panic(err)
}
return logger.Named("knative-log").Sugar()
}
func FuzzNewRevisionThrottler(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
ff := fuzz.NewConsumer(data)
revName := types.NamespacedName{}
ff.GenerateStruct(&revName)
containerConcurrency, err := ff.GetInt()
if err != nil {
t.Skip()
}
params := queue.BreakerParams{}
ff.GenerateStruct(&params)
if params.QueueDepth <= 0 {
t.Skip()
}
if params.MaxConcurrency < 0 {
t.Skip()
}
if params.InitialCapacity < 0 || params.InitialCapacity > params.MaxConcurrency {
t.Skip()
}
logger := NewFuzzLogger()
rt := newRevisionThrottler(revName, containerConcurrency%10, pkgnet.ServicePortNameHTTP1, params, logger)
//ctx := context.Background()
ctx, cancel := SetupFakeContextWithCancel()
defer cancel()
throttler := newTestThrottler(ctx)
throttler.revisionThrottlers[revName] = rt
update := revisionDestsUpdate{
Rev: revName,
ClusterIPDest: "",
Dests: sets.NewString("ip3", "ip2", "ip1"),
}
throttler.handleUpdate(update)
})
}
func SetupFakeContextWithCancel() (context.Context, context.CancelFunc) {
ctx, c := context.WithCancel(context.Background())
ctx = controller.WithEventRecorder(ctx, record.NewFakeRecorder(1000))
ctx, _ = injection.Fake.SetupInformers(ctx, &rest.Config{})
return ctx, c
}

View File

@ -1,30 +0,0 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package metrics
import (
fuzz "github.com/AdaLogics/go-fuzz-headers"
corev1 "k8s.io/api/core/v1"
"testing"
)
func FuzzNewObservabilityConfigFromConfigMap(f *testing.F) {
f.Fuzz(func(t *testing.T, configMapData []byte) {
ff := fuzz.NewConsumer(configMapData)
cm := &corev1.ConfigMap{}
ff.GenerateStruct(cm)
_, _ = NewObservabilityConfigFromConfigMap(cm)
})
}

View File

@ -1,42 +0,0 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package websocket
import (
"github.com/gorilla/websocket"
"testing"
)
func FuzzSendRawMessage(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
spy := &inspectableConnection{
writeMessageCalls: make(chan struct{}, 1),
}
conn := newConnection(staticConnFactory(spy), nil)
conn.connect()
if got := conn.Status(); got != nil {
t.Skip()
}
if got := conn.SendRaw(websocket.BinaryMessage, data); got != nil {
t.Skip()
}
if len(spy.writeMessageCalls) != 1 {
t.Fatalf("Expected 'WriteMessage' to be called once, but was called %v times", spy.writeMessageCalls)
}
})
}

View File

@ -1,20 +0,0 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package json
func FuzzJsonDecode(data []byte) int {
Decode(data, &fixture{}, false)
return 1
}