aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile10
-rw-r--r--internal/revision/parser_test.go9
-rw-r--r--plumbing/format/config/decoder_test.go11
-rw-r--r--plumbing/format/packfile/delta_test.go12
-rw-r--r--plumbing/object/signature_test.go7
-rw-r--r--plumbing/object/tree_test.go17
-rw-r--r--plumbing/protocol/packp/uppackresp_test.go12
-rw-r--r--plumbing/transport/common_test.go7
-rw-r--r--utils/merkletrie/internal/fsnoder/new_test.go9
9 files changed, 94 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 66adc8c..6c62892 100644
--- a/Makefile
+++ b/Makefile
@@ -42,3 +42,13 @@ test-coverage:
clean:
rm -rf $(GIT_DIST_PATH)
+
+fuzz:
+ @go test -fuzz=FuzzParser $(PWD)/internal/revision
+ @go test -fuzz=FuzzParseSignedByte $(PWD)/plumbing/object
+ @go test -fuzz=FuzzDecode $(PWD)/plumbing/object
+ @go test -fuzz=FuzzNewEndpoint $(PWD)/plumbing/transport
+ @go test -fuzz=FuzzDecoder $(PWD)/plumbing/protocol/packp
+ @go test -fuzz=FuzzDecoder $(PWD)/plumbing/format/config
+ @go test -fuzz=FuzzPatchDelta $(PWD)/plumbing/format/packfile
+ @go test -fuzz=FuzzDecodeFile $(PWD)/utils/merkletrie/internal/fsnoder
diff --git a/internal/revision/parser_test.go b/internal/revision/parser_test.go
index 3a77b2f..1eb3861 100644
--- a/internal/revision/parser_test.go
+++ b/internal/revision/parser_test.go
@@ -3,6 +3,7 @@ package revision
import (
"bytes"
"regexp"
+ "testing"
"time"
. "gopkg.in/check.v1"
@@ -397,3 +398,11 @@ func (s *ParserSuite) TestParseRefWithInvalidName(c *C) {
c.Assert(err, DeepEquals, e)
}
}
+
+func FuzzParser(f *testing.F) {
+
+ f.Fuzz(func(t *testing.T, input string) {
+ parser := NewParser(bytes.NewBufferString(input))
+ parser.Parse()
+ })
+}
diff --git a/plumbing/format/config/decoder_test.go b/plumbing/format/config/decoder_test.go
index 0a8e92c..6283f5e 100644
--- a/plumbing/format/config/decoder_test.go
+++ b/plumbing/format/config/decoder_test.go
@@ -2,6 +2,7 @@ package config
import (
"bytes"
+ "testing"
. "gopkg.in/check.v1"
)
@@ -91,3 +92,13 @@ func decodeFails(c *C, text string) {
err := d.Decode(cfg)
c.Assert(err, NotNil)
}
+
+func FuzzDecoder(f *testing.F) {
+
+ f.Fuzz(func(t *testing.T, input []byte) {
+
+ d := NewDecoder(bytes.NewReader(input))
+ cfg := &Config{}
+ d.Decode(cfg)
+ })
+}
diff --git a/plumbing/format/packfile/delta_test.go b/plumbing/format/packfile/delta_test.go
index e8f5ea6..9417e55 100644
--- a/plumbing/format/packfile/delta_test.go
+++ b/plumbing/format/packfile/delta_test.go
@@ -4,6 +4,7 @@ import (
"bytes"
"io"
"math/rand"
+ "testing"
"github.com/go-git/go-git/v5/plumbing"
. "gopkg.in/check.v1"
@@ -176,3 +177,14 @@ func (s *DeltaSuite) TestMaxCopySizeDeltaReader(c *C) {
c.Assert(err, IsNil)
c.Assert(result, DeepEquals, targetBuf)
}
+
+func FuzzPatchDelta(f *testing.F) {
+
+ f.Fuzz(func(t *testing.T, input []byte) {
+
+ input_0 := input[:len(input)/2]
+ input_1 := input[len(input)/2:]
+
+ PatchDelta(input_0, input_1)
+ })
+}
diff --git a/plumbing/object/signature_test.go b/plumbing/object/signature_test.go
index 1bdb1d1..3b20cde 100644
--- a/plumbing/object/signature_test.go
+++ b/plumbing/object/signature_test.go
@@ -178,3 +178,10 @@ signed tag`),
})
}
}
+
+func FuzzParseSignedBytes(f *testing.F) {
+
+ f.Fuzz(func(t *testing.T, input []byte) {
+ parseSignedBytes(input)
+ })
+}
diff --git a/plumbing/object/tree_test.go b/plumbing/object/tree_test.go
index d9dad47..bb5fc7a 100644
--- a/plumbing/object/tree_test.go
+++ b/plumbing/object/tree_test.go
@@ -4,6 +4,7 @@ import (
"context"
"errors"
"io"
+ "testing"
fixtures "github.com/go-git/go-git-fixtures/v4"
"github.com/go-git/go-git/v5/plumbing"
@@ -1623,3 +1624,19 @@ func (s *TreeSuite) TestTreeDecodeReadBug(c *C) {
c.Assert(err, IsNil)
c.Assert(entriesEquals(obtained.Entries, expected.Entries), Equals, true)
}
+
+func FuzzDecode(f *testing.F) {
+
+ f.Fuzz(func(t *testing.T, input []byte) {
+
+ obj := &SortReadObject{
+ t: plumbing.TreeObject,
+ h: plumbing.ZeroHash,
+ cont: input,
+ sz: int64(len(input)),
+ }
+
+ newTree := &Tree{}
+ newTree.Decode(obj)
+ })
+}
diff --git a/plumbing/protocol/packp/uppackresp_test.go b/plumbing/protocol/packp/uppackresp_test.go
index 8fbf924..ec56507 100644
--- a/plumbing/protocol/packp/uppackresp_test.go
+++ b/plumbing/protocol/packp/uppackresp_test.go
@@ -3,6 +3,7 @@ package packp
import (
"bytes"
"io"
+ "testing"
"github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/protocol/packp/capability"
@@ -128,3 +129,14 @@ func (s *UploadPackResponseSuite) TestEncodeMultiACK(c *C) {
b := bytes.NewBuffer(nil)
c.Assert(res.Encode(b), NotNil)
}
+
+func FuzzDecoder(f *testing.F) {
+
+ f.Fuzz(func(t *testing.T, input []byte) {
+ req := NewUploadPackRequest()
+ res := NewUploadPackResponse(req)
+ defer res.Close()
+
+ res.Decode(io.NopCloser(bytes.NewReader(input)))
+ })
+}
diff --git a/plumbing/transport/common_test.go b/plumbing/transport/common_test.go
index d9f12ab..3efc555 100644
--- a/plumbing/transport/common_test.go
+++ b/plumbing/transport/common_test.go
@@ -210,3 +210,10 @@ func (s *SuiteCommon) TestNewEndpointIPv6(c *C) {
c.Assert(e.Host, Equals, "[::1]")
c.Assert(e.String(), Equals, "http://[::1]:8080/foo.git")
}
+
+func FuzzNewEndpoint(f *testing.F) {
+
+ f.Fuzz(func(t *testing.T, input string) {
+ NewEndpoint(input)
+ })
+}
diff --git a/utils/merkletrie/internal/fsnoder/new_test.go b/utils/merkletrie/internal/fsnoder/new_test.go
index ad069c7..52b3dc4 100644
--- a/utils/merkletrie/internal/fsnoder/new_test.go
+++ b/utils/merkletrie/internal/fsnoder/new_test.go
@@ -1,6 +1,8 @@
package fsnoder
import (
+ "testing"
+
"github.com/go-git/go-git/v5/utils/merkletrie/noder"
. "gopkg.in/check.v1"
@@ -352,3 +354,10 @@ func (s *FSNoderSuite) TestHashEqual(c *C) {
c.Assert(HashEqual(t3, t1), Equals, false)
c.Assert(HashEqual(t1, t3), Equals, false)
}
+
+func FuzzDecodeFile(f *testing.F) {
+
+ f.Fuzz(func(t *testing.T, input []byte) {
+ decodeFile(input)
+ })
+}