From 1838ec2ef7c5329144a37345d9f703752d884e88 Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Sat, 11 Feb 2023 11:27:06 +0000 Subject: [PATCH] pem: initial integration (#8140) Signed-off-by: David Korczynski --- projects/pem/Dockerfile | 22 ++++++++++++++++++++++ projects/pem/build.sh | 24 ++++++++++++++++++++++++ projects/pem/data.pem | 10 ++++++++++ projects/pem/fuzz_pem.py | 36 ++++++++++++++++++++++++++++++++++++ projects/pem/project.yaml | 12 ++++++++++++ 5 files changed, 104 insertions(+) create mode 100644 projects/pem/Dockerfile create mode 100755 projects/pem/build.sh create mode 100644 projects/pem/data.pem create mode 100644 projects/pem/fuzz_pem.py create mode 100644 projects/pem/project.yaml diff --git a/projects/pem/Dockerfile b/projects/pem/Dockerfile new file mode 100644 index 000000000..6b14f77c4 --- /dev/null +++ b/projects/pem/Dockerfile @@ -0,0 +1,22 @@ +# 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 make autoconf automake libtool +RUN pip3 install --upgrade pip && pip install twisted +RUN git clone --depth 1 https://github.com/hynek/pem +WORKDIR pem +COPY build.sh *.py *.pem $SRC/ diff --git a/projects/pem/build.sh b/projects/pem/build.sh new file mode 100755 index 000000000..2665e3437 --- /dev/null +++ b/projects/pem/build.sh @@ -0,0 +1,24 @@ +#!/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 + +zip -rj $OUT/fuzz_pem_seed_corpus.zip $SRC/data.pem diff --git a/projects/pem/data.pem b/projects/pem/data.pem new file mode 100644 index 000000000..4a1843217 --- /dev/null +++ b/projects/pem/data.pem @@ -0,0 +1,10 @@ +-----BEGIN CERTIFICATE----- +MIIBfDCCATagAwIBAgIJAK94OSlzVBsWMA0GCSqGSIb3DQEBBQUAMBYxFDASBgNV +BAMTC3BlbS5pbnZhbGlkMB4XDTEzMDcxNzE0NDAyMFoXDTIzMDcxNTE0NDAyMFow +FjEUMBIGA1UEAxMLcGVtLmludmFsaWQwTDANBgkqhkiG9w0BAQEFAAM7ADA4AjEA +vtIM2QADJDHcqxZugx7MULbenrNUFrmoMDfEaedYveWY3wBxOw642L4nFWxN/fwL +AgMBAAGjdzB1MB0GA1UdDgQWBBQ4O0ZSUfTA6C+Y+QZ3MpeMhysxYjBGBgNVHSME +PzA9gBQ4O0ZSUfTA6C+Y+QZ3MpeMhysxYqEapBgwFjEUMBIGA1UEAxMLcGVtLmlu +dmFsaWSCCQCveDkpc1QbFjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBQUAAzEA +XwKIF+Kf4OhcqbdQp253HG2KBt/WZwvNLo/bBlkrGYwfacbGuWT8nKJG70ujdKKf +-----END CERTIFICATE----- diff --git a/projects/pem/fuzz_pem.py b/projects/pem/fuzz_pem.py new file mode 100644 index 000000000..5bf406698 --- /dev/null +++ b/projects/pem/fuzz_pem.py @@ -0,0 +1,36 @@ +#!/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 os +import sys +import atheris + +import pem + +def TestOneInput(data): + certs = pem.parse(data) + if len(certs) == 0: + return + # Access properties + s1 = certs[0].sha1_hexdigest + +def main(): + atheris.instrument_all() + atheris.Setup(sys.argv, TestOneInput) + atheris.Fuzz() + + +if __name__ == "__main__": + main() diff --git a/projects/pem/project.yaml b/projects/pem/project.yaml new file mode 100644 index 000000000..fb3ea07c2 --- /dev/null +++ b/projects/pem/project.yaml @@ -0,0 +1,12 @@ +homepage: "https://github.com/hynek/pem" +language: python +main_repo: "https://github.com/hynek/pem" +fuzzing_engines: +- libfuzzer +sanitizers: +- address +- undefined +vendor_ccs: +- david@adalogics.com +- adam@adalogics.com +- arthur.chan@adalogics.com