api-gate-keeper 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. api_gate_keeper-0.1.0.dist-info/METADATA +654 -0
  2. api_gate_keeper-0.1.0.dist-info/RECORD +35 -0
  3. api_gate_keeper-0.1.0.dist-info/WHEEL +5 -0
  4. api_gate_keeper-0.1.0.dist-info/entry_points.txt +2 -0
  5. api_gate_keeper-0.1.0.dist-info/licenses/LICENSE +21 -0
  6. api_gate_keeper-0.1.0.dist-info/top_level.txt +1 -0
  7. app_test/__init__.py +2 -0
  8. app_test/auth.py +107 -0
  9. app_test/categories/__init__.py +24 -0
  10. app_test/categories/auth_robustness.py +186 -0
  11. app_test/categories/authz.py +119 -0
  12. app_test/categories/baseline.py +29 -0
  13. app_test/categories/bola_matrix.py +340 -0
  14. app_test/categories/contract_conformance.py +249 -0
  15. app_test/categories/error_leakage_and_debug_surface.py +270 -0
  16. app_test/categories/file_upload_security.py +302 -0
  17. app_test/categories/jwt_security.py +261 -0
  18. app_test/categories/mass_assignment.py +200 -0
  19. app_test/categories/owasp.py +127 -0
  20. app_test/categories/pen_test.py +37 -0
  21. app_test/categories/privilege_escalation.py +180 -0
  22. app_test/categories/rate_limit_and_resource_abuse.py +240 -0
  23. app_test/categories/schema_contract_and_validation.py +297 -0
  24. app_test/categories/security_misc.py +99 -0
  25. app_test/categories/soak_profile.py +255 -0
  26. app_test/categories/sql_injection.py +36 -0
  27. app_test/categories/ssrf_and_redirects.py +280 -0
  28. app_test/categories/token_security.py +195 -0
  29. app_test/categories/workflow_chains.py +437 -0
  30. app_test/cli.py +1085 -0
  31. app_test/config.py +19 -0
  32. app_test/discovery.py +269 -0
  33. app_test/executor.py +184 -0
  34. app_test/models.py +54 -0
  35. app_test/report.py +628 -0
