aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatena cyber <35799796+catenacyber@users.noreply.github.com>2021-03-16 14:33:58 +0100
committerGitHub <noreply@github.com>2021-03-16 06:33:58 -0700
commit8c5e3f437e45c4b6297fbce9da6506abe9029a9a (patch)
tree3e962c02e7f3bce951ca085126e88d07a91d4b1c
parentcf274aba469e488358dfc24691269030ba0dd797 (diff)
downloadoss-fuzz-8c5e3f437e45c4b6297fbce9da6506abe9029a9a.tar.gz
Adds golang snappy project (#5351)
-rw-r--r--projects/go-snappy/Dockerfile22
-rwxr-xr-xprojects/go-snappy/build.sh19
-rw-r--r--projects/go-snappy/fuzz.go27
-rw-r--r--projects/go-snappy/project.yaml10
4 files changed, 78 insertions, 0 deletions
diff --git a/projects/go-snappy/Dockerfile b/projects/go-snappy/Dockerfile
new file mode 100644
index 000000000..d6d08afd0
--- /dev/null
+++ b/projects/go-snappy/Dockerfile
@@ -0,0 +1,22 @@
+# Copyright 2021 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
+RUN git clone --depth 1 https://github.com/golang/snappy
+
+COPY build.sh $SRC/
+COPY fuzz.go $SRC/snappy
+WORKDIR $SRC/snappy
diff --git a/projects/go-snappy/build.sh b/projects/go-snappy/build.sh
new file mode 100755
index 000000000..805eefb7a
--- /dev/null
+++ b/projects/go-snappy/build.sh
@@ -0,0 +1,19 @@
+#!/bin/bash -eu
+# Copyright 2021 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.
+#
+################################################################################
+
+compile_go_fuzzer . FuzzRoundTrip fuzz_roundtrip gofuzz
+compile_go_fuzzer . FuzzDecode fuzz_decode gofuzz
diff --git a/projects/go-snappy/fuzz.go b/projects/go-snappy/fuzz.go
new file mode 100644
index 000000000..e3c211823
--- /dev/null
+++ b/projects/go-snappy/fuzz.go
@@ -0,0 +1,27 @@
+// +build gofuzz
+
+package snappy
+
+import (
+ "bytes"
+)
+
+func FuzzRoundTrip(data []byte) int {
+ encoded := Encode(nil, data)
+ decoded, err := Decode(nil, encoded)
+ if err != nil {
+ panic("Error decoding snappy-encoded")
+ }
+ if !bytes.Equal(data, decoded) {
+ panic("Different result on roundtrip encode/decode")
+ }
+ return 1
+}
+
+func FuzzDecode(data []byte) int {
+ _, err := Decode(nil, data)
+ if err != nil {
+ return 0
+ }
+ return 1
+}
diff --git a/projects/go-snappy/project.yaml b/projects/go-snappy/project.yaml
new file mode 100644
index 000000000..8a732ccb3
--- /dev/null
+++ b/projects/go-snappy/project.yaml
@@ -0,0 +1,10 @@
+homepage: "https://github.com/golang/snappy"
+primary_contact: "nigeltao@golang.org"
+auto_ccs:
+ - "p.antoine@catenacyber.fr"
+language: go
+fuzzing_engines:
+ - libfuzzer
+sanitizers:
+ - address
+main_repo: 'https://github.com/golang/snappy'