Skip to content

Commit

Permalink
Merge pull request #49 from Yelp/filter-out-hypothesis-warnings
Browse files Browse the repository at this point in the history
Filter out hypothesis warnings
  • Loading branch information
domanchi authored Apr 1, 2020
2 parents ff7d582 + dbe33c0 commit 561517c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fuzz_lightyear/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 8 additions & 0 deletions fuzz_lightyear/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions fuzz_lightyear/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 561517c

Please sign in to comment.