diff --git a/projects/fabric/Dockerfile b/projects/fabric/Dockerfile new file mode 100644 index 000000000..a94454a29 --- /dev/null +++ b/projects/fabric/Dockerfile @@ -0,0 +1,20 @@ +# 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. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder-go +RUN git clone --depth 1 https://github.com/hyperledger/fabric +COPY build.sh persistence_fuzzer.go $SRC/ +WORKDIR $SRC/fabric diff --git a/projects/fabric/build.sh b/projects/fabric/build.sh new file mode 100644 index 000000000..8c6d09f27 --- /dev/null +++ b/projects/fabric/build.sh @@ -0,0 +1,19 @@ +#!/bin/bash -eu +# 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. +# +################################################################################ + +cp $SRC/persistence_fuzzer.go ./core/chaincode/persistence/mock/ +compile_go_fuzzer github.com/hyperledger/fabric/core/chaincode/persistence/mock FuzzPersistence fuzz_persistence diff --git a/projects/fabric/persistence_fuzzer.go b/projects/fabric/persistence_fuzzer.go new file mode 100644 index 000000000..98774a21c --- /dev/null +++ b/projects/fabric/persistence_fuzzer.go @@ -0,0 +1,29 @@ +// 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 mock + +import ( + "github.com/hyperledger/fabric/core/chaincode/persistence" + tm "github.com/stretchr/testify/mock" +) + +func FuzzPersistence(data []byte) int { + var ccpp persistence.ChaincodePackageParser + mockMetaProvider := &MetadataProvider{} + mockMetaProvider.On("GetDBArtifacts", tm.Anything).Return([]byte("DB artefacts"), nil) + ccpp.MetadataProvider = mockMetaProvider + _, _ = ccpp.Parse(data) + return 1 +} diff --git a/projects/fabric/project.yaml b/projects/fabric/project.yaml new file mode 100644 index 000000000..dc9317dce --- /dev/null +++ b/projects/fabric/project.yaml @@ -0,0 +1,13 @@ +homepage: "https://www.hyperledger.org" +main_repo: "https://github.com/hyperledger/fabric" +primary_contact: "ale.linux@sopit.net" +auto_ccs: + - "gari.r.singh@gmail.com" +vendor_ccs: + - "adam@adalogics.com" + - "david@adalogics.com" +language: go +fuzzing_engines: + - libfuzzer +sanitizers: + - address