aboutsummaryrefslogtreecommitdiffhomepage
path: root/projects/aiohttp
diff options
context:
space:
mode:
authorGravatar DavidKorczynski <david@adalogics.com>2022-05-25 14:08:22 +0100
committerGravatar GitHub <noreply@github.com>2022-05-25 14:08:22 +0100
commit379868d7a99bd82611939e5c4e3080ef7ff795f3 (patch)
treedc073ea2bcebeaf270b37a7c889bcbceef061353 /projects/aiohttp
parent83b5bfcae81e228a533cb424086e98aef779940b (diff)
aiohttp: enable analysis of Pure python code (#7761)
This is in addition to the existing fuzzers that analyse compiled code.
Diffstat (limited to 'projects/aiohttp')
-rwxr-xr-xprojects/aiohttp/build.sh7
-rw-r--r--projects/aiohttp/fuzz_http_parser.py6
-rw-r--r--projects/aiohttp/fuzz_http_payload_parser.py4
3 files changed, 17 insertions, 0 deletions
diff --git a/projects/aiohttp/build.sh b/projects/aiohttp/build.sh
index 17023bba..b75f0cdc 100755
--- a/projects/aiohttp/build.sh
+++ b/projects/aiohttp/build.sh
@@ -22,6 +22,13 @@ pip3 install -r requirements/dev.txt
pre-commit install
make install-dev
+# Duplicate fuzzers to use Pure python code (in addition
+# to the existing C-compiled code).
+cp fuzz_http_parser.py fuzz_http_parser_pure_python.py
+sed -i 's/AIOHTTP_VAL=0/AIOHTTP_VAL=1/g' fuzz_http_parser_pure_python.py
+cp fuzz_http_payload_parser.py fuzz_http_payload_parser_pure_python.py
+sed -i 's/AIOHTTP_VAL=0/AIOHTTP_VAL=1/g' fuzz_http_payload_parser_pure_python.py
+
# Build fuzzers in $OUT.
for fuzzer in $(find $SRC -name 'fuzz_*.py'); do
compile_python_fuzzer $fuzzer
diff --git a/projects/aiohttp/fuzz_http_parser.py b/projects/aiohttp/fuzz_http_parser.py
index 93c078ab..2d0a3057 100644
--- a/projects/aiohttp/fuzz_http_parser.py
+++ b/projects/aiohttp/fuzz_http_parser.py
@@ -13,6 +13,11 @@
# 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 os
+AIOHTTP_VAL=0
+os.environ["AIOHTTP_NO_EXTENSIONS"] = str(AIOHTTP_VAL)
+
import sys
import atheris
@@ -30,6 +35,7 @@ def TestOneInput(data):
h_p = aiohttp.http_parser.HttpRequestParser(pr, loop, 32768)
try:
h_p.feed_data(data)
+ h_p.feed_eof()
except aiohttp.http_exceptions.HttpProcessingError:
None
diff --git a/projects/aiohttp/fuzz_http_payload_parser.py b/projects/aiohttp/fuzz_http_payload_parser.py
index f48b2f77..2be93446 100644
--- a/projects/aiohttp/fuzz_http_payload_parser.py
+++ b/projects/aiohttp/fuzz_http_payload_parser.py
@@ -13,6 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import os
+AIOHTTP_VAL=0
+os.environ["AIOHTTP_NO_EXTENSIONS"] = str(AIOHTTP_VAL)
+
import sys
import atheris