humanbound-cli 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.
Files changed (39) hide show
  1. humanbound_cli-0.1.0/LICENSE +21 -0
  2. humanbound_cli-0.1.0/PKG-INFO +498 -0
  3. humanbound_cli-0.1.0/README.md +471 -0
  4. humanbound_cli-0.1.0/humanbound_cli/__init__.py +3 -0
  5. humanbound_cli-0.1.0/humanbound_cli/client.py +875 -0
  6. humanbound_cli-0.1.0/humanbound_cli/commands/__init__.py +17 -0
  7. humanbound_cli-0.1.0/humanbound_cli/commands/auth.py +121 -0
  8. humanbound_cli-0.1.0/humanbound_cli/commands/docs.py +104 -0
  9. humanbound_cli-0.1.0/humanbound_cli/commands/experiments.py +339 -0
  10. humanbound_cli-0.1.0/humanbound_cli/commands/guardrails.py +130 -0
  11. humanbound_cli-0.1.0/humanbound_cli/commands/init.py +632 -0
  12. humanbound_cli-0.1.0/humanbound_cli/commands/logs.py +232 -0
  13. humanbound_cli-0.1.0/humanbound_cli/commands/orgs.py +80 -0
  14. humanbound_cli-0.1.0/humanbound_cli/commands/posture.py +224 -0
  15. humanbound_cli-0.1.0/humanbound_cli/commands/projects.py +188 -0
  16. humanbound_cli-0.1.0/humanbound_cli/commands/providers.py +335 -0
  17. humanbound_cli-0.1.0/humanbound_cli/commands/scan.py +1 -0
  18. humanbound_cli-0.1.0/humanbound_cli/commands/test.py +448 -0
  19. humanbound_cli-0.1.0/humanbound_cli/config.py +40 -0
  20. humanbound_cli-0.1.0/humanbound_cli/exceptions.py +58 -0
  21. humanbound_cli-0.1.0/humanbound_cli/extractors/__init__.py +6 -0
  22. humanbound_cli-0.1.0/humanbound_cli/extractors/openapi.py +203 -0
  23. humanbound_cli-0.1.0/humanbound_cli/extractors/repo.py +305 -0
  24. humanbound_cli-0.1.0/humanbound_cli/main.py +156 -0
  25. humanbound_cli-0.1.0/humanbound_cli/pytest_plugin/__init__.py +209 -0
  26. humanbound_cli-0.1.0/humanbound_cli/pytest_plugin/fixtures.py +372 -0
  27. humanbound_cli-0.1.0/humanbound_cli/pytest_plugin/report.py +129 -0
  28. humanbound_cli-0.1.0/humanbound_cli.egg-info/PKG-INFO +498 -0
  29. humanbound_cli-0.1.0/humanbound_cli.egg-info/SOURCES.txt +37 -0
  30. humanbound_cli-0.1.0/humanbound_cli.egg-info/dependency_links.txt +1 -0
  31. humanbound_cli-0.1.0/humanbound_cli.egg-info/entry_points.txt +5 -0
  32. humanbound_cli-0.1.0/humanbound_cli.egg-info/requires.txt +11 -0
  33. humanbound_cli-0.1.0/humanbound_cli.egg-info/top_level.txt +3 -0
  34. humanbound_cli-0.1.0/pyproject.toml +58 -0
  35. humanbound_cli-0.1.0/setup.cfg +4 -0
  36. humanbound_cli-0.1.0/tests/__init__.py +1 -0
  37. humanbound_cli-0.1.0/tests/cli_integration_test.py +1593 -0
  38. humanbound_cli-0.1.0/tests/conftest.py +210 -0
  39. humanbound_cli-0.1.0/tests/test_cli_commands.py +188 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Humanbound
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,498 @@
1
+ Metadata-Version: 2.1
2
+ Name: humanbound-cli
3
+ Version: 0.1.0
4
+ Summary: Humanbound CLI - command line interface for AI agent security testing.
5
+ Author-email: Kostas Siabanis <hello@humanbound.io>, Demetris Gerogiannis <hello@humanbound.io>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/Humanbound/humanbound-cli
8
+ Project-URL: Documentation, https://docs.humanbound.io/cli
9
+ Project-URL: Issues, https://github.com/Humanbound/humanbound-cli/issues
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Environment :: Console
14
+ Classifier: Framework :: Pytest
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: click>=8.1.0
19
+ Requires-Dist: rich>=13.0.0
20
+ Requires-Dist: requests>=2.32.0
21
+ Requires-Dist: pyyaml>=6.0.0
22
+ Provides-Extra: pytest
23
+ Requires-Dist: pytest>=7.0.0; extra == "pytest"
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
27
+
28
+ # Humanbound CLI (Beta)
29
+
30
+ > CLI-first security testing for AI agents and chatbots. Adversarial attacks, behavioral QA, posture scoring, and guardrails export — from your terminal to your CI/CD pipeline.
31
+
32
+ [![PyPI](https://img.shields.io/pypi/v/humanbound-cli)](https://pypi.org/project/humanbound-cli/)
33
+ [![License](https://img.shields.io/badge/license-proprietary-blue)]()
34
+
35
+ ```
36
+ pip install humanbound-cli
37
+ ```
38
+
39
+ ---
40
+
41
+ ## Overview
42
+
43
+ Humanbound runs automated adversarial attacks against your bot's live endpoint, evaluates responses using LLM-as-a-judge, and produces structured findings aligned with the [OWASP Top 10 for LLM Applications](https://owasp.org/www-project-top-10-for-large-language-model-applications/) and the [OWASP Agentic AI Threats](https://genai.owasp.org/resource/agentic-ai-threats-and-mitigations/).
44
+
45
+ ### Platform Services
46
+
47
+ | Service | Description |
48
+ |---------|-------------|
49
+ | **CLI Tool** | Full-featured command line interface. Initialize projects, run tests, check posture, export guardrails. |
50
+ | **pytest Plugin** | Native pytest integration with markers, fixtures, and baseline comparison. Run security tests alongside unit tests. |
51
+ | **Adversarial Testing** | OWASP-aligned attack scenarios: single-turn, multi-turn, adaptive, and agentic. |
52
+ | **Behavioral Testing** | Validate intent boundaries, response quality, and functional correctness. |
53
+ | **Posture Scoring** | Quantified 0-100 security score with breakdown by findings, coverage, and resilience. Track over time. |
54
+ | **Guardrails Export** | Generate protection rules from test findings. Export to OpenAI, Azure AI Content Safety, AWS Bedrock, or Humanbound format. |
55
+
56
+ ### Why Humanbound?
57
+
58
+ Manual red-teaming doesn't scale. Static analysis can't catch runtime behavior. Generic pentesting tools don't understand LLM-specific attack vectors like prompt injection, jailbreaks, or tool abuse.
59
+
60
+ Humanbound is built for this. Point it at your bot's endpoint, define the scope (or let it extract one from your system prompt), and get a structured security report with actionable findings — all mapped to OWASP LLM and Agentic AI categories.
61
+
62
+ Testing feeds into hardening: export guardrails, track posture across releases, and catch regressions before they reach production. Works with any chatbot or agent, cloud or on-prem.
63
+
64
+ ---
65
+
66
+ ## Get Started
67
+
68
+ ### 1. Install & authenticate
69
+
70
+ ```bash
71
+ pip install humanbound-cli
72
+ hb login
73
+ ```
74
+
75
+ ### 2. Scan your bot & create a project
76
+
77
+ `hb init` scans your bot, extracts its scope and risk profile, and creates a project — all in one step. Point it at one or more sources:
78
+
79
+ ```bash
80
+ # From a system prompt file
81
+ hb init -n "My Bot" --prompt ./system_prompt.txt
82
+
83
+ # From a live bot endpoint (API probing)
84
+ hb init -n "My Bot" -e ./bot-config.json
85
+
86
+ # From a live URL (browser discovery)
87
+ hb init -n "My Bot" -u https://my-bot.example.com
88
+
89
+ # Combine sources for better analysis
90
+ hb init -n "My Bot" --prompt ./system.txt -e ./bot-config.json
91
+ ```
92
+
93
+ The `--endpoint/-e` flag accepts a JSON config (file or inline string) matching the experiment integration shape:
94
+
95
+ ```json
96
+ {
97
+ "streaming": false,
98
+ "thread_auth": {"endpoint": "", "headers": {}, "payload": {}},
99
+ "thread_init": {"endpoint": "https://bot.com/threads", "headers": {}, "payload": {}},
100
+ "chat_completion": {"endpoint": "https://bot.com/chat", "headers": {"Authorization": "Bearer token"}, "payload": {"content": "$PROMPT"}}
101
+ }
102
+ ```
103
+
104
+ After scanning, you'll see the extracted scope, policies (permitted/restricted intents), and a risk dashboard with threat profile. Confirm to create the project.
105
+
106
+ ### 3. Run a security test
107
+
108
+ ```bash
109
+ # Run against your bot (uses project's default integration if configured during init)
110
+ hb test
111
+
112
+ # Or specify an endpoint directly
113
+ hb test -e ./bot-config.json
114
+
115
+ # Choose test category and depth
116
+ hb test -t owasp_multi_turn -l system
117
+ ```
118
+
119
+ ### 4. Review results
120
+
121
+ ```bash
122
+ # Watch experiment progress
123
+ hb status --watch
124
+
125
+ # View logs
126
+ hb logs
127
+
128
+ # Check posture score
129
+ hb posture
130
+
131
+ # Export guardrails
132
+ hb guardrails --vendor openai -o guardrails.json
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Test Categories
138
+
139
+ | Category | Mode | Description |
140
+ |----------|------|-------------|
141
+ | `owasp_single_turn` | Adversarial | Single-prompt attacks: prompt injection, jailbreaks, data exfiltration. Fast coverage of basic vulnerabilities. |
142
+ | `owasp_multi_turn` | Adversarial | Conversational attacks that build context over multiple turns. Tests context manipulation and gradual escalation. |
143
+ | `owasp_agentic_multi_turn` | Adversarial | Targets tool-using agents. Tests goal hijacking, tool misuse, and privilege escalation. |
144
+ | `behavioral` | QA | Intent boundary validation and response quality testing. Ensures agent behaves within defined scope. |
145
+
146
+ **Adaptive mode:** Both `owasp_multi_turn` and `owasp_agentic_multi_turn` support an adaptive flag that enables evolutionary search — the attack strategy adapts based on bot responses instead of following scripted prompts.
147
+
148
+ ### Testing Levels
149
+
150
+ | Level | Description |
151
+ |-------|-------------|
152
+ | `unit` | Standard coverage (~20 min) — default |
153
+ | `system` | Deep testing (~45 min) |
154
+ | `acceptance` | Full coverage (~90 min) |
155
+
156
+ ---
157
+
158
+ ## pytest Integration
159
+
160
+ Run security tests alongside your existing test suite with native pytest markers and fixtures.
161
+
162
+ ```python
163
+ # test_security.py
164
+ import pytest
165
+
166
+ @pytest.mark.hb
167
+ def test_prompt_injection(hb):
168
+ """Test prompt injection defenses."""
169
+ result = hb.test("llm001")
170
+ assert result.passed, f"Failed: {result.findings}"
171
+
172
+ @pytest.mark.hb
173
+ def test_posture_threshold(hb_posture):
174
+ """Ensure posture meets minimum."""
175
+ assert hb_posture["score"] >= 70
176
+
177
+ @pytest.mark.hb
178
+ def test_no_regressions(hb, hb_baseline):
179
+ """Compare against baseline."""
180
+ result = hb.test("llm001")
181
+ if hb_baseline:
182
+ regressions = result.compare(hb_baseline)
183
+ assert not regressions
184
+ ```
185
+
186
+ ```bash
187
+ # Run with Humanbound enabled
188
+ pytest --hb tests/
189
+
190
+ # Filter by category
191
+ pytest --hb --hb-category=adversarial
192
+
193
+ # Set failure threshold
194
+ pytest --hb --hb-fail-on=high
195
+
196
+ # Compare to baseline
197
+ pytest --hb --hb-baseline=baseline.json
198
+
199
+ # Save new baseline
200
+ pytest --hb --hb-save-baseline=baseline.json
201
+ ```
202
+
203
+ ---
204
+
205
+ ## CI/CD Integration
206
+
207
+ Block insecure deployments automatically with exit codes.
208
+
209
+ ```
210
+ Build -> Unit Tests -> AI Security (hb test) -> Deploy
211
+ ```
212
+
213
+ ```yaml
214
+ # .github/workflows/security.yml
215
+ name: AI Security Tests
216
+ on: [push, pull_request]
217
+
218
+ jobs:
219
+ security:
220
+ runs-on: ubuntu-latest
221
+ steps:
222
+ - uses: actions/checkout@v4
223
+ - run: pip install humanbound-cli
224
+ - name: Run Security Tests
225
+ env:
226
+ HUMANBOUND_API_KEY: ${{ secrets.HUMANBOUND_API_KEY }}
227
+ run: |
228
+ hb test --wait --fail-on=high
229
+ ```
230
+
231
+ ---
232
+
233
+ ## Usage
234
+
235
+ ```
236
+ hb [--base-url URL] COMMAND [OPTIONS] [ARGS]
237
+ ```
238
+
239
+ ### Authentication
240
+
241
+ | Command | Description |
242
+ |---------|-------------|
243
+ | `login` | Authenticate via browser (OAuth PKCE) |
244
+ | `logout` | Clear stored credentials |
245
+ | `whoami` | Show current authentication status |
246
+
247
+ ### Organisation Management
248
+
249
+ | Command | Description |
250
+ |---------|-------------|
251
+ | `orgs list` | List available organisations |
252
+ | `orgs current` | Show current organisation |
253
+ | `switch <id>` | Switch to organisation |
254
+
255
+ ### Provider Management
256
+
257
+ Providers are LLM configurations used for running security tests.
258
+
259
+ | Command | Description |
260
+ |---------|-------------|
261
+ | `providers list` | List configured providers |
262
+ | `providers add` | Add new provider |
263
+ | `providers update <id>` | Update provider config |
264
+ | `providers remove <id>` | Remove provider |
265
+
266
+ <details>
267
+ <summary><code>providers add</code> options</summary>
268
+
269
+ ```
270
+ --name, -n Provider name: openai, claude, azureopenai, gemini, grok, custom
271
+ --api-key, -k API key
272
+ --endpoint, -e Endpoint URL (required for azureopenai, custom)
273
+ --model, -m Model name (optional)
274
+ --default Set as default provider
275
+ --interactive Interactive configuration mode
276
+ ```
277
+
278
+ </details>
279
+
280
+ ### Project Management
281
+
282
+ | Command | Description |
283
+ |---------|-------------|
284
+ | `projects list` | List projects |
285
+ | `projects use <id>` | Select project |
286
+ | `projects current` | Show current project |
287
+ | `projects show [id]` | Show project details |
288
+
289
+ <details>
290
+ <summary><code>init</code> — scan bot & create project</summary>
291
+
292
+ ```
293
+ hb init --name NAME [OPTIONS]
294
+
295
+ Sources (at least one required):
296
+ --prompt, -p PATH System prompt file (text source)
297
+ --url, -u URL Live bot URL for browser discovery (url source)
298
+ --endpoint, -e CONFIG Bot integration config — JSON string or file path (endpoint source)
299
+ --repo, -r PATH Repository path to scan (agentic or text source)
300
+ --openapi, -o PATH OpenAPI spec file (text source)
301
+
302
+ Options:
303
+ --description, -d Project description
304
+ --timeout, -t SECONDS Scan timeout (default: 180)
305
+ --yes, -y Auto-confirm project creation (no interactive prompts)
306
+ ```
307
+
308
+ </details>
309
+
310
+ ### Test Execution
311
+
312
+ <details>
313
+ <summary><code>test</code> — run security tests on current project</summary>
314
+
315
+ ```
316
+ hb test [OPTIONS]
317
+
318
+ Test Category:
319
+ --test-category, -t Test to run (default: owasp_multi_turn)
320
+ Values: owasp_single_turn, owasp_multi_turn,
321
+ owasp_agentic_multi_turn, behavioral
322
+
323
+ Testing Level:
324
+ --testing-level, -l Depth of testing (default: unit)
325
+ unit | system | acceptance
326
+
327
+ Chat Endpoint (required):
328
+ --chat-endpoint Chat completion URL of the bot to test
329
+ --chat-header Header for chat endpoint (repeatable)
330
+ --chat-payload JSON payload template for chat
331
+
332
+ Init Endpoint (optional):
333
+ --init-endpoint Thread initialization URL
334
+ --init-header Header for init endpoint (repeatable)
335
+ --init-payload JSON payload for init
336
+
337
+ Auth Endpoint (optional):
338
+ --auth-endpoint Auth/token endpoint URL
339
+ --auth-header Header for auth endpoint (repeatable)
340
+ --auth-payload JSON payload for auth
341
+
342
+ Other:
343
+ --provider-id Provider to use (default: first available)
344
+ --name, -n Experiment name (auto-generated if omitted)
345
+ --lang Language (default: english). Accepts codes: en, de, es...
346
+ --adaptive Enable adaptive mode (evolutionary attack strategy)
347
+ --streaming Enable streaming mode (requires wss:// endpoint)
348
+ --no-auto-start Create without starting (manual mode)
349
+ --wait, -w Wait for completion
350
+ --fail-on SEVERITY Exit non-zero if findings >= severity
351
+ Values: critical, high, medium, low, any
352
+ ```
353
+
354
+ </details>
355
+
356
+ ### Experiment Management
357
+
358
+ | Command | Description |
359
+ |---------|-------------|
360
+ | `experiments list` | List experiments |
361
+ | `experiments show <id>` | Show experiment details |
362
+ | `experiments status <id>` | Check status |
363
+ | `experiments status <id> --watch` | Watch until completion |
364
+ | `experiments wait <id>` | Wait with progressive backoff (30s -> 60s -> 120s -> 300s) |
365
+ | `experiments logs <id>` | List experiment logs |
366
+ | `experiments report <id>` | Download HTML report |
367
+
368
+ `status` is also available as a top-level alias — without an ID it shows the most recent experiment:
369
+
370
+ ```bash
371
+ hb status [experiment_id] [--watch]
372
+ ```
373
+
374
+ ### Results & Export
375
+
376
+ ```bash
377
+ # View experiment results (table, json, or csv)
378
+ hb logs [experiment_id] [--format table] [--verdict pass|fail] [--page N] [--size N]
379
+
380
+ # Security posture score
381
+ hb posture [--json]
382
+
383
+ # Export guardrails configuration
384
+ hb guardrails [--vendor humanbound|openai] [--format json|yaml] [-o FILE]
385
+ ```
386
+
387
+ ### Documentation
388
+
389
+ ```bash
390
+ hb docs
391
+ ```
392
+
393
+ Opens documentation in browser.
394
+
395
+ ---
396
+
397
+ ## Examples
398
+
399
+ ### End-to-end: scan, create project, test, review
400
+
401
+ ```bash
402
+ hb login
403
+ hb switch abc123
404
+
405
+ # Scan bot & create project (uses endpoint config file)
406
+ hb init -n "Support Bot" -e ./bot-config.json
407
+
408
+ # Run adversarial test (uses project's default integration)
409
+ hb test -t owasp_multi_turn -l unit
410
+
411
+ # Watch and review
412
+ hb status --watch
413
+ hb logs
414
+ hb posture
415
+ ```
416
+
417
+ ### Multi-source project init
418
+
419
+ ```bash
420
+ # Combine system prompt + live endpoint for best scope extraction
421
+ hb init \
422
+ --name "Support Bot" \
423
+ --prompt ./prompts/system.txt \
424
+ --endpoint ./bot-config.json
425
+
426
+ # From repository + OpenAPI spec
427
+ hb init \
428
+ --name "API Agent" \
429
+ --repo ./my-agent \
430
+ --openapi ./openapi.yaml
431
+ ```
432
+
433
+ ### Bot config with auth + thread init
434
+
435
+ ```json
436
+ {
437
+ "streaming": false,
438
+ "thread_auth": {
439
+ "endpoint": "https://bot.com/oauth/token",
440
+ "headers": {},
441
+ "payload": {"client_id": "x", "client_secret": "y"}
442
+ },
443
+ "thread_init": {
444
+ "endpoint": "https://bot.com/threads",
445
+ "headers": {"Content-Type": "application/json"},
446
+ "payload": {}
447
+ },
448
+ "chat_completion": {
449
+ "endpoint": "https://bot.com/chat",
450
+ "headers": {"Content-Type": "application/json"},
451
+ "payload": {"messages": [{"role": "user", "content": "$PROMPT"}]}
452
+ }
453
+ }
454
+ ```
455
+
456
+ ```bash
457
+ # Use with init or test
458
+ hb init -n "My Bot" -e ./bot-config.json
459
+ hb test -e ./bot-config.json
460
+ ```
461
+
462
+ ### Export guardrails
463
+
464
+ ```bash
465
+ hb guardrails --vendor openai --format json -o guardrails.json
466
+ ```
467
+
468
+ ---
469
+
470
+ ### On-Premises
471
+
472
+ ```bash
473
+ export HUMANBOUND_BASE_URL=https://api.your-domain.com
474
+ hb login
475
+ ```
476
+
477
+ ### Files
478
+
479
+ | Path | Description |
480
+ |------|-------------|
481
+ | `~/.humanbound/` | Configuration directory |
482
+ | `~/.humanbound/credentials.json` | Auth tokens (mode `600`) |
483
+
484
+ ---
485
+
486
+ ## Exit Codes
487
+
488
+ | Code | Meaning |
489
+ |------|---------|
490
+ | `0` | Success |
491
+ | `1` | Error or test failure (with `--fail-on`) |
492
+
493
+ ---
494
+
495
+ ## Links
496
+
497
+ - [Documentation](https://docs.humanbound.io)
498
+ - [GitHub](https://github.com/Humanbound/humanbound-cli)