Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mat2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
jvoisin
mat2
Commits
48680b98
Commit
48680b98
authored
3 years ago
by
Julien (jvoisin) Voisin
Browse files
Options
Downloads
Patches
Plain Diff
Add a fuzzer based on atheris
parent
d555a02c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#72455
failed
3 years ago
Stage: linting
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/fuzz.py
+54
-0
54 additions, 0 deletions
tests/fuzz.py
with
54 additions
and
0 deletions
tests/fuzz.py
0 → 100644
+
54
−
0
View file @
48680b98
import
mimetypes
import
os
import
sys
sys
.
path
.
append
(
'
..
'
)
import
atheris
with
atheris
.
instrument_imports
(
enable_loader_override
=
False
):
from
libmat2
import
parser_factory
,
UNSUPPORTED_EXTENSIONS
extensions
=
set
()
for
parser
in
parser_factory
.
_get_parsers
():
# type: ignore
for
mtype
in
parser
.
mimetypes
:
if
mtype
.
startswith
(
'
video
'
):
continue
if
'
aif
'
in
mtype
:
continue
if
'
wav
'
in
mtype
:
continue
if
'
gif
'
in
mtype
:
continue
if
'
aifc
'
in
mtype
:
continue
for
extension
in
mimetypes
.
guess_all_extensions
(
mtype
):
if
extension
not
in
UNSUPPORTED_EXTENSIONS
:
extensions
.
add
(
extension
)
extensions
=
list
(
extensions
)
def
TestOneInput
(
data
):
fdp
=
atheris
.
FuzzedDataProvider
(
data
)
extension
=
fdp
.
PickValueInList
(
extensions
)
data
=
fdp
.
ConsumeBytes
(
sys
.
maxsize
)
fname
=
'
/tmp/mat2_fuzz
'
+
extension
with
open
(
fname
,
'
wb
'
)
as
f
:
f
.
write
(
data
)
try
:
p
,
_
=
parser_factory
.
get_parser
(
fname
)
if
p
:
p
.
sandbox
=
False
p
.
get_meta
()
p
.
remove_all
()
p
,
_
=
parser_factory
.
get_parser
(
fname
)
p
.
get_meta
()
except
ValueError
:
pass
os
.
remove
(
fname
)
atheris
.
Setup
(
sys
.
argv
,
TestOneInput
)
atheris
.
Fuzz
()
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