@@ -0,0 +1,261 @@
1
+ from __future__ import annotations
2
+
3
+ import base64
4
+ import json
5
+
6
+ import httpx
7
+
8
+ from app_test.auth import extract_bearer_token
9
+ from app_test.executor import execute_endpoint
10
+ from app_test.models import EndpointSpec, ExecutionResult
11
+
12
+
13
+ MAX_JWT_TARGETS = 15
14
+ _ASYMMETRIC_ALG_PREFIXES = ("RS", "ES", "PS")
15
+
16
+
17
+ # ---------------------------------------------------------------------------
18
+ # JWT helpers (no external dependencies — stdlib only)
19
+ # ---------------------------------------------------------------------------
20
+
21
+ def _b64url_decode(segment: str) -> bytes:
22
+ padding = 4 - len(segment) % 4
23
+ if padding != 4:
24
+ segment += "=" * padding
25
+ return base64.urlsafe_b64decode(segment)
26
+
27
+
28
+ def _b64url_encode(data: bytes) -> str:
29
+ return base64.urlsafe_b64encode(data).rstrip(b"=").decode()
30
+
31
+
32
+ def _parse_jwt(token: str) -> tuple[dict, dict, str] | None:
33
+ """Return (header_dict, payload_dict, raw_signature) or None."""
34
+ parts = token.split(".")
35
+ if len(parts) != 3:
36
+ return None
37
+ try:
38
+ header = json.loads(_b64url_decode(parts[0]))
39
+ payload = json.loads(_b64url_decode(parts[1]))
40
+ return header, payload, parts[2]
41
+ except Exception:
42
+ return None
43
+
44
+
45
+ def _build_jwt(header: dict, payload: dict, signature: str = "") -> str:
46
+ h = _b64url_encode(json.dumps(header, separators=(",", ":")).encode())
47
+ p = _b64url_encode(json.dumps(payload, separators=(",", ":")).encode())
48
+ return f"{h}.{p}.{signature}"
49
+
50
+
51
+ # ---------------------------------------------------------------------------
52
+ # Endpoint helpers
53
+ # ---------------------------------------------------------------------------
54
+
55
+ def _safe_auth_targets(endpoints: list[EndpointSpec]) -> list[EndpointSpec]:
56
+ return [
57
+ ep
58
+ for ep in endpoints
59
+ if ep.requires_auth and ep.method.upper() in {"GET", "HEAD", "OPTIONS"}
60
+ ]
61
+
62
+
63
+ def _run_jwt_probe(
64
+ client: httpx.Client,
65
+ endpoint: EndpointSpec,
66
+ base_url: str,
67
+ tampered_token: str,
68
+ test_name: str,
69
+ ) -> ExecutionResult:
70
+ base_result = execute_endpoint(
71
+ client=client,
72
+ endpoint=endpoint,
73
+ base_url=base_url,
74
+ token=None,
75
+ category="jwt_security",
76
+ test_name=test_name,
77
+ include_unsafe=False,
78
+ auth_mode="none",
79
+ auth_header_override=f"Bearer {tampered_token}",
80
+ )
81
+
82
+ if base_result.status == "skipped":
83
+ return ExecutionResult(
84
+ category="jwt_security",
85
+ test_name=test_name,
86
+ service=base_result.service,
87
+ method=base_result.method,
88
+ url=base_result.url,
89
+ status="skipped",
90
+ message=base_result.message,
91
+ )
92
+
93
+ if base_result.status == "error":
94
+ return ExecutionResult(
95
+ category="jwt_security",
96
+ test_name=test_name,
97
+ service=base_result.service,
98
+ method=base_result.method,
99
+ url=base_result.url,
100
+ status="error",
101
+ http_status=base_result.http_status,
102
+ latency_ms=base_result.latency_ms,
103
+ message=base_result.message,
104
+ retries=base_result.retries,
105
+ diagnostics=base_result.diagnostics,
106
+ response_snippet=base_result.response_snippet,
107
+ )
108
+
109
+ allowed_statuses = {400, 401, 403}
110
+ if base_result.http_status in allowed_statuses:
111
+ status = "pass"
112
+ message = f"Tampered JWT was rejected ({base_result.http_status})"
113
+ elif base_result.http_status is not None and 200 <= base_result.http_status < 300:
114
+ status = "fail"
115
+ message = (
116
+ f"Tampered JWT returned success ({base_result.http_status}) "
117
+ "— potential JWT misuse vulnerability"
118
+ )
119
+ else:
120
+ status = "pass"
121
+ message = f"Tampered JWT returned non-success ({base_result.http_status})"
122
+
123
+ return ExecutionResult(
124
+ category="jwt_security",
125
+ test_name=test_name,
126
+ service=base_result.service,
127
+ method=base_result.method,
128
+ url=base_result.url,
129
+ status=status,
130
+ http_status=base_result.http_status,
131
+ latency_ms=base_result.latency_ms,
132
+ message=message,
133
+ retries=base_result.retries,
134
+ diagnostics=base_result.diagnostics,
135
+ response_snippet=base_result.response_snippet,
136
+ )
137
+
138
+
139
+ # ---------------------------------------------------------------------------
140
+ # Attack probe set for a single endpoint
141
+ # ---------------------------------------------------------------------------
142
+
143
+ def _probes_for_endpoint(
144
+ client: httpx.Client,
145
+ endpoint: EndpointSpec,
146
+ base_url: str,
147
+ header: dict,
148
+ payload: dict,
149
+ signature: str,
150
+ ) -> list[ExecutionResult]:
151
+ results: list[ExecutionResult] = []
152
+
153
+ # 1. alg:none — server must reject tokens claiming no algorithm
154
+ none_header = {**header, "alg": "none"}
155
+ results.append(_run_jwt_probe(client, endpoint, base_url, _build_jwt(none_header, payload, ""), "jwt_alg_none"))
156
+
157
+ # 2. alg:None — capital variant accepted by some buggy libraries
158
+ none_cap_header = {**header, "alg": "None"}
159
+ results.append(_run_jwt_probe(client, endpoint, base_url, _build_jwt(none_cap_header, payload, ""), "jwt_alg_none_capital"))
160
+
161
+ # 3. Signature stripped from a valid header+payload
162
+ results.append(_run_jwt_probe(client, endpoint, base_url, _build_jwt(header, payload, ""), "jwt_signature_stripped"))
163
+
164
+ # 4. Expired claim — exp set to the past (2001-09-09)
165
+ expired_payload = {**payload, "exp": 1_000_000_000}
166
+ results.append(_run_jwt_probe(client, endpoint, base_url, _build_jwt(header, expired_payload, signature), "jwt_expired_claim"))
167
+
168
+ # 5. Not-before in far future (year 2286) — token not yet valid
169
+ future_nbf_payload = {**payload, "nbf": 9_999_999_999}
170
+ results.append(_run_jwt_probe(client, endpoint, base_url, _build_jwt(header, future_nbf_payload, signature), "jwt_nbf_future_claim"))
171
+
172
+ # 6. kid header — path traversal attempt
173
+ kid_traversal_header = {**header, "kid": "../../dev/null"}
174
+ results.append(_run_jwt_probe(client, endpoint, base_url, _build_jwt(kid_traversal_header, payload, signature), "jwt_kid_path_traversal"))
175
+
176
+ # 7. kid header — SQL injection attempt
177
+ kid_sql_header = {**header, "kid": "' OR 1=1 --"}
178
+ results.append(_run_jwt_probe(client, endpoint, base_url, _build_jwt(kid_sql_header, payload, signature), "jwt_kid_sql_injection"))
179
+
180
+ # 8. Algorithm confusion: RS/ES/PS → HS256 (HMAC with invalid key)
181
+ orig_alg = header.get("alg", "")
182
+ if isinstance(orig_alg, str) and orig_alg.upper().startswith(_ASYMMETRIC_ALG_PREFIXES):
183
+ hs_header = {**header, "alg": "HS256"}
184
+ results.append(
185
+ _run_jwt_probe(
186
+ client, endpoint, base_url,
187
+ _build_jwt(hs_header, payload, "invalidsignature"),
188
+ "jwt_alg_confusion_rsa_to_hmac",
189
+ )
190
+ )
191
+
192
+ return results
193
+
194
+
195
+ # ---------------------------------------------------------------------------
196
+ # Category entry point
197
+ # ---------------------------------------------------------------------------
198
+
199
+ def run(
200
+ client: httpx.Client,
201
+ base_url: str,
202
+ token: str | None,
203
+ endpoints: list[EndpointSpec],
204
+ include_unsafe: bool,
205
+ ) -> list[ExecutionResult]:
206
+ del include_unsafe
207
+
208
+ raw_bearer = extract_bearer_token(token)
209
+ if not raw_bearer:
210
+ return [
211
+ ExecutionResult(
212
+ category="jwt_security",
213
+ test_name="jwt_security_token_presence",
214
+ service="gateway",
215
+ method="GET",
216
+ url=base_url.rstrip("/"),
217
+ status="skipped",
218
+ message=(
219
+ "JWT security checks require bearer token auth; "
220
+ "current auth mode does not provide a bearer token"
221
+ ),
222
+ )
223
+ ]
224
+
225
+ parsed = _parse_jwt(raw_bearer)
226
+ if parsed is None:
227
+ return [
228
+ ExecutionResult(
229
+ category="jwt_security",
230
+ test_name="jwt_security_format_detection",
231
+ service="gateway",
232
+ method="GET",
233
+ url=base_url.rstrip("/"),
234
+ status="skipped",
235
+ message=(
236
+ "Access token is not JWT-shaped (expected 3 base64url segments); "
237
+ "JWT-specific misuse checks skipped"
238
+ ),
239
+ )
240
+ ]
241
+
242
+ header, payload, signature = parsed
243
+
244
+ targets = _safe_auth_targets(endpoints)[:MAX_JWT_TARGETS]
245
+ if not targets:
246
+ return [
247
+ ExecutionResult(
248
+ category="jwt_security",
249
+ test_name="jwt_security_target_discovery",
250
+ service="gateway",
251
+ method="GET",
252
+ url=base_url.rstrip("/"),
253
+ status="skipped",
254
+ message="No safe authenticated endpoints discovered for JWT security checks",
255
+ )
256
+ ]
257
+
258
+ results: list[ExecutionResult] = []
259
+ for endpoint in targets:
260
+ results.extend(_probes_for_endpoint(client, endpoint, base_url, header, payload, signature))
261
+ return results
@@ -0,0 +1,200 @@
1
+ from __future__ import annotations
2
+
3
+ import json
4
+
5
+ import httpx
6
+
7
+ from app_test.executor import execute_endpoint
8
+ from app_test.models import EndpointSpec, ExecutionResult
9
+
10
+
11
+ SENSITIVE_FIELDS = {
12
+ "role": "__apptest_mass_assignment_role__",
13
+ "roles": ["__apptest_mass_assignment_roles__"],
14
+ "is_admin": True,
15
+ "admin": True,
16
+ "tenant_id": "__apptest_mass_assignment_tenant__",
17
+ "owner_id": "__apptest_mass_assignment_owner__",
18
+ "permissions": ["__apptest_mass_assignment_permissions__"],
19
+ "status": "__apptest_mass_assignment_status__",
20
+ "user_id": "__apptest_mass_assignment_user__",
21
+ "organization_id": "__apptest_mass_assignment_org__",
22
+ }
23
+ SENSITIVE_FIELD_NAMES = set(SENSITIVE_FIELDS)
24
+ MUTATING_METHODS = {"POST", "PUT", "PATCH"}
25
+ MAX_TARGETS = 20
26
+
27
+
28
+ def _sample_value(schema_type: str) -> str | int | float | bool:
29
+ if schema_type == "integer":
30
+ return 1
31
+ if schema_type == "number":
32
+ return 1.0
33
+ if schema_type == "boolean":
34
+ return True
35
+ return "sample"
36
+
37
+
38
+ def _json_properties(endpoint: EndpointSpec) -> dict[str, dict[str, object]]:
39
+ properties = (
40
+ endpoint.request_body.get("content", {})
41
+ .get("application/json", {})
42
+ .get("schema", {})
43
+ .get("properties", {})
44
+ )
45
+ return properties if isinstance(properties, dict) else {}
46
+
47
+
48
+ def _candidate_targets(endpoints: list[EndpointSpec]) -> list[EndpointSpec]:
49
+ targets: list[EndpointSpec] = []
50
+ for endpoint in endpoints:
51
+ if endpoint.method.upper() not in MUTATING_METHODS:
52
+ continue
53
+ if not endpoint.requires_auth:
54
+ continue
55
+ if not _json_properties(endpoint):
56
+ continue
57
+ targets.append(endpoint)
58
+ return targets[:MAX_TARGETS]
59
+
60
+
61
+ def _base_payload(endpoint: EndpointSpec) -> dict[str, object]:
62
+ payload: dict[str, object] = {}
63
+ for key, prop in _json_properties(endpoint).items():
64
+ prop_type = "string"
65
+ if isinstance(prop, dict):
66
+ prop_type = str(prop.get("type", "string"))
67
+ payload[key] = _sample_value(prop_type)
68
+ return payload
69
+
70
+
71
+ def _assignment_payload(endpoint: EndpointSpec) -> tuple[dict[str, object], list[str]]:
72
+ payload = _base_payload(endpoint)
73
+ added_fields: list[str] = []
74
+ for field, value in SENSITIVE_FIELDS.items():
75
+ if field in payload:
76
+ continue
77
+ payload[field] = value
78
+ added_fields.append(field)
79
+ return payload, added_fields
80
+
81
+
82
+ def _reflected_sensitive_fields(snippet: str, payload: dict[str, object], added_fields: list[str]) -> list[str]:
83
+ normalized_snippet = snippet.lower()
84
+ reflected: list[str] = []
85
+ for field in added_fields:
86
+ value = payload.get(field)
87
+ if isinstance(value, str):
88
+ tokens = [value.lower()]
89
+ elif isinstance(value, list):
90
+ tokens = [str(item).lower() for item in value if isinstance(item, str)]
91
+ else:
92
+ continue
93
+
94
+ if any(token and token in normalized_snippet for token in tokens):
95
+ reflected.append(field)
96
+ return reflected
97
+
98
+
99
+ def _infer_from_response(result: ExecutionResult, payload: dict[str, object], added_fields: list[str]) -> ExecutionResult:
100
+ if result.status == "skipped":
101
+ return ExecutionResult(
102
+ category="mass_assignment",
103
+ test_name="mass_assignment_sensitive_field_probe",
104
+ service=result.service,
105
+ method=result.method,
106
+ url=result.url,
107
+ status="skipped",
108
+ message=result.message,
109
+ )
110
+
111
+ if result.status == "error":
112
+ return ExecutionResult(
113
+ category="mass_assignment",
114
+ test_name="mass_assignment_sensitive_field_probe",
115
+ service=result.service,
116
+ method=result.method,
117
+ url=result.url,
118
+ status="error",
119
+ http_status=result.http_status,
120
+ latency_ms=result.latency_ms,
121
+ message=result.message,
122
+ retries=result.retries,
123
+ diagnostics=result.diagnostics,
124
+ response_snippet=result.response_snippet,
125
+ )
126
+
127
+ status_code = result.http_status
128
+ snippet = result.response_snippet.lower()
129
+
130
+ if status_code in {400, 401, 403, 404, 409, 422}:
131
+ status = "pass"
132
+ message = f"Sensitive field probe was rejected ({status_code})"
133
+ elif status_code is not None and 200 <= status_code < 300:
134
+ reflected = _reflected_sensitive_fields(snippet, payload, added_fields)
135
+ if reflected:
136
+ status = "fail"
137
+ message = f"Response appears to accept or reflect injected sensitive values for: {', '.join(reflected)}"
138
+ else:
139
+ status = "skipped"
140
+ message = "Mutation succeeded but response did not clearly reflect injected sensitive values"
141
+ else:
142
+ status = "pass"
143
+ message = f"Sensitive field probe returned non-success status ({status_code})"
144
+
145
+ return ExecutionResult(
146
+ category="mass_assignment",
147
+ test_name="mass_assignment_sensitive_field_probe",
148
+ service=result.service,
149
+ method=result.method,
150
+ url=result.url,
151
+ status=status,
152
+ http_status=result.http_status,
153
+ latency_ms=result.latency_ms,
154
+ message=message,
155
+ retries=result.retries,
156
+ diagnostics=result.diagnostics,
157
+ response_snippet=result.response_snippet,
158
+ )
159
+
160
+
161
+ def run(
162
+ client: httpx.Client,
163
+ base_url: str,
164
+ token: str,
165
+ endpoints: list[EndpointSpec],
166
+ include_unsafe: bool,
167
+ ) -> list[ExecutionResult]:
168
+ targets = _candidate_targets(endpoints)
169
+ if not targets:
170
+ return [
171
+ ExecutionResult(
172
+ category="mass_assignment",
173
+ test_name="mass_assignment_target_discovery",
174
+ service="gateway",
175
+ method="POST",
176
+ url=base_url.rstrip("/"),
177
+ status="skipped",
178
+ message="No authenticated JSON mutation endpoints discovered for mass assignment checks",
179
+ )
180
+ ]
181
+
182
+ results: list[ExecutionResult] = []
183
+ for endpoint in targets:
184
+ payload, added_fields = _assignment_payload(endpoint)
185
+ base_result = execute_endpoint(
186
+ client=client,
187
+ endpoint=endpoint,
188
+ base_url=base_url,
189
+ token=token,
190
+ category="mass_assignment",
191
+ test_name="mass_assignment_sensitive_field_probe",
192
+ include_unsafe=include_unsafe,
193
+ body_override=payload,
194
+ )
195
+ normalized = _infer_from_response(base_result, payload, added_fields)
196
+ if normalized.status == "skipped" and include_unsafe and not normalized.response_snippet:
197
+ normalized.response_snippet = json.dumps({"added_fields": added_fields})[:400]
198
+ results.append(normalized)
199
+
200
+ return results
@@ -0,0 +1,127 @@
1
+ from __future__ import annotations
2
+
3
+ import httpx
4
+
5
+ from app_test.auth import auth_headers_from_token
6
+ from app_test.executor import execute_endpoint
7
+ from app_test.models import EndpointSpec, ExecutionResult
8
+
9
+
10
+ OWASP_HEADERS = {
11
+ "x-frame-options",
12
+ "x-content-type-options",
13
+ "content-security-policy",
14
+ "strict-transport-security",
15
+ }
16
+
17
+
18
+ def _header_result(url: str, service: str, status: str, message: str) -> ExecutionResult:
19
+ return ExecutionResult(
20
+ category="owasp",
21
+ test_name="security_headers_check",
22
+ service=service,
23
+ method="GET",
24
+ url=url,
25
+ status=status,
26
+ message=message,
27
+ )
28
+
29
+
30
+ def _is_header_candidate(endpoint: EndpointSpec) -> bool:
31
+ return endpoint.method.upper() == "GET" and "{" not in endpoint.path
32
+
33
+
34
+ def _select_header_targets(endpoints: list[EndpointSpec]) -> list[EndpointSpec]:
35
+ public_candidates = [e for e in endpoints if _is_header_candidate(e) and not e.requires_auth]
36
+ auth_candidates = [e for e in endpoints if _is_header_candidate(e) and e.requires_auth]
37
+
38
+ preferred_keywords = ["health", "openapi", "docs", "status", "version"]
39
+
40
+ def sort_key(endpoint: EndpointSpec) -> tuple[int, str]:
41
+ path = endpoint.path.lower()
42
+ score = 1
43
+ if any(k in path for k in preferred_keywords):
44
+ score = 0
45
+ return (score, path)
46
+
47
+ public_sorted = sorted(public_candidates, key=sort_key)
48
+ auth_sorted = sorted(auth_candidates, key=sort_key)
49
+ return public_sorted[:3] + auth_sorted[:3]
50
+
51
+
52
+ def run(
53
+ client: httpx.Client,
54
+ base_url: str,
55
+ token: str,
56
+ endpoints: list[EndpointSpec],
57
+ include_unsafe: bool,
58
+ ) -> list[ExecutionResult]:
59
+ results: list[ExecutionResult] = []
60
+
61
+ header_targets = _select_header_targets(endpoints)
62
+ if not header_targets:
63
+ fallback_url = base_url.rstrip("/")
64
+ try:
65
+ response = client.get(fallback_url)
66
+ response_headers = {k.lower(): v for k, v in response.headers.items()}
67
+ missing = [h for h in OWASP_HEADERS if h not in response_headers]
68
+ if missing:
69
+ results.append(
70
+ _header_result(
71
+ fallback_url,
72
+ "gateway",
73
+ "fail",
74
+ f"Missing headers: {', '.join(missing)}",
75
+ )
76
+ )
77
+ else:
78
+ results.append(_header_result(fallback_url, "gateway", "pass", "All baseline OWASP headers found"))
79
+ except Exception as exc:
80
+ results.append(_header_result(fallback_url, "gateway", "error", str(exc)))
81
+ else:
82
+ for endpoint in header_targets:
83
+ url = f"{base_url.rstrip('/')}{endpoint.path}"
84
+ headers: dict[str, str] = {}
85
+ if endpoint.requires_auth and token:
86
+ headers.update(auth_headers_from_token(token))
87
+
88
+ try:
89
+ response = client.get(url, headers=headers)
90
+ response_headers = {k.lower(): v for k, v in response.headers.items()}
91
+ missing = [h for h in OWASP_HEADERS if h not in response_headers]
92
+ if missing:
93
+ results.append(
94
+ _header_result(
95
+ str(response.request.url),
96
+ endpoint.service,
97
+ "fail",
98
+ f"Missing headers: {', '.join(missing)}",
99
+ )
100
+ )
101
+ else:
102
+ results.append(
103
+ _header_result(
104
+ str(response.request.url),
105
+ endpoint.service,
106
+ "pass",
107
+ "All baseline OWASP headers found",
108
+ )
109
+ )
110
+ except Exception as exc:
111
+ results.append(_header_result(url, endpoint.service, "error", str(exc)))
112
+
113
+ for endpoint in endpoints:
114
+ if endpoint.requires_auth:
115
+ results.append(
116
+ execute_endpoint(
117
+ client=client,
118
+ endpoint=endpoint,
119
+ base_url=base_url,
120
+ token=token,
121
+ category="owasp",
122
+ test_name="auth_required_check",
123
+ include_unsafe=include_unsafe,
124
+ auth_mode="none",
125
+ )
126
+ )
127
+ return results
@@ -0,0 +1,37 @@
1
+ from __future__ import annotations
2
+
3
+ import httpx
4
+
5
+ from app_test.executor import execute_endpoint
6
+ from app_test.models import EndpointSpec, ExecutionResult
7
+
8
+ PEN_TEST_PAYLOADS = [
9
+ "../../../../etc/passwd",
10
+ "$(cat /etc/passwd)",
11
+ "<script>alert('xss')</script>",
12
+ ]
13
+
14
+
15
+ def run(
16
+ client: httpx.Client,
17
+ base_url: str,
18
+ token: str,
19
+ endpoints: list[EndpointSpec],
20
+ include_unsafe: bool,
21
+ ) -> list[ExecutionResult]:
22
+ results: list[ExecutionResult] = []
23
+ for endpoint in endpoints:
24
+ for payload in PEN_TEST_PAYLOADS:
25
+ results.append(
26
+ execute_endpoint(
27
+ client=client,
28
+ endpoint=endpoint,
29
+ base_url=base_url,
30
+ token=token,
31
+ category="pen_test",
32
+ test_name=f"pentest_payload:{payload}",
33
+ include_unsafe=include_unsafe,
34
+ attack_payload=payload,
35
+ )
36
+ )
37
+ return results