Skip to main content
Homepage
Explore
Search or go to…
/
Register
Sign in
Explore
Primary navigation
Project
T
Transfer.Sh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
mirror
Transfer.Sh
Commits
8c5ef8f2
Commit
8c5ef8f2
authored
Aug 31, 2019
by
Andrea Spacca
Browse files
Options
Downloads
Patches
Plain Diff
Fuzz local storage test
parent
b40e9d1f
Loading
Loading
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.travis.yml
+2
-2
2 additions, 2 deletions
.travis.yml
fuzzit.sh
+1
-3
1 addition, 3 deletions
fuzzit.sh
server/server_fuzz.go
+59
-97
59 additions, 97 deletions
server/server_fuzz.go
with
62 additions
and
102 deletions
.travis.yml
+
2
−
2
View file @
8c5ef8f2
...
@@ -29,7 +29,7 @@ jobs:
...
@@ -29,7 +29,7 @@ jobs:
dist
:
bionic
dist
:
bionic
script
:
./fuzzit.sh local-regression
script
:
./fuzzit.sh local-regression
-
stage
:
Fuzz
-
stage
:
Fuzz
if
:
branch =
master
AND type IN (push)
if
:
branch =
fuzz
AND type IN (push)
go
:
1.12.x
go
:
1.12.x
dist
:
bionic
dist
:
bionic
script
:
./fuzzit.sh fuzzing
script
:
./fuzzit.sh fuzzing
...
@@ -53,5 +53,5 @@ deploy:
...
@@ -53,5 +53,5 @@ deploy:
skip_cleanup
:
true
skip_cleanup
:
true
on
:
on
:
tags
:
true
tags
:
true
go
:
tip
go
:
1.12.x
overwrite
:
true
overwrite
:
true
This diff is collapsed.
Click to expand it.
fuzzit.sh
+
1
−
3
View file @
8c5ef8f2
...
@@ -30,6 +30,4 @@ function fuzz {
...
@@ -30,6 +30,4 @@ function fuzz {
clang
-fsanitize
=
fuzzer fuzzer.a
-o
fuzzer
clang
-fsanitize
=
fuzzer fuzzer.a
-o
fuzzer
./fuzzit create job
--type
$TYPE
$NAME
/
$TARGET
fuzzer
./fuzzit create job
--type
$TYPE
$NAME
/
$TARGET
fuzzer
}
}
fuzz Profile profile
fuzz LocalStorage local-storage
fuzz HTTP http
fuzz HTTPS https
This diff is collapsed.
Click to expand it.
server/server_fuzz.go
+
59
−
97
View file @
8c5ef8f2
...
@@ -3,126 +3,88 @@
...
@@ -3,126 +3,88 @@
package
server
package
server
import
(
import
(
"
crypto/tl
s"
"
byte
s"
"io
/ioutil
"
"io"
"
net
"
"
math/rand
"
"
strings
"
"
reflect
"
)
)
// FuzzProfile tests the profile server.
const
applicationOctetStream
=
"application/octet-stream"
func
FuzzProfile
(
fuzz
[]
byte
)
int
{
if
len
(
fuzz
)
==
0
{
// FuzzLocalStorage tests the Local Storage.
func
FuzzLocalStorage
(
fuzz
[]
byte
)
int
{
var
fuzzLength
=
uint64
(
len
(
fuzz
))
if
fuzzLength
==
0
{
return
-
1
return
-
1
}
}
server
,
err
:=
New
(
EnableProfiler
())
if
err
!=
nil
{
storage
,
err
:=
NewLocalStorage
(
"/tmp"
,
nil
)
panic
(
err
.
Error
())
}
server
.
Run
()
defer
server
.
profileListener
.
Close
()
defer
server
.
httpListener
.
Close
()
address
:=
server
.
profileListener
.
Addr
connection
,
err
:=
net
.
Dial
(
"tcp"
,
address
)
if
err
!=
nil
{
panic
(
err
.
Error
())
}
_
,
err
=
connection
.
Write
(
fuzz
)
if
err
!=
nil
{
return
0
}
response
,
err
:=
ioutil
.
ReadAll
(
connection
)
if
err
!=
nil
{
return
0
}
err
=
connection
.
Close
()
if
err
!=
nil
{
if
err
!=
nil
{
return
0
panic
(
"unable to create local storage"
)
}
fields
:=
strings
.
Fields
(
string
(
response
))
if
len
(
fields
)
<
2
{
panic
(
"invalid HTTP response"
)
}
code
:=
fields
[
1
]
if
code
==
"500"
{
panic
(
"server panicked"
)
}
return
1
}
}
// FuzzHTTP tests the HTTP server.
token
:=
Encode
(
10000000
+
int64
(
rand
.
Intn
(
1000000000
)))
func
FuzzHTTP
(
fuzz
[]
byte
)
int
{
filename
:=
Encode
(
10000000
+
int64
(
rand
.
Intn
(
1000000000
)))
+
".bin"
if
len
(
fuzz
)
==
0
{
return
-
1
input
:=
bytes
.
NewReader
(
fuzz
)
}
err
=
storage
.
Put
(
token
,
filename
,
input
,
applicationOctetStream
,
fuzzLength
)
server
,
err
:=
New
(
Listener
(
"localhost"
))
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
.
Error
()
)
panic
(
"unable to save file"
)
}
}
server
.
Run
()
defer
server
.
httpListener
.
Close
()
contentType
,
contentLength
,
err
:=
storage
.
Head
(
token
,
filename
)
address
:=
server
.
httpListener
.
Addr
connection
,
err
:=
net
.
Dial
(
"tcp"
,
address
)
if
err
!=
nil
{
if
err
!=
nil
{
panic
(
err
.
Error
()
)
panic
(
"not visible through head"
)
}
}
_
,
err
=
connection
.
Write
(
fuzz
)
if
err
!=
nil
{
if
contentType
!=
applicationOctetStream
{
return
0
panic
(
"incorrect content type"
)
}
}
response
,
err
:=
ioutil
.
ReadAll
(
connection
)
if
err
!=
nil
{
if
contentLength
!=
fuzzLength
{
return
0
panic
(
"incorrect content length"
)
}
}
err
=
connection
.
Close
()
output
,
contentType
,
contentLength
,
err
:=
storage
.
Get
(
token
,
filename
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
panic
(
"not visible through get"
)
}
}
fields
:=
strings
.
Fields
(
string
(
response
))
if
len
(
fields
)
<
2
{
if
contentType
!=
applicationOctetStream
{
panic
(
"invalid HTTP response"
)
panic
(
"incorrect content type"
)
}
code
:=
fields
[
1
]
if
code
==
"500"
{
panic
(
"server panicked"
)
}
}
return
1
if
contentLength
!=
fuzzLength
{
panic
(
"incorrect content length"
)
}
}
// FuzzHTTPS tests the HTTPS server.
var
length
uint64
func
FuzzHTTPS
(
fuzz
[]
byte
)
int
{
b
:=
make
([]
byte
,
len
(
fuzz
))
if
len
(
fuzz
)
==
0
{
for
{
return
-
1
n
,
err
:=
output
.
Read
(
b
)
length
+=
uint64
(
n
)
if
err
==
io
.
EOF
{
break
}
}
server
,
err
:=
New
(
TLSListener
(
"localhost"
,
true
))
if
err
!=
nil
{
panic
(
err
.
Error
())
}
}
server
.
Run
()
defer
server
.
httpsListener
.
Close
()
if
!
reflect
.
DeepEqual
(
b
,
fuzz
)
{
address
:=
server
.
httpsListener
.
Addr
panic
(
"incorrect content body"
)
connection
,
err
:=
tls
.
Dial
(
"tcp"
,
address
,
nil
)
if
err
!=
nil
{
panic
(
err
.
Error
())
}
_
,
err
=
connection
.
Write
(
fuzz
)
if
err
!=
nil
{
return
0
}
}
response
,
err
:=
ioutil
.
ReadAll
(
connection
)
if
err
!=
nil
{
if
length
!=
fuzzLength
{
return
0
panic
(
"incorrect content length"
)
}
}
err
=
connection
.
Close
()
err
=
storage
.
Delete
(
token
,
filename
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
panic
(
"unable to delete file"
)
}
fields
:=
strings
.
Fields
(
string
(
response
))
if
len
(
fields
)
<
2
{
panic
(
"invalid HTTP response"
)
}
}
code
:=
fields
[
1
]
if
code
==
"500"
{
_
,
_
,
err
=
storage
.
Head
(
token
,
filename
)
panic
(
"server panicked"
)
if
!
storage
.
IsNotExist
(
err
)
{
panic
(
"file not deleted"
)
}
}
return
1
return
1
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment