api-gate-keeper 0.1.0__tar.gz
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.
- api_gate_keeper-0.1.0/LICENSE +21 -0
- api_gate_keeper-0.1.0/PKG-INFO +654 -0
- api_gate_keeper-0.1.0/README.md +624 -0
- api_gate_keeper-0.1.0/api_gate_keeper.egg-info/PKG-INFO +654 -0
- api_gate_keeper-0.1.0/api_gate_keeper.egg-info/SOURCES.txt +38 -0
- api_gate_keeper-0.1.0/api_gate_keeper.egg-info/dependency_links.txt +1 -0
- api_gate_keeper-0.1.0/api_gate_keeper.egg-info/entry_points.txt +2 -0
- api_gate_keeper-0.1.0/api_gate_keeper.egg-info/requires.txt +4 -0
- api_gate_keeper-0.1.0/api_gate_keeper.egg-info/top_level.txt +1 -0
- api_gate_keeper-0.1.0/app_test/__init__.py +2 -0
- api_gate_keeper-0.1.0/app_test/auth.py +107 -0
- api_gate_keeper-0.1.0/app_test/categories/__init__.py +24 -0
- api_gate_keeper-0.1.0/app_test/categories/auth_robustness.py +186 -0
- api_gate_keeper-0.1.0/app_test/categories/authz.py +119 -0
- api_gate_keeper-0.1.0/app_test/categories/baseline.py +29 -0
- api_gate_keeper-0.1.0/app_test/categories/bola_matrix.py +340 -0
- api_gate_keeper-0.1.0/app_test/categories/contract_conformance.py +249 -0
- api_gate_keeper-0.1.0/app_test/categories/error_leakage_and_debug_surface.py +270 -0
- api_gate_keeper-0.1.0/app_test/categories/file_upload_security.py +302 -0
- api_gate_keeper-0.1.0/app_test/categories/jwt_security.py +261 -0
- api_gate_keeper-0.1.0/app_test/categories/mass_assignment.py +200 -0
- api_gate_keeper-0.1.0/app_test/categories/owasp.py +127 -0
- api_gate_keeper-0.1.0/app_test/categories/pen_test.py +37 -0
- api_gate_keeper-0.1.0/app_test/categories/privilege_escalation.py +180 -0
- api_gate_keeper-0.1.0/app_test/categories/rate_limit_and_resource_abuse.py +240 -0
- api_gate_keeper-0.1.0/app_test/categories/schema_contract_and_validation.py +297 -0
- api_gate_keeper-0.1.0/app_test/categories/security_misc.py +99 -0
- api_gate_keeper-0.1.0/app_test/categories/soak_profile.py +255 -0
- api_gate_keeper-0.1.0/app_test/categories/sql_injection.py +36 -0
- api_gate_keeper-0.1.0/app_test/categories/ssrf_and_redirects.py +280 -0
- api_gate_keeper-0.1.0/app_test/categories/token_security.py +195 -0
- api_gate_keeper-0.1.0/app_test/categories/workflow_chains.py +437 -0
- api_gate_keeper-0.1.0/app_test/cli.py +1085 -0
- api_gate_keeper-0.1.0/app_test/config.py +19 -0
- api_gate_keeper-0.1.0/app_test/discovery.py +269 -0
- api_gate_keeper-0.1.0/app_test/executor.py +184 -0
- api_gate_keeper-0.1.0/app_test/models.py +54 -0
- api_gate_keeper-0.1.0/app_test/report.py +628 -0
- api_gate_keeper-0.1.0/pyproject.toml +46 -0
- api_gate_keeper-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Dhalisoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: api-gate-keeper
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Web app API security test harness
|
|
5
|
+
Author: Dhalisoft
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Dhalisoft/api-gate-keeper
|
|
8
|
+
Project-URL: Repository, https://github.com/Dhalisoft/api-gate-keeper
|
|
9
|
+
Project-URL: Issues, https://github.com/Dhalisoft/api-gate-keeper/issues
|
|
10
|
+
Keywords: api,security,testing,openapi,pentest,owasp,ci
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Information Technology
|
|
15
|
+
Classifier: Topic :: Security
|
|
16
|
+
Classifier: Topic :: Software Development :: Testing
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: httpx>=0.27.0
|
|
26
|
+
Requires-Dist: pydantic>=2.7.0
|
|
27
|
+
Requires-Dist: rich>=13.7.0
|
|
28
|
+
Requires-Dist: PyYAML>=6.0.0
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# api-gate-keeper
|
|
32
|
+
|
|
33
|
+
Python-based API test harness for web application security and reliability checks.
|
|
34
|
+
|
|
35
|
+
## About
|
|
36
|
+
|
|
37
|
+
`apptest` is a CLI that discovers a web app's API surface from its live OpenAPI schema and runs a broad set of security and reliability checks against it — authentication robustness, injection, authorization/IDOR, JWT misuse, mass assignment, SSRF, rate limiting, and more — with safe-by-default execution and CI-friendly reporting (JSON, Markdown, JUnit, SARIF).
|
|
38
|
+
|
|
39
|
+
It's built for teams that want a repeatable, automatable security signal in CI/CD without standing up a full scanning platform.
|
|
40
|
+
|
|
41
|
+
## What It Does
|
|
42
|
+
|
|
43
|
+
- Discovers API endpoints automatically from OpenAPI specs (or manually seeded paths)
|
|
44
|
+
- Supports multiple auth strategies: `auto`, `bearer`/API key, `basic`, username/password login, or `none`
|
|
45
|
+
- Runs 20+ security test categories (auth, authz/BOLA, JWT, SSRF, mass assignment, schema conformance, workflow chains, soak/reliability profiling, and more)
|
|
46
|
+
- Classifies every check as `pass`, `fail`, `skipped`, or `error` — with conservative defaults to keep CI signal trustworthy
|
|
47
|
+
- Emits JSON, Markdown (summary/detail/failures), JUnit XML, and SARIF reports for CI gating and dashboards
|
|
48
|
+
- Ships `quick` / `standard` / `strict` profiles so you can start fast and dial up coverage over time
|
|
49
|
+
|
|
50
|
+
## Navigate
|
|
51
|
+
|
|
52
|
+
- [Quick Start](#quick-start)
|
|
53
|
+
- [Advanced Usage](#advanced-usage)
|
|
54
|
+
- [Learn More](#learn-more)
|
|
55
|
+
|
|
56
|
+
## Quick Start
|
|
57
|
+
|
|
58
|
+
First-time run should only require three choices:
|
|
59
|
+
|
|
60
|
+
- target URL (`--base-url`)
|
|
61
|
+
- auth type (API key, username/password, or no auth)
|
|
62
|
+
- profile (`quick`, `standard`, or `strict`)
|
|
63
|
+
|
|
64
|
+
### 60-Second Path
|
|
65
|
+
|
|
66
|
+
Use this if you just want a first successful run with minimal setup.
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
python3 -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt && pip install -e .
|
|
70
|
+
apptest --base-url https://your-target.example --api-key <your-api-key> --profile quick
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Install and run:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
python3 -m venv .venv
|
|
77
|
+
source .venv/bin/activate
|
|
78
|
+
pip install -r requirements.txt
|
|
79
|
+
pip install -e .
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Recommended first command (safe defaults):
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
apptest --base-url https://your-target.example --api-key <your-api-key> --profile quick
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
If the target does not expose an OpenAPI spec, you can seed known endpoints manually:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
apptest --base-url https://your-target.example --api-key <your-api-key> \
|
|
92
|
+
--seed-endpoint GET:/api/v1/resources.json \
|
|
93
|
+
--seed-endpoint GET:/api/v1/accounts.json \
|
|
94
|
+
--profile quick
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Run multiple targets in one command (parallel):
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
apptest --targets https://service-a.example,https://service-b.example --api-key <your-api-key> --profile quick
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Which Profile Should I Pick?
|
|
104
|
+
|
|
105
|
+
| Profile | Use this when | Typical first use |
|
|
106
|
+
|---|---|---|
|
|
107
|
+
| `quick` | Fast feedback and first-time validation | Local smoke run |
|
|
108
|
+
| `standard` | Broader routine coverage without aggressive behavior | Daily or pre-merge checks |
|
|
109
|
+
| `strict` | Deepest and most assertive coverage | Security hardening and release gates |
|
|
110
|
+
|
|
111
|
+
Auth alternatives:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
# username/password
|
|
115
|
+
apptest --base-url https://your-target.example --username user@example.com --password secret --profile quick
|
|
116
|
+
|
|
117
|
+
# public endpoints only
|
|
118
|
+
apptest --base-url https://your-target.example --profile quick --config apptest.yaml
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
If you use the no-auth flow, set this in `apptest.yaml`:
|
|
122
|
+
|
|
123
|
+
```yaml
|
|
124
|
+
auth:
|
|
125
|
+
type: none
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Minimal starter `apptest.yaml` (onboarding-focused):
|
|
129
|
+
|
|
130
|
+
```yaml
|
|
131
|
+
base_url: https://your-target.example
|
|
132
|
+
auth:
|
|
133
|
+
type: bearer
|
|
134
|
+
header: "Authorization: Bearer ${TARGET_TOKEN}"
|
|
135
|
+
profile: quick
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Common First-Run Issues
|
|
139
|
+
|
|
140
|
+
- 401/403 responses on most checks: verify API key/token, or switch to username/password auth.
|
|
141
|
+
- Connection or DNS failures: confirm `--base-url` is reachable from your environment.
|
|
142
|
+
- TLS/certificate errors in non-production environments: retry with `--insecure` only for test environments.
|
|
143
|
+
- Very few tests executed: ensure auth is valid and avoid `auth.type: none` unless testing public endpoints.
|
|
144
|
+
|
|
145
|
+
## Advanced Usage
|
|
146
|
+
|
|
147
|
+
### Authentication
|
|
148
|
+
|
|
149
|
+
Supported auth modes:
|
|
150
|
+
|
|
151
|
+
**Auto** (default):
|
|
152
|
+
- Uses `--api-key` if provided.
|
|
153
|
+
- Otherwise attempts login with `--username`/`--password`.
|
|
154
|
+
|
|
155
|
+
**Bearer / API key header**:
|
|
156
|
+
```bash
|
|
157
|
+
apptest --base-url https://your-target.example --api-key <your-api-key>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Username + password login**:
|
|
161
|
+
```bash
|
|
162
|
+
apptest --base-url https://your-target.example --username user@example.com --password secret
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**HTTP basic auth** (via config):
|
|
166
|
+
```yaml
|
|
167
|
+
auth:
|
|
168
|
+
type: basic
|
|
169
|
+
username: ${APP_USERNAME}
|
|
170
|
+
password: ${APP_PASSWORD}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**No auth** (public API checks only):
|
|
174
|
+
```yaml
|
|
175
|
+
auth:
|
|
176
|
+
type: none
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Browser-copied session headers / cookies**:
|
|
180
|
+
```bash
|
|
181
|
+
apptest \
|
|
182
|
+
--base-url https://your-target.example \
|
|
183
|
+
--request-header 'X-Requested-With: XMLHttpRequest' \
|
|
184
|
+
--cookie-header 'sessionid=abc123; other_cookie=value' \
|
|
185
|
+
--profile quick
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Environment variable fallback is supported (precedence: CLI args > env vars > built-in defaults):
|
|
189
|
+
|
|
190
|
+
- `APPTEST_BASE_URL`
|
|
191
|
+
- `APPTEST_API_KEY`
|
|
192
|
+
- `APPTEST_USERNAME`
|
|
193
|
+
- `APPTEST_PASSWORD`
|
|
194
|
+
- `APPTEST_AUTH_TYPE`
|
|
195
|
+
- `APPTEST_AUTH_HEADER`
|
|
196
|
+
- `APPTEST_AUTH_USERNAME`
|
|
197
|
+
- `APPTEST_AUTH_PASSWORD`
|
|
198
|
+
- `APPTEST_CATEGORIES`
|
|
199
|
+
- `APPTEST_SOAK_SAMPLES`
|
|
200
|
+
- `APPTEST_SOAK_MAX_5XX_RATE`
|
|
201
|
+
- `APPTEST_SOAK_MAX_EXCEPTION_RATE`
|
|
202
|
+
- `APPTEST_SOAK_MAX_P95_MS`
|
|
203
|
+
|
|
204
|
+
Example using env vars only:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
APPTEST_BASE_URL=https://your-target.example \
|
|
208
|
+
APPTEST_USERNAME=your-user@example.com \
|
|
209
|
+
APPTEST_PASSWORD=your-password \
|
|
210
|
+
apptest
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Config File (`apptest.yaml`)
|
|
214
|
+
|
|
215
|
+
If `apptest.yaml` exists in the current directory, it is auto-loaded.
|
|
216
|
+
You can also pass a custom path with `--config`.
|
|
217
|
+
|
|
218
|
+
Precedence is:
|
|
219
|
+
|
|
220
|
+
- CLI args
|
|
221
|
+
- Environment variables
|
|
222
|
+
- `apptest.yaml`
|
|
223
|
+
- Built-in defaults
|
|
224
|
+
|
|
225
|
+
Example `apptest.yaml`:
|
|
226
|
+
|
|
227
|
+
```yaml
|
|
228
|
+
base_url: https://your-target.example
|
|
229
|
+
auth:
|
|
230
|
+
type: bearer
|
|
231
|
+
header: "Authorization: Bearer ${TARGET_TOKEN}"
|
|
232
|
+
profile: quick
|
|
233
|
+
timeout: 20
|
|
234
|
+
output_dir: reports
|
|
235
|
+
include_unsafe: false
|
|
236
|
+
unsafe_categories: all
|
|
237
|
+
categories: all
|
|
238
|
+
soak_samples: 12
|
|
239
|
+
soak_max_5xx_rate: 0.15
|
|
240
|
+
soak_max_exception_rate: 0.05
|
|
241
|
+
soak_max_p95_ms: 2500
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Auth modes for `auth.type`: `auto`, `bearer`, `api_key`, `basic`, `none`.
|
|
245
|
+
|
|
246
|
+
For `bearer` and `api_key`, set `auth.header` (for example `Authorization: Bearer <token>` or `x-api-key: <key>`).
|
|
247
|
+
|
|
248
|
+
For browser-driven apps that require session cookies or extra request headers, you can also set:
|
|
249
|
+
|
|
250
|
+
```yaml
|
|
251
|
+
auth:
|
|
252
|
+
type: none
|
|
253
|
+
cookie_header: ${TARGET_COOKIE_HEADER}
|
|
254
|
+
extra_headers:
|
|
255
|
+
X-Requested-With: XMLHttpRequest
|
|
256
|
+
Accept: application/json
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
CLI `--request-header` values override `auth.extra_headers` entries with the same header name.
|
|
260
|
+
|
|
261
|
+
Run with auto-loaded config:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
apptest
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Run with explicit config path:
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
apptest --config ./apptest.yaml
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Initialize a starter config file:
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
apptest init
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Initialize at custom path:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
apptest init --path ./config/apptest.yaml
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
Overwrite existing config:
|
|
286
|
+
|
|
287
|
+
```bash
|
|
288
|
+
apptest init --force
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Default Runtime Parameters
|
|
292
|
+
|
|
293
|
+
- base URL: `https://your-target.example`
|
|
294
|
+
- auth mode: `auto`
|
|
295
|
+
- username: `your-user@example.com` (used by `auto` login fallback)
|
|
296
|
+
- password: `your-password` (used by `auto` login fallback)
|
|
297
|
+
|
|
298
|
+
### Example Commands
|
|
299
|
+
|
|
300
|
+
Run with defaults (safe mode — skips mutating methods):
|
|
301
|
+
|
|
302
|
+
```bash
|
|
303
|
+
apptest --base-url https://your-target.example
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
Run with profile presets:
|
|
307
|
+
|
|
308
|
+
```bash
|
|
309
|
+
# reduced category set, safe mode
|
|
310
|
+
apptest --profile quick --base-url https://your-target.example
|
|
311
|
+
|
|
312
|
+
# all categories, safe mode
|
|
313
|
+
apptest --profile standard --base-url https://your-target.example
|
|
314
|
+
|
|
315
|
+
# all categories, unsafe enabled by default
|
|
316
|
+
apptest --profile strict --base-url https://your-target.example
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Run specific categories only:
|
|
320
|
+
|
|
321
|
+
```bash
|
|
322
|
+
apptest --base-url https://your-target.example --categories auth_robustness
|
|
323
|
+
apptest --base-url https://your-target.example --categories token_security
|
|
324
|
+
apptest --base-url https://your-target.example --categories privilege_escalation
|
|
325
|
+
apptest --base-url https://your-target.example --categories file_upload_security --include-unsafe --unsafe-categories file_upload_security
|
|
326
|
+
apptest --base-url https://your-target.example --categories ssrf_and_redirects --include-unsafe --unsafe-categories ssrf_and_redirects
|
|
327
|
+
apptest --base-url https://your-target.example --categories rate_limit_and_resource_abuse
|
|
328
|
+
apptest --base-url https://your-target.example --categories error_leakage_and_debug_surface
|
|
329
|
+
apptest --base-url https://your-target.example --categories mass_assignment --include-unsafe --unsafe-categories mass_assignment
|
|
330
|
+
apptest --base-url https://your-target.example --categories schema_contract_and_validation --include-unsafe --unsafe-categories schema_contract_and_validation
|
|
331
|
+
apptest --base-url https://your-target.example --categories jwt_security
|
|
332
|
+
apptest --base-url https://your-target.example --categories contract_conformance
|
|
333
|
+
apptest --base-url https://your-target.example --categories bola_matrix
|
|
334
|
+
apptest --base-url https://your-target.example --categories workflow_chains --include-unsafe --unsafe-categories workflow_chains
|
|
335
|
+
apptest --base-url https://your-target.example --categories soak_profile
|
|
336
|
+
apptest --base-url https://your-target.example --categories baseline,owasp,authz
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
Tune soak profile thresholds/samples (CLI):
|
|
340
|
+
|
|
341
|
+
```bash
|
|
342
|
+
apptest \
|
|
343
|
+
--base-url https://your-target.example \
|
|
344
|
+
--categories soak_profile \
|
|
345
|
+
--soak-samples 8 \
|
|
346
|
+
--soak-max-5xx-rate 0.25 \
|
|
347
|
+
--soak-max-exception-rate 0.10 \
|
|
348
|
+
--soak-max-p95-ms 3500
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Soak tuning precedence is:
|
|
352
|
+
|
|
353
|
+
- CLI flags
|
|
354
|
+
- environment variables
|
|
355
|
+
- config file keys
|
|
356
|
+
- category defaults
|
|
357
|
+
|
|
358
|
+
Tune soak profile thresholds via environment variables:
|
|
359
|
+
|
|
360
|
+
```bash
|
|
361
|
+
APPTEST_SOAK_SAMPLES=8 \
|
|
362
|
+
APPTEST_SOAK_MAX_5XX_RATE=0.25 \
|
|
363
|
+
APPTEST_SOAK_MAX_EXCEPTION_RATE=0.10 \
|
|
364
|
+
APPTEST_SOAK_MAX_P95_MS=3500 \
|
|
365
|
+
apptest --base-url https://your-target.example --categories soak_profile
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Run with API key instead of username/password:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
apptest --base-url https://your-target.example --api-key <your-api-key>
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
Run with explicit auth header from config/env:
|
|
375
|
+
|
|
376
|
+
```bash
|
|
377
|
+
APPTEST_AUTH_TYPE=bearer \
|
|
378
|
+
APPTEST_AUTH_HEADER="Authorization: Bearer <token>" \
|
|
379
|
+
apptest --base-url https://your-target.example
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
Run with custom target and creds:
|
|
383
|
+
|
|
384
|
+
```bash
|
|
385
|
+
apptest --base-url https://your-target.example --username your-user --password your-pass
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Run with unsafe methods enabled for specific categories:
|
|
389
|
+
|
|
390
|
+
```bash
|
|
391
|
+
apptest --base-url https://your-target.example --include-unsafe --unsafe-categories baseline
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
Run with all categories fully unlocked:
|
|
395
|
+
|
|
396
|
+
```bash
|
|
397
|
+
apptest --base-url https://your-target.example --include-unsafe --unsafe-categories all
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
Disable TLS verification (only for test environments):
|
|
401
|
+
|
|
402
|
+
```bash
|
|
403
|
+
apptest --base-url https://your-target.example --insecure
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Fail CI when findings are present:
|
|
407
|
+
|
|
408
|
+
```bash
|
|
409
|
+
apptest --base-url https://your-target.example --fail-on-findings
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
Fail CI only when thresholds are exceeded:
|
|
413
|
+
|
|
414
|
+
```bash
|
|
415
|
+
apptest --base-url https://your-target.example --max-failed 0 --max-errors 0
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
Generate JUnit XML output for CI test dashboards:
|
|
419
|
+
|
|
420
|
+
```bash
|
|
421
|
+
apptest --base-url https://your-target.example --junit-out reports/apptest-junit.xml
|
|
422
|
+
```
|
|
423
|
+
|
|
424
|
+
Generate SARIF output for GitHub code scanning:
|
|
425
|
+
|
|
426
|
+
```bash
|
|
427
|
+
apptest --base-url https://your-target.example --sarif-out reports/apptest.sarif.json
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
Write reports to explicit paths:
|
|
431
|
+
|
|
432
|
+
```bash
|
|
433
|
+
apptest \
|
|
434
|
+
--base-url https://your-target.example \
|
|
435
|
+
--categories auth_robustness \
|
|
436
|
+
--json-out reports/auth_robustness.json \
|
|
437
|
+
--md-summary-out reports/auth_robustness.summary.md \
|
|
438
|
+
--md-detail-out reports/auth_robustness.detail.md \
|
|
439
|
+
--sarif-out reports/auth_robustness.sarif.json
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
Upload SARIF to GitHub Code Scanning:
|
|
443
|
+
|
|
444
|
+
```yaml
|
|
445
|
+
- name: Run apptest with SARIF
|
|
446
|
+
run: |
|
|
447
|
+
apptest \
|
|
448
|
+
--base-url "$APPTEST_BASE_URL" \
|
|
449
|
+
--api-key "$APPTEST_API_KEY" \
|
|
450
|
+
--sarif-out reports/apptest.sarif.json
|
|
451
|
+
|
|
452
|
+
- name: Upload SARIF to GitHub Code Scanning
|
|
453
|
+
if: always()
|
|
454
|
+
uses: github/codeql-action/upload-sarif@v3
|
|
455
|
+
with:
|
|
456
|
+
sarif_file: reports/apptest.sarif.json
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### Output
|
|
460
|
+
|
|
461
|
+
Reports are written to `reports/` — four files per run, prefixed with the target hostname:
|
|
462
|
+
- `<target-host>-<timestamp>-api-security-report.json` — raw results
|
|
463
|
+
- `<target-host>-<timestamp>-api-security-summary.md` — per-category totals
|
|
464
|
+
- `<target-host>-<timestamp>-api-security-detail.md` — per-test detail table with PASS/FAIL/SKIP
|
|
465
|
+
- `<target-host>-<timestamp>-api-security-failures.md` — failures/errors only, with a prioritized Remediation Plan summary followed by the detail table
|
|
466
|
+
|
|
467
|
+
### Categories Implemented
|
|
468
|
+
|
|
469
|
+
- baseline API execution
|
|
470
|
+
- penetration payload probes
|
|
471
|
+
- SQL injection probes
|
|
472
|
+
- OWASP-oriented checks
|
|
473
|
+
- additional security checks (CORS, basic rate probe)
|
|
474
|
+
- authorization and IDOR checks
|
|
475
|
+
- authentication robustness checks (invalid credential rejection, failed-login throttle signal)
|
|
476
|
+
- token security checks (malformed token, tampered token, missing Bearer prefix; skipped when bearer token auth is not in use)
|
|
477
|
+
- privilege escalation checks (likely admin endpoint access with current token)
|
|
478
|
+
- file upload security checks (multipart endpoint discovery, unsafe filename traversal and absolute path probes)
|
|
479
|
+
- SSRF and redirect checks (ServiceNow instance URL rejection for internal targets, redirect-style parameter discovery)
|
|
480
|
+
- rate-limit and resource-abuse checks (burst probes and oversized pagination or time-window requests)
|
|
481
|
+
- error leakage and debug surface checks (debug route exposure, unauthenticated debug access, stack-trace/internal error leakage markers)
|
|
482
|
+
- mass assignment checks (sensitive writable fields on authenticated JSON mutation endpoints)
|
|
483
|
+
- schema contract and validation checks (missing required fields, wrong types, unknown fields)
|
|
484
|
+
- JWT-specific token misuse checks (`alg:none`, stripped signatures, future `nbf`, `kid` abuse patterns)
|
|
485
|
+
- response contract conformance checks (status-code drift, undocumented response fields, missing required response fields)
|
|
486
|
+
- BOLA matrix checks with harvested live IDs (neighbor ID probes and cross-service ID references)
|
|
487
|
+
- workflow lifecycle chain checks (create-read-update-delete flow health and auth enforcement)
|
|
488
|
+
- soak profile checks on safe endpoints (repeated request stability and latency thresholds; auth-required endpoints with no successful responses are classified as skipped to reduce false positives)
|
|
489
|
+
|
|
490
|
+
### GitHub Actions Integration
|
|
491
|
+
|
|
492
|
+
Sample workflow (`.github/workflows/apptest-scan.yml`):
|
|
493
|
+
|
|
494
|
+
```yaml
|
|
495
|
+
name: Web App Security Scan (apptest)
|
|
496
|
+
|
|
497
|
+
on:
|
|
498
|
+
pull_request:
|
|
499
|
+
branches: [ main, develop ]
|
|
500
|
+
push:
|
|
501
|
+
branches: [ main, develop ]
|
|
502
|
+
workflow_dispatch:
|
|
503
|
+
inputs:
|
|
504
|
+
base_url:
|
|
505
|
+
description: "Target web app base URL"
|
|
506
|
+
required: false
|
|
507
|
+
default: "https://your-target.example"
|
|
508
|
+
|
|
509
|
+
jobs:
|
|
510
|
+
apptest-scan:
|
|
511
|
+
runs-on: ubuntu-latest
|
|
512
|
+
timeout-minutes: 30
|
|
513
|
+
|
|
514
|
+
env:
|
|
515
|
+
DEFAULT_BASE_URL: https://your-target.example
|
|
516
|
+
|
|
517
|
+
steps:
|
|
518
|
+
- name: Checkout
|
|
519
|
+
uses: actions/checkout@v4
|
|
520
|
+
|
|
521
|
+
- name: Set up Python
|
|
522
|
+
uses: actions/setup-python@v5
|
|
523
|
+
with:
|
|
524
|
+
python-version: "3.11"
|
|
525
|
+
|
|
526
|
+
- name: Install apptest
|
|
527
|
+
run: |
|
|
528
|
+
python -m pip install --upgrade pip
|
|
529
|
+
pip install -e .
|
|
530
|
+
|
|
531
|
+
- name: Resolve target URL
|
|
532
|
+
id: target
|
|
533
|
+
shell: bash
|
|
534
|
+
run: |
|
|
535
|
+
if [ -n "${{ github.event.inputs.base_url }}" ]; then
|
|
536
|
+
echo "base_url=${{ github.event.inputs.base_url }}" >> "$GITHUB_OUTPUT"
|
|
537
|
+
elif [ -n "${{ vars.APPTEST_BASE_URL }}" ]; then
|
|
538
|
+
echo "base_url=${{ vars.APPTEST_BASE_URL }}" >> "$GITHUB_OUTPUT"
|
|
539
|
+
else
|
|
540
|
+
echo "base_url=${DEFAULT_BASE_URL}" >> "$GITHUB_OUTPUT"
|
|
541
|
+
fi
|
|
542
|
+
|
|
543
|
+
- name: Run apptest (API key preferred)
|
|
544
|
+
shell: bash
|
|
545
|
+
env:
|
|
546
|
+
APPTEST_API_KEY: ${{ secrets.APPTEST_API_KEY }}
|
|
547
|
+
APPTEST_USERNAME: ${{ secrets.APPTEST_USERNAME }}
|
|
548
|
+
APPTEST_PASSWORD: ${{ secrets.APPTEST_PASSWORD }}
|
|
549
|
+
run: |
|
|
550
|
+
set -euo pipefail
|
|
551
|
+
BASE_URL="${{ steps.target.outputs.base_url }}"
|
|
552
|
+
|
|
553
|
+
if [ -n "${APPTEST_API_KEY:-}" ]; then
|
|
554
|
+
apptest \
|
|
555
|
+
--base-url "$BASE_URL" \
|
|
556
|
+
--api-key "$APPTEST_API_KEY" \
|
|
557
|
+
--include-unsafe \
|
|
558
|
+
--unsafe-categories baseline
|
|
559
|
+
else
|
|
560
|
+
apptest \
|
|
561
|
+
--base-url "$BASE_URL" \
|
|
562
|
+
--username "${APPTEST_USERNAME}" \
|
|
563
|
+
--password "${APPTEST_PASSWORD}" \
|
|
564
|
+
--include-unsafe \
|
|
565
|
+
--unsafe-categories baseline
|
|
566
|
+
fi
|
|
567
|
+
|
|
568
|
+
- name: Enforce gate from JSON report
|
|
569
|
+
shell: bash
|
|
570
|
+
run: |
|
|
571
|
+
set -euo pipefail
|
|
572
|
+
python - <<'PY'
|
|
573
|
+
import json, glob, sys
|
|
574
|
+
report = sorted(glob.glob("reports/*-api-security-report.json"))[-1]
|
|
575
|
+
data = json.load(open(report))
|
|
576
|
+
failed = data.get("summary", {}).get("failed", 0)
|
|
577
|
+
errors = data.get("summary", {}).get("errors", 0)
|
|
578
|
+
print(f"Gate check: failed={failed}, errors={errors}")
|
|
579
|
+
if failed > 0 or errors > 0:
|
|
580
|
+
sys.exit(1)
|
|
581
|
+
PY
|
|
582
|
+
|
|
583
|
+
- name: Upload reports
|
|
584
|
+
if: always()
|
|
585
|
+
uses: actions/upload-artifact@v4
|
|
586
|
+
with:
|
|
587
|
+
name: apptest-reports
|
|
588
|
+
path: reports/
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
Required repository configuration:
|
|
592
|
+
|
|
593
|
+
- Secret `APPTEST_API_KEY` (recommended), or both `APPTEST_USERNAME` and `APPTEST_PASSWORD`
|
|
594
|
+
- Optional repository variable `APPTEST_BASE_URL`
|
|
595
|
+
|
|
596
|
+
### Simple Workflow (URL + Username + Password Only)
|
|
597
|
+
|
|
598
|
+
Use this minimal option if you want the easiest integration path.
|
|
599
|
+
|
|
600
|
+
```yaml
|
|
601
|
+
name: apptest-simple
|
|
602
|
+
|
|
603
|
+
on:
|
|
604
|
+
workflow_dispatch:
|
|
605
|
+
pull_request:
|
|
606
|
+
branches: [ main ]
|
|
607
|
+
|
|
608
|
+
jobs:
|
|
609
|
+
apptest:
|
|
610
|
+
runs-on: ubuntu-latest
|
|
611
|
+
steps:
|
|
612
|
+
- uses: actions/checkout@v4
|
|
613
|
+
|
|
614
|
+
- uses: actions/setup-python@v5
|
|
615
|
+
with:
|
|
616
|
+
python-version: "3.11"
|
|
617
|
+
|
|
618
|
+
- name: Install
|
|
619
|
+
run: |
|
|
620
|
+
python -m pip install --upgrade pip
|
|
621
|
+
pip install -e .
|
|
622
|
+
|
|
623
|
+
- name: Run apptest
|
|
624
|
+
env:
|
|
625
|
+
APPTEST_BASE_URL: ${{ secrets.APPTEST_BASE_URL }}
|
|
626
|
+
APPTEST_USERNAME: ${{ secrets.APPTEST_USERNAME }}
|
|
627
|
+
APPTEST_PASSWORD: ${{ secrets.APPTEST_PASSWORD }}
|
|
628
|
+
run: |
|
|
629
|
+
apptest \
|
|
630
|
+
--base-url "$APPTEST_BASE_URL" \
|
|
631
|
+
--username "$APPTEST_USERNAME" \
|
|
632
|
+
--password "$APPTEST_PASSWORD"
|
|
633
|
+
|
|
634
|
+
- name: Upload reports
|
|
635
|
+
if: always()
|
|
636
|
+
uses: actions/upload-artifact@v4
|
|
637
|
+
with:
|
|
638
|
+
name: apptest-reports
|
|
639
|
+
path: reports/
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
Required secrets for the simple workflow:
|
|
643
|
+
|
|
644
|
+
- `APPTEST_BASE_URL`
|
|
645
|
+
- `APPTEST_USERNAME`
|
|
646
|
+
- `APPTEST_PASSWORD`
|
|
647
|
+
|
|
648
|
+
## Learn More
|
|
649
|
+
|
|
650
|
+
- [Executive Summary](docs/api-gate-keeper-executive-summary.md) — the problem, the approach, and why it matters, in a few paragraphs
|
|
651
|
+
- [Design Document](docs/api-gate-keeper-design.md) — full technical design: discovery, auth, execution, categories, reporting, and extension points
|
|
652
|
+
- [Test Categories](docs/api-gate-keeper-categories.md) — every check explained: what it tests, how, and why
|
|
653
|
+
- [Security Risk Brief](docs/api-gate-keeper-risk-brief.md) — what each test category protects against, why it matters, and the business impact of leaving it unaddressed
|
|
654
|
+
- [Deck Notes](docs/api-gate-keeper-deck.md) — copy/paste-ready slide content for internal readouts
|