-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fuzzer for frontend dockerfile parser
Signed-off-by: AdamKorcz <[email protected]>
- Loading branch information
Showing
4 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,9 @@ clean: FORCE | |
test: | ||
./hack/test integration gateway dockerfile | ||
|
||
fuzz: | ||
./hack/fuzz | ||
|
||
lint: | ||
./hack/lint | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM ubuntu:20.04 | ||
ENV DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update && apt-get upgrade -y | ||
RUN apt-get install wget git software-properties-common build-essential -y | ||
RUN wget https://golang.org/dl/go1.14.9.linux-amd64.tar.gz | ||
RUN tar -xvf go1.14.9.linux-amd64.tar.gz | ||
RUN mv go /usr/local | ||
|
||
RUN mkdir /root/src | ||
ENV GOPATH /root/go | ||
ENV GOROOT /usr/local/go | ||
ENV PATH $PATH:/usr/local/go/bin | ||
|
||
RUN go get github.com/moby/buildkit | ||
RUN go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build | ||
COPY fuzz.go /go/src/github.com/moby/buildkit/frontend/dockerfiles/parser/ | ||
RUN cd /go/src/github.com/moby/buildkit/frontend/dockerfiles/parser && $GOPATH/bin/go-fuzz-build && $GOPATH/bin/go-fuzz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
cp util/testutil/fuzz/fuzz.go hack/dockerfiles/ | ||
|
||
cd hack/dockerfiles && sudo docker build -f fuzz.Dockerfile . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package fuzz | ||
|
||
import ( | ||
"bytes" | ||
"github.com/moby/buildkit/frontend/dockerfile/parser" | ||
) | ||
|
||
func Fuzz(data []byte) int { | ||
_, err := parser.Parse(bytes.NewReader(data)) | ||
if err != nil { | ||
return 0 | ||
} | ||
return 1 | ||
} |