hubric 0.5.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.
- hubric-0.5.0/LICENSE +21 -0
- hubric-0.5.0/PKG-INFO +395 -0
- hubric-0.5.0/README.md +353 -0
- hubric-0.5.0/hubric/__init__.py +6 -0
- hubric-0.5.0/hubric/__main__.py +5 -0
- hubric-0.5.0/hubric/auth/__init__.py +8 -0
- hubric-0.5.0/hubric/auth/classifier.py +187 -0
- hubric-0.5.0/hubric/auth/interviewer.py +497 -0
- hubric-0.5.0/hubric/auth/resolver.py +160 -0
- hubric-0.5.0/hubric/auth/schemes.py +188 -0
- hubric-0.5.0/hubric/auth/store.py +292 -0
- hubric-0.5.0/hubric/auth/verifier.py +325 -0
- hubric-0.5.0/hubric/cli/__init__.py +1 -0
- hubric-0.5.0/hubric/cli/commands/ci.py +53 -0
- hubric-0.5.0/hubric/cli/commands/forecast.py +241 -0
- hubric-0.5.0/hubric/cli/commands/inspect.py +76 -0
- hubric-0.5.0/hubric/cli/commands/payload.py +127 -0
- hubric-0.5.0/hubric/cli/commands/run.py +706 -0
- hubric-0.5.0/hubric/cli/commands/settings.py +44 -0
- hubric-0.5.0/hubric/cli/commands/trace.py +195 -0
- hubric-0.5.0/hubric/cli/helpers.py +527 -0
- hubric-0.5.0/hubric/cli/main.py +116 -0
- hubric-0.5.0/hubric/cli/tracer.py +109 -0
- hubric-0.5.0/hubric/config/__init__.py +5 -0
- hubric-0.5.0/hubric/config/loader.py +108 -0
- hubric-0.5.0/hubric/core/__init__.py +1 -0
- hubric-0.5.0/hubric/core/assertions.py +152 -0
- hubric-0.5.0/hubric/core/env.py +30 -0
- hubric-0.5.0/hubric/core/llm.py +545 -0
- hubric-0.5.0/hubric/core/schema.py +964 -0
- hubric-0.5.0/hubric/core/security.py +451 -0
- hubric-0.5.0/hubric/core/synthesizer.py +551 -0
- hubric-0.5.0/hubric/engine/__init__.py +1 -0
- hubric-0.5.0/hubric/engine/aggregator.py +211 -0
- hubric-0.5.0/hubric/engine/auth_pool.py +126 -0
- hubric-0.5.0/hubric/engine/dispatcher.py +69 -0
- hubric-0.5.0/hubric/engine/executor.py +792 -0
- hubric-0.5.0/hubric/engine/journey.py +806 -0
- hubric-0.5.0/hubric/engine/rate_limit.py +56 -0
- hubric-0.5.0/hubric/engine/registry.py +351 -0
- hubric-0.5.0/hubric/engine/runner.py +5 -0
- hubric-0.5.0/hubric/engine/scheduler.py +645 -0
- hubric-0.5.0/hubric/engine/types.py +55 -0
- hubric-0.5.0/hubric/engine/utils.py +214 -0
- hubric-0.5.0/hubric/forecast/__init__.py +0 -0
- hubric-0.5.0/hubric/forecast/analyzer.py +350 -0
- hubric-0.5.0/hubric/forecast/reporter.py +1234 -0
- hubric-0.5.0/hubric/report/__init__.py +1 -0
- hubric-0.5.0/hubric/report/diagnostics.py +122 -0
- hubric-0.5.0/hubric/report/export.py +14 -0
- hubric-0.5.0/hubric/report/export_html.py +158 -0
- hubric-0.5.0/hubric/report/export_json.py +23 -0
- hubric-0.5.0/hubric/report/html_assets.py +154 -0
- hubric-0.5.0/hubric/report/html_helpers.py +135 -0
- hubric-0.5.0/hubric/report/html_sections.py +429 -0
- hubric-0.5.0/hubric/report/junit.py +100 -0
- hubric-0.5.0/hubric/report/metrics.py +435 -0
- hubric-0.5.0/hubric/report/reporter.py +8 -0
- hubric-0.5.0/hubric/report/scoring.py +288 -0
- hubric-0.5.0/hubric/report/terminal.py +506 -0
- hubric-0.5.0/hubric/settings.py +355 -0
- hubric-0.5.0/hubric.egg-info/PKG-INFO +395 -0
- hubric-0.5.0/hubric.egg-info/SOURCES.txt +95 -0
- hubric-0.5.0/hubric.egg-info/dependency_links.txt +1 -0
- hubric-0.5.0/hubric.egg-info/entry_points.txt +3 -0
- hubric-0.5.0/hubric.egg-info/requires.txt +24 -0
- hubric-0.5.0/hubric.egg-info/top_level.txt +1 -0
- hubric-0.5.0/pyproject.toml +68 -0
- hubric-0.5.0/setup.cfg +4 -0
- hubric-0.5.0/tests/test_aggregator.py +146 -0
- hubric-0.5.0/tests/test_assertions_and_junit.py +134 -0
- hubric-0.5.0/tests/test_audit_regressions.py +311 -0
- hubric-0.5.0/tests/test_audit_regressions_v2.py +218 -0
- hubric-0.5.0/tests/test_auth_resolver.py +225 -0
- hubric-0.5.0/tests/test_cli_display.py +107 -0
- hubric-0.5.0/tests/test_config_loader.py +77 -0
- hubric-0.5.0/tests/test_core.py +18 -0
- hubric-0.5.0/tests/test_env_vars.py +79 -0
- hubric-0.5.0/tests/test_error_attribution.py +74 -0
- hubric-0.5.0/tests/test_journey.py +357 -0
- hubric-0.5.0/tests/test_oob_classification.py +64 -0
- hubric-0.5.0/tests/test_primitives_protocol.py +467 -0
- hubric-0.5.0/tests/test_registry.py +31 -0
- hubric-0.5.0/tests/test_reporter.py +124 -0
- hubric-0.5.0/tests/test_responsive_shielding.py +82 -0
- hubric-0.5.0/tests/test_scheduler_phases.py +170 -0
- hubric-0.5.0/tests/test_schema.py +76 -0
- hubric-0.5.0/tests/test_schema_constraints.py +246 -0
- hubric-0.5.0/tests/test_scoring.py +85 -0
- hubric-0.5.0/tests/test_secret_key_matching.py +77 -0
- hubric-0.5.0/tests/test_security_fixes.py +299 -0
- hubric-0.5.0/tests/test_security_hardening.py +331 -0
- hubric-0.5.0/tests/test_security_proficiency.py +68 -0
- hubric-0.5.0/tests/test_settings.py +106 -0
- hubric-0.5.0/tests/test_synthesizer.py +68 -0
- hubric-0.5.0/tests/test_synthesizer_constraints.py +210 -0
- hubric-0.5.0/tests/test_typescript_compatibility.py +121 -0
hubric-0.5.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
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.
|
hubric-0.5.0/PKG-INFO
ADDED
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hubric
|
|
3
|
+
Version: 0.5.0
|
|
4
|
+
Summary: Zero-config, LLM-powered API load tester.
|
|
5
|
+
Author: Hubric Team
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/adetu-siyan/rubric_lt
|
|
8
|
+
Project-URL: Repository, https://github.com/adetu-siyan/rubric_lt
|
|
9
|
+
Project-URL: Issues, https://github.com/adetu-siyan/rubric_lt/issues
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Software Development :: Testing
|
|
17
|
+
Classifier: Topic :: Software Development :: Testing :: Traffic Generation
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
Requires-Dist: click>=8.1.0
|
|
22
|
+
Requires-Dist: rich>=13.0.0
|
|
23
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
24
|
+
Requires-Dist: numpy>=1.24.0
|
|
25
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
26
|
+
Requires-Dist: pyyaml>=6.0
|
|
27
|
+
Requires-Dist: pydantic>=2.0
|
|
28
|
+
Requires-Dist: prompt_toolkit>=3.0
|
|
29
|
+
Requires-Dist: keyring>=24.0.0
|
|
30
|
+
Requires-Dist: certifi>=2024.0.0
|
|
31
|
+
Provides-Extra: groq
|
|
32
|
+
Requires-Dist: groq>=0.9.0; extra == "groq"
|
|
33
|
+
Provides-Extra: bedrock
|
|
34
|
+
Requires-Dist: boto3>=1.34.0; extra == "bedrock"
|
|
35
|
+
Provides-Extra: pdf
|
|
36
|
+
Requires-Dist: weasyprint>=60.0; extra == "pdf"
|
|
37
|
+
Provides-Extra: all
|
|
38
|
+
Requires-Dist: groq>=0.9.0; extra == "all"
|
|
39
|
+
Requires-Dist: boto3>=1.34.0; extra == "all"
|
|
40
|
+
Requires-Dist: weasyprint>=60.0; extra == "all"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# Hubric
|
|
44
|
+
|
|
45
|
+
[](https://pypi.org/project/hubric/)
|
|
46
|
+
[](https://opensource.org/licenses/MIT)
|
|
47
|
+
[](https://www.python.org/downloads/)
|
|
48
|
+
|
|
49
|
+
**Hubric** is a zero-config, LLM-powered API load tester and benchmark engine.
|
|
50
|
+
|
|
51
|
+
It ingests your live OpenAPI/Swagger schema, leverages fast LLMs (Groq, OpenAI, Anthropic, Bedrock) to synthesize realistic multi-tier test payloads, and executes high-concurrency stateful user flows—benchmarking latency against the **Apdex (Application Performance Index)** standard.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Key Features
|
|
56
|
+
|
|
57
|
+
- ⚡ **Zero-Scripting Schema Ingestion**: Automatically reads `/openapi.json` or local spec files (OpenAPI, Swagger, Postman, Blueprint) to categorize endpoints, path parameters, and request bodies.
|
|
58
|
+
- 🧠 **LLM-Powered Multi-Tier Payload Synthesis**:
|
|
59
|
+
- `happy_path`: Realistic, schema-valid data targeting production success.
|
|
60
|
+
- `edge_cases`: Boundary values, unicode, extreme numbers, and max-length strings.
|
|
61
|
+
- `malformed`: Invalid types and schema violations to test API error handling.
|
|
62
|
+
- 🚀 **High-Throughput Asynchronous Engine**: Built on Python `asyncio` and `aiohttp` proactor runtimes, featuring an adaptive auto-concurrency heuristic and ramp scheduler for high-volume sustained traffic.
|
|
63
|
+
- 🔄 **Stateful Multi-Step Journeys**: Automatically sequences dependent endpoints (`POST /orders` $\rightarrow$ `GET /orders/{id}`) by dynamically extracting identifiers, tokens, and cookies across requests.
|
|
64
|
+
- 📊 **Apdex Standard Scoring**: Calculates objective 0–100 user satisfaction ratings with dynamic latency baseline scaling for AI, streaming, and media workloads.
|
|
65
|
+
- 🛠️ **Dedicated CI/CD Pipeline Mode (`hubric ci`)**: Headless execution, configurable regression thresholds, and automated **JUnit XML** test artifact export.
|
|
66
|
+
- 📦 **Payload Pre-Caching (`hubric payload`)**: Pre-generate and cache synthetic payloads to a local reusable pool (`.hubric_cache/`), eliminating redundant LLM calls during repeated benchmark runs.
|
|
67
|
+
- 🔒 **Enterprise-Grade Security Architecture**: Multi-layer credential protection, atomic OS file permissions, header injection prevention, and linear-time PII/secret redaction.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
Requires Python 3.11+.
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pip install hubric
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
> **Windows Note:** To prevent Windows Defender or execution policy wrappers from interfering, you can always run Hubric directly via Python:
|
|
80
|
+
> ```bash
|
|
81
|
+
> python -m hubric run <url>
|
|
82
|
+
> ```
|
|
83
|
+
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
## Quickstart
|
|
87
|
+
|
|
88
|
+
Run a zero-config load test against any live API:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
hubric run http://localhost:8000
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### What Hubric Does:
|
|
95
|
+
1. **Schema Ingestion**: Fetches `/openapi.json` and classifies endpoints into Route Buckets:
|
|
96
|
+
- **Bucket A**: Script-generated parameter routes (GET, HEAD, DELETE).
|
|
97
|
+
- **Bucket B**: Independent mutations (POST, PUT, PATCH) requiring synthesized bodies.
|
|
98
|
+
- **Bucket C**: Stateful endpoints that depend on upstream resource IDs.
|
|
99
|
+
2. **Auth Discovery & Interview**: Automatically detects authentication schemes (Bearer JWT, API Key, Basic Auth, Cookies) and securely acquires/verifies a session token.
|
|
100
|
+
3. **Payload Synthesis**: Pre-flight LLM pass synthesizes realistic payloads and caches them in `.hubric_cache/`.
|
|
101
|
+
4. **4-Phase Traffic Dispatch**:
|
|
102
|
+
- *Phase 1a*: Independent writes (`POST`)
|
|
103
|
+
- *Phase 2*: Concurrent reads and updates (`GET`, `PUT`, `PATCH`)
|
|
104
|
+
- *Phase 3*: Destructive operations (`DELETE`)
|
|
105
|
+
- *Phase 4*: Session teardowns (`POST /logout`)
|
|
106
|
+
5. **Report Generation**: Outputs rich terminal statistics, standalone interactive HTML reports, and JSON telemetry.
|
|
107
|
+
|
|
108
|
+
---
|
|
109
|
+
|
|
110
|
+
## Commands & Usage
|
|
111
|
+
|
|
112
|
+
### 1. `hubric run` — Full Load Test
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# Run with 50 concurrent users
|
|
116
|
+
hubric run http://localhost:8000 --users 50
|
|
117
|
+
|
|
118
|
+
# Target a specific request-per-second (RPS) rate
|
|
119
|
+
hubric run http://localhost:8000 --rps 100
|
|
120
|
+
|
|
121
|
+
# Choose traffic pattern (ramp, spike, constant, step)
|
|
122
|
+
hubric run http://localhost:8000 --pattern ramp --users 100
|
|
123
|
+
|
|
124
|
+
# Test a specific endpoint only
|
|
125
|
+
hubric run http://localhost:8000 --endpoint "POST /api/items"
|
|
126
|
+
|
|
127
|
+
# Run all payload tiers (happy_path, edge_cases, malformed)
|
|
128
|
+
hubric run http://localhost:8000 --tier all
|
|
129
|
+
|
|
130
|
+
# Pass a local OpenAPI spec or Postman collection
|
|
131
|
+
hubric run http://localhost:8000 --spec ./openapi.yaml
|
|
132
|
+
|
|
133
|
+
# Pass authentication token directly
|
|
134
|
+
hubric run http://localhost:8000 --token "your-jwt-token"
|
|
135
|
+
|
|
136
|
+
# Multi-account simulation using a Token Pool (distributes rate limits across users)
|
|
137
|
+
hubric run https://api.example.com --tokens ./tokens.txt
|
|
138
|
+
|
|
139
|
+
# Skip brute-force login limits or session-destroying routes (/logout)
|
|
140
|
+
hubric run https://api.example.com --skip "POST /auth/login,POST /auth/logout"
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Handling Authentication & Rate Limits Under Load
|
|
144
|
+
|
|
145
|
+
When load testing APIs with protected routes and concurrent virtual users:
|
|
146
|
+
|
|
147
|
+
#### 1. Responsive Single-User Protection (Automatic)
|
|
148
|
+
When Hubric detects you are testing with a single authenticated account (and no `--tokens` multi-account pool):
|
|
149
|
+
- It **automatically shields** routes that would invalidate your session (e.g., `POST /logout`, `/signout`) or trigger 1-account brute-force rate limiters (e.g., `POST /auth/login`, `/forgot-password`, `/reset-password`).
|
|
150
|
+
- This guarantees your valid token remains intact throughout all testing phases and concurrent stages without getting hit by `429 Too Many Requests` or cascade `401 Unauthorized` errors.
|
|
151
|
+
- At the end of the test, Hubric displays an intelligent guidance nudge showing what was shielded and how to test those endpoints with `--tokens`.
|
|
152
|
+
- *(Note: If you explicitly specify an endpoint like `--endpoint "POST /auth/login"`, Hubric will honor your direct command and test it).*
|
|
153
|
+
|
|
154
|
+
#### 2. Multi-Account Virtual User Pools (`--tokens <file>`)
|
|
155
|
+
Testing with a single account causes all concurrent virtual users to share the same identity. On production-like APIs, this triggers brute-force rate limiters (e.g., 10 login requests/minute) or invalidates sessions for all virtual users when `/logout` is called.
|
|
156
|
+
|
|
157
|
+
Supply a `tokens.txt` file containing pre-generated tokens for multiple test users (one token per line):
|
|
158
|
+
```text
|
|
159
|
+
eyJhbGciOi... (user 1)
|
|
160
|
+
eyJhbGciOi... (user 2)
|
|
161
|
+
eyJhbGciOi... (user 3)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Run with `--tokens`:
|
|
165
|
+
```bash
|
|
166
|
+
hubric run https://api.example.com --tokens ./tokens.txt --users 25
|
|
167
|
+
```
|
|
168
|
+
Hubric round-robins requests across the pool, giving each virtual user their own rate-limit bucket and isolated session state.
|
|
169
|
+
|
|
170
|
+
#### 3. Exclude Lifecycle Routes (`--skip <endpoints>`)
|
|
171
|
+
If you want to manually exclude specific routes from testing:
|
|
172
|
+
```bash
|
|
173
|
+
hubric run https://api.example.com --skip "POST /auth/login,POST /auth/logout"
|
|
174
|
+
```
|
|
175
|
+
You can pass exact keys (`POST /auth/login`) or route substrings (`logout,login`).
|
|
176
|
+
|
|
177
|
+
#### 4. Staging Environment Best Practices
|
|
178
|
+
In staging environments, backend teams should either:
|
|
179
|
+
- Configure relaxed rate limits (e.g., `1000/min` instead of `10/min`).
|
|
180
|
+
- Add a rate-limit bypass header (e.g., `X-RateLimit-Bypass`) for automated load test suites.
|
|
181
|
+
- Whitelist the test runner IP address from rate limit middleware.
|
|
182
|
+
|
|
183
|
+
### 2. `hubric ci` — Non-Interactive CI/CD Automation
|
|
184
|
+
|
|
185
|
+
Designed specifically for automated deployment pipelines (GitHub Actions, GitLab CI, Jenkins):
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
hubric ci http://localhost:8000 --users 20 --junit junit.xml --fail-on-degraded
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
- **Non-interactive & Headless**: Automatically disables browser popups (`--no-open`) and interactive credential interviews.
|
|
192
|
+
- **JUnit XML Export**: Saves standard JUnit XML test results (`--junit <path>`) for native test reporting in CI/CD platforms.
|
|
193
|
+
- **Fail Gates**: Exits with exit code `1` if any endpoint fails SLA or if `--fail-on-degraded` is tripped.
|
|
194
|
+
|
|
195
|
+
#### Example: GitHub Actions Workflow
|
|
196
|
+
```yaml
|
|
197
|
+
name: API Load & Regression Test
|
|
198
|
+
on: [push, pull_request]
|
|
199
|
+
|
|
200
|
+
jobs:
|
|
201
|
+
load-test:
|
|
202
|
+
runs-on: ubuntu-latest
|
|
203
|
+
steps:
|
|
204
|
+
- uses: actions/checkout@v4
|
|
205
|
+
- uses: actions/setup-python@v5
|
|
206
|
+
with:
|
|
207
|
+
python-version: '3.11'
|
|
208
|
+
- name: Install Hubric
|
|
209
|
+
run: pip install hubric
|
|
210
|
+
- name: Run CI Load Test
|
|
211
|
+
env:
|
|
212
|
+
HUBRIC_AUTH_TOKEN: ${{ secrets.TEST_API_TOKEN }}
|
|
213
|
+
GROQ_API_KEY: ${{ secrets.GROQ_API_KEY }}
|
|
214
|
+
run: |
|
|
215
|
+
hubric ci http://localhost:8000 --users 25 --junit report.xml --fail-on-degraded
|
|
216
|
+
- name: Publish Test Results
|
|
217
|
+
uses: EnricoMi/publish-unit-test-result-action@v2
|
|
218
|
+
if: always()
|
|
219
|
+
with:
|
|
220
|
+
files: report.xml
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### 3. `hubric payload` — Pre-Flight Payload Synthesis
|
|
224
|
+
|
|
225
|
+
Generate and cache synthetic test payloads before running a test:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Pre-synthesize 5 payloads per endpoint across all tiers
|
|
229
|
+
hubric payload http://localhost:8000 --count 5 --tier all
|
|
230
|
+
|
|
231
|
+
# Export generated payloads to a custom JSON file
|
|
232
|
+
hubric payload http://localhost:8000 --out payloads.json
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 4. `hubric inspect` — API Schema Inspection
|
|
236
|
+
|
|
237
|
+
Inspect discovered routes, parameters, and auth requirements without sending test traffic:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
hubric inspect http://localhost:8000
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### 5. `hubric settings` — LLM & Provider Configuration
|
|
244
|
+
|
|
245
|
+
Configure LLM provider keys and default inference models:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
# Interactive setup wizard
|
|
249
|
+
hubric settings --configure-llm
|
|
250
|
+
|
|
251
|
+
# View active provider and configuration
|
|
252
|
+
hubric settings
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## LLM Provider Configuration
|
|
258
|
+
|
|
259
|
+
Hubric supports **Groq** (ultra-fast LPU inference, default), **OpenAI**, **Anthropic**, **OpenRouter**, and **AWS Bedrock**.
|
|
260
|
+
|
|
261
|
+
You can configure your provider via:
|
|
262
|
+
|
|
263
|
+
### Option A: Interactive Wizard
|
|
264
|
+
```bash
|
|
265
|
+
hubric settings --configure-llm
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Option B: Environment Variables
|
|
269
|
+
Create a `.env` file or export environment variables:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Provider Selection (groq, openai, anthropic, openrouter, bedrock)
|
|
273
|
+
HUBRIC_PROVIDER=groq
|
|
274
|
+
|
|
275
|
+
# Groq (Default)
|
|
276
|
+
GROQ_API_KEY=gsk_...
|
|
277
|
+
GROQ_MODEL=qwen/qwen3.8-27b
|
|
278
|
+
GROQ_FAST_MODEL=openai/gpt-oss-20b
|
|
279
|
+
|
|
280
|
+
# OpenAI
|
|
281
|
+
OPENAI_API_KEY=sk-...
|
|
282
|
+
OPENAI_MODEL=gpt-4o-mini
|
|
283
|
+
|
|
284
|
+
# Anthropic
|
|
285
|
+
ANTHROPIC_API_KEY=sk-ant-...
|
|
286
|
+
ANTHROPIC_MODEL=claude-haiku-4-5-20251001
|
|
287
|
+
|
|
288
|
+
# AWS Bedrock
|
|
289
|
+
AWS_REGION=us-east-1
|
|
290
|
+
AWS_ACCESS_KEY_ID=AKIA...
|
|
291
|
+
AWS_SECRET_ACCESS_KEY=...
|
|
292
|
+
BEDROCK_MODEL=us.meta.llama3-1-70b-instruct-v1:0
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## Declarative Configuration (`hubric.json`)
|
|
298
|
+
|
|
299
|
+
Standardize test parameters across your repository by committing a `hubric.json` or `hubric.yaml` to your project root:
|
|
300
|
+
|
|
301
|
+
```json
|
|
302
|
+
{
|
|
303
|
+
"target": "http://localhost:8000",
|
|
304
|
+
"users": 50,
|
|
305
|
+
"pattern": "ramp",
|
|
306
|
+
"tier": "happy_path",
|
|
307
|
+
"assertions": [
|
|
308
|
+
"status < 500",
|
|
309
|
+
"p95 < 500"
|
|
310
|
+
],
|
|
311
|
+
"fail_on_degraded": true
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Whenever `hubric.json` is present in your working directory, simply run:
|
|
316
|
+
```bash
|
|
317
|
+
hubric run
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## Performance Benchmarks & Apdex Scoring
|
|
323
|
+
|
|
324
|
+
Hubric measures user satisfaction using the **Apdex (Application Performance Index)** standard:
|
|
325
|
+
|
|
326
|
+
$$\text{Apdex} = \frac{\text{Satisfied} + \frac{\text{Tolerating}}{2}}{\text{Total Requests}}$$
|
|
327
|
+
|
|
328
|
+
Where requests are categorized against target latency threshold $T$:
|
|
329
|
+
- **Satisfied**: Response time $\le T$, zero HTTP error.
|
|
330
|
+
- **Tolerating**: $T < \text{Response time} \le 4T$, zero HTTP error.
|
|
331
|
+
- **Frustrated**: Response time $> 4T$ or HTTP failure ($5xx$, connection drops, non-validation $4xx$).
|
|
332
|
+
|
|
333
|
+
### Target Latencies ($T$)
|
|
334
|
+
- **Read routes (GET/HEAD/DELETE)**: $T = 300\text{ms}$, degraded $\le 999\text{ms}$.
|
|
335
|
+
- **Write mutations (POST/PUT/PATCH)**: $T = 1000\text{ms}$, degraded $\le 3999\text{ms}$.
|
|
336
|
+
- **Media / File Uploads**: $T = 5000\text{ms}$, degraded $\le 15000\text{ms}$.
|
|
337
|
+
- **Generative AI & Streaming**: Specialized thresholds ($1000\text{ms}$ for SSE streams, $5000\text{ms}$ for chat, $15000\text{ms}$ for image diffusion).
|
|
338
|
+
- **Dynamic SLA Scaling**: If observed single-request baseline latency $L_{\text{base}} \ge 1500\text{ms}$, thresholds scale proportionally ($2.0 \times L_{\text{base}}$ pass, $4.5 \times L_{\text{base}}$ degraded).
|
|
339
|
+
|
|
340
|
+
### Suite Score vs. Suite Verdict (Weighting)
|
|
341
|
+
- **Suite Apdex Score**: Arithmetic average across all *tested* endpoints:
|
|
342
|
+
$$\text{Suite Score} = \text{round}\left(\frac{\sum_{i=1}^N \text{score}_i}{N}\right)$$
|
|
343
|
+
Endpoints skipped by auth or classified as untested report `score: None` and do not skew the average.
|
|
344
|
+
- **Suite Verdict**: Evaluated via strictest-gate policy:
|
|
345
|
+
- If any tested endpoint receives `FAILED` (e.g. error rate $\ge 5\%$ or $p95 > 4T$), the overall suite verdict is **`SUITE FAILED`**, ensuring critical service failures are never masked by high scores on secondary endpoints.
|
|
346
|
+
- If any endpoint is `DEGRADED`, the suite verdict is **`PARTIAL PASS`**.
|
|
347
|
+
- Only when all tested endpoints achieve `PASSED` does the suite receive **`ALL PASSED`**.
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## Security Architecture
|
|
352
|
+
|
|
353
|
+
Hubric is engineered under strict Application Security (AppSec) guidelines to ensure that testing untrusted or external APIs never compromises the developer's machine, credentials, or privacy.
|
|
354
|
+
|
|
355
|
+
### 1. Atomic Kernel-Level Private Writes (`write_private`)
|
|
356
|
+
- All secret-bearing configuration files (`~/.hubric/config.json`) and session tokens are written with **POSIX `0o600` (owner-only)** permissions at creation time (`os.open`).
|
|
357
|
+
- **Windows ACL Hardening**: On Windows, where POSIX permissions are ignored, Hubric invokes native `icacls` to strip inherited directory permissions and explicitly restrict access to the active user SID only, eliminating file-access race conditions.
|
|
358
|
+
|
|
359
|
+
### 2. Multi-Pass PII & Credential Redaction Engine
|
|
360
|
+
- Before request telemetry is rendered to HTML, saved to disk, or sent to an LLM for root-cause diagnosis, it passes through recursive redaction:
|
|
361
|
+
- **Header & Token Sanitization**: Masks JWTs, Bearer tokens, PEM private keys, and Basic Auth headers.
|
|
362
|
+
- **Free-Text JSON/KV Scanners**: Linear-time scanners identify `"key": value` and `key=value` patterns even in truncated or malformed HTTP response bodies.
|
|
363
|
+
- **Bounded Redaction**: Strict word-boundary checks prevent false-positive masking on normal metric keys like `passed` or `pass_threshold`.
|
|
364
|
+
|
|
365
|
+
### 3. Header & Cookie Smuggling Protection (`_safe_token_text`)
|
|
366
|
+
- Prevents malicious or hostile OpenAPI specs from injecting unauthorized headers or smuggling cookies:
|
|
367
|
+
- Header names and auth prefixes are validated against strict RFC 7230 token specifications.
|
|
368
|
+
- Dangerous hop-by-hop and routing headers (`Host`, `Transfer-Encoding`, etc.) are explicitly blocked from being hijacked by an API schema.
|
|
369
|
+
|
|
370
|
+
### 4. Terminal Injection Defenses (`terminal_safe`)
|
|
371
|
+
- When printing server responses or error diagnostics to stdout, all ANSI/VT C0/C1 control characters are stripped. This neutralizes terminal escape sequence injection attacks from untrusted remote APIs.
|
|
372
|
+
|
|
373
|
+
### 5. Provider Isolation
|
|
374
|
+
- LLM API keys and AWS credentials configured for one provider (e.g. Groq) are strictly isolated and never forwarded if you switch providers via environment variable or CLI flag.
|
|
375
|
+
|
|
376
|
+
---
|
|
377
|
+
|
|
378
|
+
## Project Architecture
|
|
379
|
+
|
|
380
|
+
```text
|
|
381
|
+
hubric/
|
|
382
|
+
├── auth/ # Auth scheme detection, interview wizard, and token pools
|
|
383
|
+
├── cli/ # Click CLI commands (run, ci, payload, inspect, settings, trace)
|
|
384
|
+
├── config/ # Declarative hubric.json/yaml loader
|
|
385
|
+
├── core/ # Schema parser, LLM client, Pydantic synthesizers, security layer
|
|
386
|
+
├── engine/ # Async runner, stateful user journeys, reservoir aggregator, dispatcher
|
|
387
|
+
├── forecast/ # Predictive performance analyzer
|
|
388
|
+
└── report/ # Modular HTML report generator, Apdex metrics, JUnit XML exporter
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## License
|
|
394
|
+
|
|
395
|
+
Distributed under the MIT License. See `LICENSE` for more information.
|