mirror of https://github.com/google/oss-fuzz.git
decorator: initial integration (#7998)
* decorator: initial integration Create fuzzers * decorator: initial integtaion Fix fuzzer
This commit is contained in:
parent
3bed5727dd
commit
a8d6f1e9d4
|
@ -0,0 +1,22 @@
|
|||
# Copyright 2022 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-python
|
||||
|
||||
RUN git clone https://github.com/micheles/decorator
|
||||
WORKDIR decorator
|
||||
|
||||
COPY build.sh fuzz_*.py $SRC/
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash -eu
|
||||
# Copyright 2022 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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# Build and install project (using current CFLAGS, CXXFLAGS).
|
||||
pip3 install --upgrade pip
|
||||
pip3 install .
|
||||
|
||||
for fuzzer in $(find $SRC -name 'fuzz_*.py'); do
|
||||
compile_python_fuzzer $fuzzer
|
||||
done
|
|
@ -0,0 +1,62 @@
|
|||
#!/usr/bin/python3
|
||||
# Copyright 2022 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.
|
||||
|
||||
import atheris
|
||||
import sys
|
||||
import random
|
||||
with atheris.instrument_imports():
|
||||
from decorator import *
|
||||
|
||||
def TestInput(data):
|
||||
fdp = atheris.FuzzedDataProvider(data)
|
||||
|
||||
@decorator
|
||||
def dummy_decorator(func, dummy=1, *args, **kw):
|
||||
result = func(*args, **kw)
|
||||
|
||||
@decoratorx
|
||||
def dummy_decoratorx(func, *args, **kw):
|
||||
result = func(*args, **kw)
|
||||
|
||||
def dummy_decorate(func, dummy=1, *args, **kw):
|
||||
result = func(*args, **kw)
|
||||
|
||||
@dummy_decorator(dummy=fdp.ConsumeInt(8))
|
||||
def func1(dummy):
|
||||
pass
|
||||
|
||||
@dummy_decoratorx
|
||||
def func2(dummy):
|
||||
pass
|
||||
|
||||
def func3(dummy):
|
||||
pass
|
||||
|
||||
choice = fdp.ConsumeIntInRange(1,3)
|
||||
|
||||
if choice == 1:
|
||||
func1(fdp.ConsumeBytes(fdp.ConsumeIntInRange(1,1000)))
|
||||
if choice == 2:
|
||||
func2(fdp.ConsumeBytes(fdp.ConsumeIntInRange(1,1000)))
|
||||
if choice == 3:
|
||||
decorate(func3,dummy_decorate,fdp.ConsumeInt(fdp.ConsumeIntInRange(1,1000)))
|
||||
func3(fdp.ConsumeBytes(10))
|
||||
|
||||
def main():
|
||||
atheris.Setup(sys.argv, TestInput, enable_python_coverage=True)
|
||||
atheris.Fuzz()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/python3
|
||||
# Copyright 2022 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.
|
||||
|
||||
import atheris
|
||||
import sys
|
||||
import random
|
||||
with atheris.instrument_imports():
|
||||
from decorator import *
|
||||
|
||||
def base_func(*args, **kw):
|
||||
pass
|
||||
|
||||
def TestInput(data):
|
||||
fdp = atheris.FuzzedDataProvider(data)
|
||||
|
||||
try:
|
||||
FunctionMaker.create(
|
||||
"f%s(%s)"%(fdp.ConsumeString(20),fdp.ConsumeString(20)),
|
||||
"base_func()",
|
||||
dict(f=base_func),
|
||||
addsource=fdp.ConsumeBool()
|
||||
)
|
||||
except Exception as e:
|
||||
if "Error in generated code" not in str(e):
|
||||
raise e
|
||||
|
||||
def main():
|
||||
atheris.Setup(sys.argv, TestInput, enable_python_coverage=True)
|
||||
atheris.Fuzz()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,12 @@
|
|||
fuzzing_engines:
|
||||
- libfuzzer
|
||||
homepage: https://github.com/micheles/decorator
|
||||
language: python
|
||||
main_repo: https://github.com/micheles/decorator
|
||||
sanitizers:
|
||||
- address
|
||||
- undefined
|
||||
vendor_ccs:
|
||||
- david@adalogics.com
|
||||
- adam@adalogics.com
|
||||
- arthur.chan@adalogics.com
|
Loading…
Reference in New Issue