Skip to content

Commit d32d6cd

Browse files
committed
[fuzzing] cifuzz, update fuzzers, bug fix
Signed-off-by: Arjun Singh <[email protected]>
1 parent ced662e commit d32d6cd

File tree

4 files changed

+74
-14
lines changed

4 files changed

+74
-14
lines changed

.github/workflows/cifuzz.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CIFuzz
2+
on: [pull_request]
3+
permissions: {}
4+
jobs:
5+
Fuzzing:
6+
runs-on: ubuntu-latest
7+
permissions:
8+
security-events: write
9+
steps:
10+
- name: Build Fuzzers
11+
id: build
12+
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
13+
with:
14+
oss-fuzz-project-name: 'go-git'
15+
language: go
16+
- name: Run Fuzzers
17+
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
18+
with:
19+
oss-fuzz-project-name: 'go-git'
20+
language: go
21+
fuzz-seconds: 300
22+
output-sarif: true
23+
- name: Upload Crash
24+
uses: actions/upload-artifact@v3
25+
if: failure() && steps.build.outcome == 'success'
26+
with:
27+
name: artifacts
28+
path: ./out/artifacts
29+
- name: Upload Sarif
30+
if: always() && steps.build.outcome == 'success'
31+
uses: github/codeql-action/upload-sarif@v2
32+
with:
33+
# Path to SARIF file relative to the root of the repository
34+
sarif_file: cifuzz-sarif/results.sarif
35+
checkout_path: cifuzz-sarif

Makefile

+4-5
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,9 @@ clean:
4545

4646
fuzz:
4747
@go test -fuzz=FuzzParser $(PWD)/internal/revision
48-
@go test -fuzz=FuzzParseSignedByte $(PWD)/plumbing/object
49-
@go test -fuzz=FuzzDecode $(PWD)/plumbing/object
50-
@go test -fuzz=FuzzNewEndpoint $(PWD)/plumbing/transport
51-
@go test -fuzz=FuzzDecoder $(PWD)/plumbing/protocol/packp
5248
@go test -fuzz=FuzzDecoder $(PWD)/plumbing/format/config
5349
@go test -fuzz=FuzzPatchDelta $(PWD)/plumbing/format/packfile
54-
@go test -fuzz=FuzzDecodeFile $(PWD)/utils/merkletrie/internal/fsnoder
50+
@go test -fuzz=FuzzParseSignedBytes $(PWD)/plumbing/object
51+
@go test -fuzz=FuzzDecode $(PWD)/plumbing/object
52+
@go test -fuzz=FuzzDecoder $(PWD)/plumbing/protocol/packp
53+
@go test -fuzz=FuzzNewEndpoint $(PWD)/plumbing/transport

oss-fuzz.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash -eu
2+
# Copyright 2023 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
################################################################################
17+
18+
19+
go mod download
20+
go get github.com/AdamKorcz/go-118-fuzz-build/testing
21+
22+
if [ "$SANITIZER" != "coverage" ]; then
23+
sed -i '/func (s \*DecoderSuite) TestDecode(/,/^}/ s/^/\/\//' plumbing/format/config/decoder_test.go
24+
sed -n '35,$p' plumbing/format/packfile/common_test.go >> plumbing/format/packfile/delta_test.go
25+
sed -n '20,53p' plumbing/object/object_test.go >> plumbing/object/tree_test.go
26+
sed -i 's|func Test|// func Test|' plumbing/transport/common_test.go
27+
fi
28+
29+
compile_native_go_fuzzer $(pwd)/internal/revision FuzzParser fuzz_parser
30+
compile_native_go_fuzzer $(pwd)/plumbing/format/config FuzzDecoder fuzz_decoder_config
31+
compile_native_go_fuzzer $(pwd)/plumbing/format/packfile FuzzPatchDelta fuzz_patch_delta
32+
compile_native_go_fuzzer $(pwd)/plumbing/object FuzzParseSignedBytes fuzz_parse_signed_bytes
33+
compile_native_go_fuzzer $(pwd)/plumbing/object FuzzDecode fuzz_decode
34+
compile_native_go_fuzzer $(pwd)/plumbing/protocol/packp FuzzDecoder fuzz_decoder_packp
35+
compile_native_go_fuzzer $(pwd)/plumbing/transport FuzzNewEndpoint fuzz_new_endpoint

utils/merkletrie/internal/fsnoder/new_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package fsnoder
22

33
import (
4-
"testing"
5-
64
"github.com/go-git/go-git/v5/utils/merkletrie/noder"
75

86
. "gopkg.in/check.v1"
@@ -354,10 +352,3 @@ func (s *FSNoderSuite) TestHashEqual(c *C) {
354352
c.Assert(HashEqual(t3, t1), Equals, false)
355353
c.Assert(HashEqual(t1, t3), Equals, false)
356354
}
357-
358-
func FuzzDecodeFile(f *testing.F) {
359-
360-
f.Fuzz(func(t *testing.T, input []byte) {
361-
decodeFile(input)
362-
})
363-
}

0 commit comments

Comments
 (0)