swagger_fuzzer.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:swagger-fuzzer 作者: Lothiraldan 项目源码 文件源码
def do(settings):
    PARSED_HOST = urlparse(settings.spec_url)

    swagger_spec = requests.get(settings.spec_url)
    swagger_spec.raise_for_status()
    SPEC = swagger_spec.json()

    validator = get_validator(SPEC, settings.spec_url)
    validator.validate_spec(swagger_spec.json(), settings.spec_url)

    SPEC_HOST = urlunparse(list(PARSED_HOST)[:2] + [SPEC['basePath']] + ['', '', ''])

    s = requests.Session()

    @given(data())
    @hsettings(max_examples=settings.iterations)
    def swagger_fuzzer(data):
        request = get_request(data, SPEC, SPEC_HOST)
        note("Curl command: {}".format(to_curl_command(request)))

        result = s.send(request)

        for validator in VALIDATORS:
            validator(SPEC, request, result, settings)

    # Call the function
    swagger_fuzzer()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号