c56bef871b
Sync docs with Docusaurus / sync (push) Waiting to run
Tests / Check if changed (push) Waiting to run
Tests / format (push) Blocked by required conditions
Tests / check-imports (push) Blocked by required conditions
Tests / Unit / macos-latest (push) Blocked by required conditions
Tests / Unit / ubuntu-latest (push) Blocked by required conditions
Tests / Unit / windows-latest (push) Blocked by required conditions
Tests / mypy (push) Blocked by required conditions
Tests / Integration / ubuntu-latest (push) Blocked by required conditions
Tests / Integration / macos-latest (push) Blocked by required conditions
Tests / Integration / windows-latest (push) Blocked by required conditions
Tests / notify-slack-on-failure (push) Blocked by required conditions
Tests / Mark tests as completed (push) Blocked by required conditions
Docker image release / Build base image (push) Waiting to run
CodeQL / Analyze (python) (push) Has been cancelled
Update Platform Components Table / update (push) Has been cancelled
47 lines
1.6 KiB
Python
47 lines
1.6 KiB
Python
# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
"""Fuzz target for ``Pipeline.loads`` — deserializing untrusted serialized pipelines.
|
|
|
|
Loading a serialized pipeline is an explicit attack surface (see SECURITY.md), so this
|
|
target feeds arbitrary fuzzer bytes through the YAML unmarshaller and ``from_dict``.
|
|
"""
|
|
|
|
import sys
|
|
|
|
import atheris
|
|
|
|
with atheris.instrument_imports():
|
|
from haystack import Pipeline
|
|
from haystack.core.errors import DeserializationError, PipelineError
|
|
|
|
# Exceptions that are a normal reaction to malformed input. Anything else — a crash,
|
|
# unbounded recursion, a hang, or an unexpected exception type — is a genuine finding.
|
|
_EXPECTED = (DeserializationError, PipelineError, ValueError, TypeError, KeyError)
|
|
|
|
# Known finding, deferred to a separate fix: non-dict YAML documents (e.g. an empty
|
|
# string, a bare scalar, or a list) unmarshal cleanly and then make ``from_dict`` raise
|
|
# a raw ``AttributeError`` from ``data.get(...)`` instead of a ``DeserializationError``.
|
|
# Tolerated here so the target builds and fuzzes; remove once ``from_dict`` validates
|
|
# its input type and this collapses back into ``DeserializationError``.
|
|
_KNOWN_BUGS = (AttributeError,)
|
|
|
|
|
|
def TestOneInput(data: bytes) -> None:
|
|
"""Feed one fuzzer-generated input to ``Pipeline.loads`` as a YAML document."""
|
|
try:
|
|
Pipeline.loads(data)
|
|
except _EXPECTED + _KNOWN_BUGS:
|
|
pass
|
|
|
|
|
|
def main() -> None:
|
|
"""Set up and run the Atheris fuzzing loop."""
|
|
atheris.Setup(sys.argv, TestOneInput)
|
|
atheris.Fuzz()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|