From fd267349ac7a5adf59fb0ac36c4b4ff50e6f78a5 Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Tue, 21 Feb 2023 11:49:43 +0000 Subject: [PATCH] nbclassic: initial integration (#9771) Signed-off-by: David Korczynski --- projects/nbclassic/Dockerfile | 20 ++++++++++++++++++ projects/nbclassic/build.sh | 20 ++++++++++++++++++ projects/nbclassic/fuzz_cell.py | 37 +++++++++++++++++++++++++++++++++ projects/nbclassic/project.yaml | 10 +++++++++ 4 files changed, 87 insertions(+) create mode 100644 projects/nbclassic/Dockerfile create mode 100644 projects/nbclassic/build.sh create mode 100644 projects/nbclassic/fuzz_cell.py create mode 100644 projects/nbclassic/project.yaml diff --git a/projects/nbclassic/Dockerfile b/projects/nbclassic/Dockerfile new file mode 100644 index 000000000..b1c8ca914 --- /dev/null +++ b/projects/nbclassic/Dockerfile @@ -0,0 +1,20 @@ +#!/usr/bin/python3 +# Copyright 2023 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 apt-get update && apt-get install -y npm libffi-dev +RUN pip3 install --upgrade pip cython notebook +RUN git clone https://github.com/jupyter/nbclassic nbclassic +COPY *.sh *py $SRC/ +WORKDIR $SRC/nbclassic diff --git a/projects/nbclassic/build.sh b/projects/nbclassic/build.sh new file mode 100644 index 000000000..83cdadf8c --- /dev/null +++ b/projects/nbclassic/build.sh @@ -0,0 +1,20 @@ +#!/bin/bash -eu +# Copyright 2023 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. +# +################################################################################ +pip3 install . +for fuzzer in $(find $SRC -name 'fuzz_*.py'); do + compile_python_fuzzer $fuzzer +done diff --git a/projects/nbclassic/fuzz_cell.py b/projects/nbclassic/fuzz_cell.py new file mode 100644 index 000000000..d610cd279 --- /dev/null +++ b/projects/nbclassic/fuzz_cell.py @@ -0,0 +1,37 @@ +#!/usr/bin/python3 +# Copyright 2023 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 sys +import atheris + +from nbclassic.bundler.tools import get_cell_reference_patterns +from nbformat.v4 import new_markdown_cell + + +@atheris.instrument_func +def TestOneInput(data): + fdp = atheris.FuzzedDataProvider(data) + new_cell = new_markdown_cell(fdp.ConsumeUnicodeNoSurrogates(4096)) + if new_cell != None: + get_cell_reference_patterns(new_cell) + + +def main(): + atheris.instrument_all() + atheris.Setup(sys.argv, TestOneInput) + atheris.Fuzz() + + +if __name__ == "__main__": + main() diff --git a/projects/nbclassic/project.yaml b/projects/nbclassic/project.yaml new file mode 100644 index 000000000..15f155fc8 --- /dev/null +++ b/projects/nbclassic/project.yaml @@ -0,0 +1,10 @@ +homepage: https://github.com/jupyter/nbclassic +main_repo: https://github.com/jupyter/nbclassic +language: python +fuzzing_engines: +- libfuzzer +sanitizers: +- address +- undefined +vendor_ccs: +- david@adalogics.com