From dbe33c04c604c2d53b421d8603fbd6fbd1f78ed8 Mon Sep 17 00:00:00 2001 From: Aaron Loo Date: Wed, 1 Apr 2020 08:09:05 -0700 Subject: [PATCH] filtering out hypothesis warnings --- fuzz_lightyear/generator.py | 2 ++ fuzz_lightyear/main.py | 8 ++++++++ fuzz_lightyear/request.py | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/fuzz_lightyear/generator.py b/fuzz_lightyear/generator.py index a604d9c..37cd1c9 100644 --- a/fuzz_lightyear/generator.py +++ b/fuzz_lightyear/generator.py @@ -108,9 +108,11 @@ def _add_request_to_sequence( neighbor_requests = request_graph[request.operation_id] # We have no idea whether a request should consume an existing # resource, use a factory, or fuzz a value. + # # However, we want to move towards building sequences of requests # that only consume resources created by previous requests (the # algorithm described in the original Microsoft paper) + # # Therefore, add the request to the sequence if it shares an edge with # ANY of the requests in the sequence- leaving room for factory # usage, but still keeping in line with the spirit of RESTler. diff --git a/fuzz_lightyear/main.py b/fuzz_lightyear/main.py index d5a78cd..3cfeded 100644 --- a/fuzz_lightyear/main.py +++ b/fuzz_lightyear/main.py @@ -2,12 +2,14 @@ from typing import Dict from typing import List from typing import Optional +import warnings import requests import simplejson import yaml from bravado.client import SwaggerClient from bravado.exception import HTTPError +from hypothesis.errors import NonInteractiveExampleWarning from swagger_spec_validator.common import SwaggerValidationError # type: ignore from .datastore import get_setup_fixtures @@ -27,6 +29,12 @@ def main(argv: Optional[List[str]] = None) -> int: if args.verbose: # pragma: no cover log.set_debug_level(args.verbose) + # NOTE: Hypothesis warns us against using `.example()` (which we leverage + # during the fuzzing process), and to use `@given` instead. However, we + # are not using hypothesis in a conventional manner, and therefore this + # warning does not apply to us. + warnings.filterwarnings('ignore', category=NonInteractiveExampleWarning) + # Setup message = setup_client(args.url, args.schema) if message: diff --git a/fuzz_lightyear/request.py b/fuzz_lightyear/request.py index 20b5676..244ccb7 100644 --- a/fuzz_lightyear/request.py +++ b/fuzz_lightyear/request.py @@ -147,6 +147,15 @@ def send( self.fuzzed_input = self.fuzz(data) self.apply_post_fuzz_hooks(self.fuzzed_input, rerun=False) else: + # On the first run, self.fuzzed_input will be initialized + # to a dictionary. Therefore, if this request is sent again, + # this code path will execute, and we will want to rerun + # the applicable post_fuzz hooks. + # + # TODO: I wonder whether we have to distinguish between + # explicitly initialized `fuzzed_input`, and *actually* fuzzed + # input, given that the former case will technically be the + # *first* time the post_fuzz hook is run. self.apply_post_fuzz_hooks(self.fuzzed_input, rerun=True) if not auth: