Skip to content

Commit 7f80e47

Browse files
lobziikStranger6667
authored andcommitted
Add possibility to skip https ssl check for schemathesis
This commit adds new flag to the wafp cli - `--fuzzer-skip-ssl-verify` which tells fuzzeers to skip certs ferification. Also added possibility to disable certs verification on per target basis, for such purposes new field `fuzzer_skip_ssl_verify` was introduced in target context. After target run its value will be piped down to a fuzzer run function.
1 parent ff03d69 commit 7f80e47

File tree

14 files changed

+133
-22
lines changed

14 files changed

+133
-22
lines changed

src/wafp/__main__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class CliArguments(targets.cli.SharedCliArguments, fuzzers.cli.SharedCliArgument
1818

1919
build: bool
2020
output_dir: str
21+
fuzzer_skip_ssl_verify: bool
2122

2223
@classmethod
2324
def from_all_args(
@@ -39,6 +40,13 @@ def extend_parser(cls, parser: argparse.ArgumentParser, *, catalog: Optional[str
3940
parser.add_argument(
4041
"--build", action="store_true", required=False, default=False, help="Force building docker images"
4142
)
43+
parser.add_argument(
44+
"--fuzzer-skip-ssl-verify",
45+
action="store_true",
46+
required=False,
47+
default=False,
48+
help="Tells fuzzer to skip certificates verification in case of https",
49+
)
4250
parser.add_argument(
4351
"--output-dir",
4452
action="store",
@@ -65,6 +73,7 @@ def main(
6573
schema=context.schema_location,
6674
base_url=context.base_url,
6775
headers=context.headers,
76+
ssl_insecure=cli_args.fuzzer_skip_ssl_verify or context.fuzzer_skip_ssl_verify,
6877
build=cli_args.build,
6978
target=cli_args.target,
7079
) as result:

src/wafp/fuzzers/catalog/api_fuzzer/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,16 @@
88

99
class Default(BaseFuzzer):
1010
def get_entrypoint_args(
11-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
11+
self,
12+
context: FuzzerContext,
13+
schema: str,
14+
base_url: str,
15+
headers: Dict[str, str],
16+
ssl_insecure: bool = False,
1217
) -> List[str]:
18+
if ssl_insecure:
19+
self.logger.warning("Explicit cert verification skip is not supported for this fuzzer yet")
20+
1321
args = ["--basic_output=True"]
1422
if is_url(schema):
1523
args.append(f"--src_url={schema}")

src/wafp/fuzzers/catalog/cats/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,16 @@ def get_container_output_directory(self) -> pathlib.Path:
2525
return pathlib.Path("/app/test-report/")
2626

2727
def get_entrypoint_args(
28-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
28+
self,
29+
context: FuzzerContext,
30+
schema: str,
31+
base_url: str,
32+
headers: Dict[str, str],
33+
ssl_insecure: bool = False,
2934
) -> List[str]:
35+
if ssl_insecure:
36+
self.logger.warning("Explicit cert verification skip is not supported for this fuzzer yet")
37+
3038
args = [f"--contract={schema}", f"--server={base_url}"]
3139
if headers:
3240
# Over-simplified YAML serialization only for this exact case

src/wafp/fuzzers/catalog/fuzz_lightyear/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,16 @@
77

88
class Default(BaseFuzzer):
99
def get_entrypoint_args(
10-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
10+
self,
11+
context: FuzzerContext,
12+
schema: str,
13+
base_url: str,
14+
headers: Dict[str, str],
15+
ssl_insecure: bool = False,
1116
) -> List[str]:
17+
if ssl_insecure:
18+
self.logger.warning("Explicit cert verification skip is not supported for this fuzzer yet")
19+
1220
if not is_url(schema):
1321
# The `url` argument is ignored if we pass the `--schema` option
1422
args = [f"--schema={schema}", "http://0.0.0.0/any.yaml"]

src/wafp/fuzzers/catalog/fuzzy_swagger/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55

66
class Default(BaseFuzzer):
77
def get_entrypoint_args(
8-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
8+
self,
9+
context: FuzzerContext,
10+
schema: str,
11+
base_url: str,
12+
headers: Dict[str, str],
13+
ssl_insecure: bool = False,
914
) -> List[str]:
15+
if ssl_insecure:
16+
self.logger.warning("Explicit cert verification skip is not supported for this fuzzer yet")
17+
1018
# Fuzzy-Swagger does not support custom headers
1119
return [f"--swagger={schema}", f"--server={base_url}", "--verbose"]

src/wafp/fuzzers/catalog/got_swag/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55

66
class Default(BaseFuzzer):
77
def get_entrypoint_args(
8-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
8+
self,
9+
context: FuzzerContext,
10+
schema: str,
11+
base_url: str,
12+
headers: Dict[str, str],
13+
ssl_insecure: bool = False,
914
) -> List[str]:
15+
if ssl_insecure:
16+
self.logger.warning("Explicit cert verification skip is not supported for this fuzzer yet")
17+
1018
# Custom headers are only supported as variables for their tests DSL
1119
return [schema, "-m"]

src/wafp/fuzzers/catalog/restler/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,16 @@ def prepare_schema(self, context: FuzzerContext, schema: str) -> str:
2626
return str(container_input / filename)
2727

2828
def get_entrypoint_args(
29-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
29+
self,
30+
context: FuzzerContext,
31+
schema: str,
32+
base_url: str,
33+
headers: Dict[str, str],
34+
ssl_insecure: bool = False,
3035
) -> List[str]:
36+
if ssl_insecure:
37+
self.logger.warning("Explicit cert verification skip is not supported for this fuzzer yet")
38+
3139
parsed = urlparse(base_url)
3240
args = [
3341
str(self.get_container_output_directory()),

src/wafp/fuzzers/catalog/schemathesis/__init__.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
class Default(BaseFuzzer):
99
def get_entrypoint_args(
10-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
10+
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str], ssl_insecure: bool = False
1111
) -> List[str]:
1212
args = [
1313
"run",
@@ -22,6 +22,8 @@ def get_entrypoint_args(
2222
if headers:
2323
for key, value in headers.items():
2424
args.extend(["-H", f"{key}: {value}"])
25+
if ssl_insecure:
26+
args.extend(["--request-tls-verify=false"])
2527
extend_entrypoint_args(context, args)
2628
return args
2729

@@ -36,27 +38,27 @@ def extend_entrypoint_args(context: FuzzerContext, args: List[str]) -> None:
3638

3739
class AllChecks(Default):
3840
def get_entrypoint_args(
39-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
41+
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str], ssl_insecure: bool = False
4042
) -> List[str]:
41-
args = super().get_entrypoint_args(context, schema, base_url, headers)
43+
args = super().get_entrypoint_args(context, schema, base_url, headers, ssl_insecure)
4244
args.append("--checks=all")
4345
return args
4446

4547

4648
class Negative(Default):
4749
def get_entrypoint_args(
48-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
50+
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str], ssl_insecure: bool = False
4951
) -> List[str]:
50-
args = super().get_entrypoint_args(context, schema, base_url, headers)
52+
args = super().get_entrypoint_args(context, schema, base_url, headers, ssl_insecure)
5153
args.append("--data-generation-method=negative")
5254
return args
5355

5456

5557
class StatefulOld(Default):
5658
def get_entrypoint_args(
57-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
59+
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str], ssl_insecure: bool = False
5860
) -> List[str]:
59-
args = super().get_entrypoint_args(context, schema, base_url, headers)
61+
args = super().get_entrypoint_args(context, schema, base_url, headers, ssl_insecure)
6062
args.append("--stateful=links")
6163
return args
6264

@@ -66,8 +68,11 @@ def get_entrypoint(self) -> Union[str, NotSet]:
6668
return "pytest"
6769

6870
def get_entrypoint_args(
69-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
71+
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str], ssl_insecure: bool = False
7072
) -> List[str]:
73+
if ssl_insecure:
74+
self.logger.warning("Explicit cert verification skip is not supported for this target yet")
75+
7176
filename = "test_stateful.py"
7277
if context.target is not None and context.target.startswith("age_of_empires_2_api"):
7378
extra = {"force_schema_version": "30"}

src/wafp/fuzzers/catalog/swagger_conformance/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@
55

66
class Default(BaseFuzzer):
77
def get_entrypoint_args(
8-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
8+
self,
9+
context: FuzzerContext,
10+
schema: str,
11+
base_url: str,
12+
headers: Dict[str, str],
13+
ssl_insecure: bool = False,
914
) -> List[str]:
15+
if ssl_insecure:
16+
self.logger.warning("Explicit cert verification skip is not supported for this fuzzer yet")
17+
1018
# Swagger-conformance does not support setting base URL or custom headers
1119
return [schema]

src/wafp/fuzzers/catalog/swagger_fuzzer/__init__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,15 @@ def prepare_schema(self, context: FuzzerContext, schema: str) -> str:
1212
return self.serve_spec(context, schema)
1313

1414
def get_entrypoint_args(
15-
self, context: FuzzerContext, schema: str, base_url: str, headers: Dict[str, str]
15+
self,
16+
context: FuzzerContext,
17+
schema: str,
18+
base_url: str,
19+
headers: Dict[str, str],
20+
ssl_insecure: bool = False,
1621
) -> List[str]:
22+
if ssl_insecure:
23+
self.logger.warning("Explicit cert verification skip is not supported for this fuzzer yet")
24+
1725
# Swagger-fuzzer does not support setting base URL or custom headers
1826
return [schema]

0 commit comments

Comments
 (0)