pyntrace 0.5.1__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 (102) hide show
  1. pyntrace-0.5.1/.github/workflows/docs.yml +26 -0
  2. pyntrace-0.5.1/.github/workflows/publish.yml +71 -0
  3. pyntrace-0.5.1/.github/workflows/tests.yml +40 -0
  4. pyntrace-0.5.1/.gitignore +14 -0
  5. pyntrace-0.5.1/PKG-INFO +493 -0
  6. pyntrace-0.5.1/README.md +454 -0
  7. pyntrace-0.5.1/docs/agentic-security.md +252 -0
  8. pyntrace-0.5.1/docs/auto-dataset.md +52 -0
  9. pyntrace-0.5.1/docs/ci.md +72 -0
  10. pyntrace-0.5.1/docs/dashboard.md +63 -0
  11. pyntrace-0.5.1/docs/eval.md +51 -0
  12. pyntrace-0.5.1/docs/fingerprint.md +41 -0
  13. pyntrace-0.5.1/docs/guard.md +292 -0
  14. pyntrace-0.5.1/docs/images/dashboard-agents.png +0 -0
  15. pyntrace-0.5.1/docs/images/dashboard-compliance.png +0 -0
  16. pyntrace-0.5.1/docs/images/dashboard-costs.png +0 -0
  17. pyntrace-0.5.1/docs/images/dashboard-eval.png +0 -0
  18. pyntrace-0.5.1/docs/images/dashboard-git.png +0 -0
  19. pyntrace-0.5.1/docs/images/dashboard-mcp.png +0 -0
  20. pyntrace-0.5.1/docs/images/dashboard-monitor.png +0 -0
  21. pyntrace-0.5.1/docs/images/dashboard-overview.png +0 -0
  22. pyntrace-0.5.1/docs/images/dashboard-review.png +0 -0
  23. pyntrace-0.5.1/docs/images/dashboard-security.png +0 -0
  24. pyntrace-0.5.1/docs/images/dashboard.svg +165 -0
  25. pyntrace-0.5.1/docs/images/heatmap.svg +106 -0
  26. pyntrace-0.5.1/docs/images/red-team-report.svg +44 -0
  27. pyntrace-0.5.1/docs/index.md +162 -0
  28. pyntrace-0.5.1/docs/mcp-security.md +174 -0
  29. pyntrace-0.5.1/docs/monitor.md +144 -0
  30. pyntrace-0.5.1/docs/quickstart.md +109 -0
  31. pyntrace-0.5.1/mkdocs.yml +71 -0
  32. pyntrace-0.5.1/pyntrace/__init__.py +168 -0
  33. pyntrace-0.5.1/pyntrace/cli.py +756 -0
  34. pyntrace-0.5.1/pyntrace/compliance/__init__.py +4 -0
  35. pyntrace-0.5.1/pyntrace/compliance/reporter.py +344 -0
  36. pyntrace-0.5.1/pyntrace/db.py +429 -0
  37. pyntrace-0.5.1/pyntrace/eval/__init__.py +15 -0
  38. pyntrace-0.5.1/pyntrace/eval/compare.py +230 -0
  39. pyntrace-0.5.1/pyntrace/eval/dataset.py +143 -0
  40. pyntrace-0.5.1/pyntrace/eval/experiment.py +288 -0
  41. pyntrace-0.5.1/pyntrace/eval/scorers.py +199 -0
  42. pyntrace-0.5.1/pyntrace/git_tracker.py +212 -0
  43. pyntrace-0.5.1/pyntrace/guard/__init__.py +38 -0
  44. pyntrace-0.5.1/pyntrace/guard/agent.py +239 -0
  45. pyntrace-0.5.1/pyntrace/guard/attacks.py +188 -0
  46. pyntrace-0.5.1/pyntrace/guard/auto_dataset.py +113 -0
  47. pyntrace-0.5.1/pyntrace/guard/conversation.py +315 -0
  48. pyntrace-0.5.1/pyntrace/guard/fingerprint.py +213 -0
  49. pyntrace-0.5.1/pyntrace/guard/mcp_scanner.py +559 -0
  50. pyntrace-0.5.1/pyntrace/guard/mcp_static.py +252 -0
  51. pyntrace-0.5.1/pyntrace/guard/multilingual.py +349 -0
  52. pyntrace-0.5.1/pyntrace/guard/mutations.py +95 -0
  53. pyntrace-0.5.1/pyntrace/guard/pii_mask.py +37 -0
  54. pyntrace-0.5.1/pyntrace/guard/prompt_leakage.py +319 -0
  55. pyntrace-0.5.1/pyntrace/guard/rag_scanner.py +217 -0
  56. pyntrace-0.5.1/pyntrace/guard/red_team.py +578 -0
  57. pyntrace-0.5.1/pyntrace/guard/swarm.py +422 -0
  58. pyntrace-0.5.1/pyntrace/guard/toolchain.py +340 -0
  59. pyntrace-0.5.1/pyntrace/interceptor.py +119 -0
  60. pyntrace-0.5.1/pyntrace/monitor/__init__.py +14 -0
  61. pyntrace-0.5.1/pyntrace/monitor/alerts.py +174 -0
  62. pyntrace-0.5.1/pyntrace/monitor/audit_log.py +55 -0
  63. pyntrace-0.5.1/pyntrace/monitor/daemon.py +132 -0
  64. pyntrace-0.5.1/pyntrace/monitor/drift.py +249 -0
  65. pyntrace-0.5.1/pyntrace/monitor/latency.py +209 -0
  66. pyntrace-0.5.1/pyntrace/monitor/prometheus.py +199 -0
  67. pyntrace-0.5.1/pyntrace/monitor/tracer.py +178 -0
  68. pyntrace-0.5.1/pyntrace/plugins/__init__.py +4 -0
  69. pyntrace-0.5.1/pyntrace/plugins/registry.py +138 -0
  70. pyntrace-0.5.1/pyntrace/pricing.py +103 -0
  71. pyntrace-0.5.1/pyntrace/providers.py +157 -0
  72. pyntrace-0.5.1/pyntrace/review/__init__.py +4 -0
  73. pyntrace-0.5.1/pyntrace/review/annotations.py +193 -0
  74. pyntrace-0.5.1/pyntrace/secrets/__init__.py +0 -0
  75. pyntrace-0.5.1/pyntrace/secrets/store.py +121 -0
  76. pyntrace-0.5.1/pyntrace/server/__init__.py +1 -0
  77. pyntrace-0.5.1/pyntrace/server/app.py +1334 -0
  78. pyntrace-0.5.1/pyntrace/server/auth.py +194 -0
  79. pyntrace-0.5.1/pyntrace/server/oauth.py +121 -0
  80. pyntrace-0.5.1/pyproject.toml +56 -0
  81. pyntrace-0.5.1/tests/conftest.py +40 -0
  82. pyntrace-0.5.1/tests/test_alerts.py +153 -0
  83. pyntrace-0.5.1/tests/test_audit_log.py +68 -0
  84. pyntrace-0.5.1/tests/test_auth.py +178 -0
  85. pyntrace-0.5.1/tests/test_conversation.py +122 -0
  86. pyntrace-0.5.1/tests/test_db_audit.py +73 -0
  87. pyntrace-0.5.1/tests/test_eval.py +140 -0
  88. pyntrace-0.5.1/tests/test_git_tracker.py +55 -0
  89. pyntrace-0.5.1/tests/test_guard.py +177 -0
  90. pyntrace-0.5.1/tests/test_latency.py +109 -0
  91. pyntrace-0.5.1/tests/test_mcp_scanner.py +323 -0
  92. pyntrace-0.5.1/tests/test_monitor.py +90 -0
  93. pyntrace-0.5.1/tests/test_multilingual.py +150 -0
  94. pyntrace-0.5.1/tests/test_mutations.py +96 -0
  95. pyntrace-0.5.1/tests/test_oauth.py +96 -0
  96. pyntrace-0.5.1/tests/test_pii_mask.py +74 -0
  97. pyntrace-0.5.1/tests/test_prometheus.py +111 -0
  98. pyntrace-0.5.1/tests/test_prompt_leakage.py +115 -0
  99. pyntrace-0.5.1/tests/test_red_team.py +258 -0
  100. pyntrace-0.5.1/tests/test_secrets_store.py +151 -0
  101. pyntrace-0.5.1/tests/test_swarm.py +152 -0
  102. pyntrace-0.5.1/tests/test_toolchain.py +127 -0
@@ -0,0 +1,26 @@
1
+ name: Deploy Docs
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: write
10
+
11
+ jobs:
12
+ deploy:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: "3.11"
21
+
22
+ - name: Install MkDocs
23
+ run: pip install mkdocs-material
24
+
25
+ - name: Deploy docs
26
+ run: mkdocs gh-deploy --force
@@ -0,0 +1,71 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ python-version: ["3.10", "3.11", "3.12"]
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Set up Python ${{ matrix.python-version }}
18
+ uses: actions/setup-python@v5
19
+ with:
20
+ python-version: ${{ matrix.python-version }}
21
+
22
+ - name: Install dependencies
23
+ run: |
24
+ pip install -e ".[eval,server]"
25
+ pip install pytest ruff
26
+
27
+ - name: Lint
28
+ run: ruff check pyntrace/
29
+
30
+ - name: Run tests
31
+ run: pytest tests/ -v --tb=short
32
+
33
+ verify-version:
34
+ runs-on: ubuntu-latest
35
+ steps:
36
+ - uses: actions/checkout@v4
37
+
38
+ - name: Check tag matches pyproject.toml version
39
+ run: |
40
+ TAG="${GITHUB_REF_NAME#v}"
41
+ PKG=$(grep '^version' pyproject.toml | head -1 | sed 's/.*= *"\(.*\)"/\1/')
42
+ echo "Tag version: $TAG"
43
+ echo "Package version: $PKG"
44
+ if [ "$TAG" != "$PKG" ]; then
45
+ echo "ERROR: Git tag v$TAG does not match pyproject.toml version $PKG"
46
+ exit 1
47
+ fi
48
+
49
+ publish:
50
+ needs: [test, verify-version]
51
+ runs-on: ubuntu-latest
52
+
53
+ steps:
54
+ - uses: actions/checkout@v4
55
+
56
+ - name: Set up Python
57
+ uses: actions/setup-python@v5
58
+ with:
59
+ python-version: "3.11"
60
+
61
+ - name: Install build tools
62
+ run: pip install build twine
63
+
64
+ - name: Build package
65
+ run: python -m build
66
+
67
+ - name: Publish to PyPI
68
+ env:
69
+ TWINE_USERNAME: __token__
70
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
71
+ run: twine upload dist/*
@@ -0,0 +1,40 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+
19
+ - name: Set up Python ${{ matrix.python-version }}
20
+ uses: actions/setup-python@v5
21
+ with:
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install dependencies
25
+ run: |
26
+ pip install -e ".[eval,server]"
27
+ pip install pytest pytest-cov ruff
28
+
29
+ - name: Lint
30
+ run: ruff check pyntrace/
31
+
32
+ - name: Run tests
33
+ run: pytest tests/ -v --tb=short --cov=pyntrace --cov-report=xml
34
+
35
+ - name: Upload coverage
36
+ uses: codecov/codecov-action@v4
37
+ if: matrix.python-version == '3.11'
38
+ with:
39
+ file: ./coverage.xml
40
+ fail_ci_if_error: false
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .venv/
7
+ venv/
8
+ .env
9
+ *.db
10
+ .pytest_cache/
11
+ .coverage
12
+ coverage.xml
13
+ site/
14
+ .DS_Store
@@ -0,0 +1,493 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyntrace
3
+ Version: 0.5.1
4
+ Summary: Red-team, eval, and monitor your LLMs. Security-first, Python-native.
5
+ Project-URL: Homepage, https://github.com/pinexai/pyntrace
6
+ Project-URL: Documentation, https://pinexai.github.io/pyntrace
7
+ Project-URL: Repository, https://github.com/pinexai/pyntrace
8
+ Project-URL: Issues, https://github.com/pinexai/pyntrace/issues
9
+ License: MIT
10
+ Keywords: ai,eval,jailbreak,llm,mcp,observability,red-team,safety,security
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
19
+ Classifier: Topic :: Security
20
+ Requires-Python: >=3.10
21
+ Provides-Extra: eval
22
+ Requires-Dist: jsonschema>=4.0; extra == 'eval'
23
+ Provides-Extra: full
24
+ Requires-Dist: cryptography>=41.0; extra == 'full'
25
+ Requires-Dist: fastapi>=0.100; extra == 'full'
26
+ Requires-Dist: jsonschema>=4.0; extra == 'full'
27
+ Requires-Dist: sentence-transformers>=2.0; extra == 'full'
28
+ Requires-Dist: sqlcipher3; extra == 'full'
29
+ Requires-Dist: uvicorn>=0.20; extra == 'full'
30
+ Requires-Dist: websockets>=11.0; extra == 'full'
31
+ Provides-Extra: secure
32
+ Requires-Dist: cryptography>=41.0; extra == 'secure'
33
+ Requires-Dist: sqlcipher3; extra == 'secure'
34
+ Provides-Extra: server
35
+ Requires-Dist: fastapi>=0.100; extra == 'server'
36
+ Requires-Dist: uvicorn>=0.20; extra == 'server'
37
+ Requires-Dist: websockets>=11.0; extra == 'server'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # pyntrace — LLM Security Testing
41
+
42
+ <p align="center">
43
+ <a href="https://pypi.org/project/pyntrace/"><img src="https://img.shields.io/pypi/v/pyntrace?color=blueviolet" alt="PyPI"></a>
44
+ <a href="https://pypi.org/project/pyntrace/"><img src="https://img.shields.io/pypi/pyversions/pyntrace?color=blueviolet" alt="Python"></a>
45
+ <a href="https://github.com/pinexai/pyntrace/actions/workflows/tests.yml"><img src="https://img.shields.io/github/actions/workflow/status/pinexai/pyntrace/tests.yml?label=tests" alt="Tests"></a>
46
+ <a href="https://github.com/pinexai/pyntrace/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-blueviolet" alt="MIT license"></a>
47
+ <img src="https://img.shields.io/badge/zero-dependencies-brightgreen" alt="zero deps">
48
+ </p>
49
+
50
+ <p align="center">
51
+ <b>Red-team, fingerprint, and monitor your LLMs — pure Python, zero config.</b><br>
52
+ Find vulnerabilities before your users do.
53
+ </p>
54
+
55
+ <p align="center">
56
+ <a href="https://pinexai.github.io/pyntrace/">Documentation</a> ·
57
+ <a href="https://pinexai.github.io/pyntrace/quickstart/">Quick Start</a> ·
58
+ <a href="https://pinexai.github.io/pyntrace/guard/">Red Teaming</a> ·
59
+ <a href="https://pinexai.github.io/pyntrace/fingerprint/">Attack Heatmap</a> ·
60
+ <a href="https://github.com/pinexai/pyntrace/issues">Issues</a>
61
+ </p>
62
+
63
+ ---
64
+
65
+ ## What is pyntrace?
66
+
67
+ `pyntrace` is a Python-native LLM security suite. In one `pip install`, you get automated red teaming, vulnerability fingerprinting across models, adversarial test generation, compliance reporting, and production monitoring — with a local SQLite store and a built-in dashboard. No YAML. No Node.js.
68
+
69
+ **Here's what the attack heatmap looks like:**
70
+
71
+ <p align="center">
72
+ <img src="https://raw.githubusercontent.com/pinexai/pyntrace/main/docs/images/heatmap.svg" alt="pyntrace attack heatmap — vulnerability matrix across models and attack plugins" width="720">
73
+ <br><em>Terminal output rendered as SVG for illustration</em>
74
+ </p>
75
+
76
+ **And the web dashboard:**
77
+
78
+ <p align="center">
79
+ <img src="https://raw.githubusercontent.com/pinexai/pyntrace/main/docs/images/dashboard-overview.png" alt="pyntrace web dashboard — Security tab, vulnerability rate bar chart and scan table" width="760">
80
+ </p>
81
+
82
+ <p align="center">
83
+ <img src="https://raw.githubusercontent.com/pinexai/pyntrace/main/docs/images/dashboard-costs.png" alt="pyntrace web dashboard — Costs tab, cost by model bar chart and breakdown table" width="760">
84
+ </p>
85
+
86
+ **Red team report from the CLI:**
87
+
88
+ <p align="center">
89
+ <img src="https://raw.githubusercontent.com/pinexai/pyntrace/main/docs/images/red-team-report.svg" alt="pyntrace red team report output" width="680">
90
+ <br><em>Terminal output rendered as SVG for illustration</em>
91
+ </p>
92
+
93
+ ---
94
+
95
+ ## Quick Start
96
+
97
+ ```bash
98
+ pip install pyntrace
99
+ ```
100
+
101
+ ```python
102
+ import pyntrace
103
+
104
+ pyntrace.init() # enable SQLite persistence + SDK cost tracking
105
+
106
+ def my_chatbot(prompt: str) -> str:
107
+ return call_llm(prompt)
108
+
109
+ # Red team your chatbot
110
+ report = pyntrace.red_team(my_chatbot, plugins=["jailbreak", "pii", "harmful"])
111
+ report.summary()
112
+ ```
113
+
114
+ Or from the CLI:
115
+
116
+ ```bash
117
+ pyntrace scan myapp:chatbot --plugins jailbreak,pii,harmful --n 20
118
+ pyntrace serve # open dashboard at localhost:7234
119
+ ```
120
+
121
+ ---
122
+
123
+ ## v0.3.0 — MCP Security Scanner
124
+
125
+ The **first** comprehensive security scanner for MCP servers. Zero dependencies, pure Python.
126
+
127
+ ```python
128
+ # Scan a live MCP server
129
+ report = pyntrace.scan_mcp("http://localhost:3000")
130
+ report.summary()
131
+ # CRITICAL: path_traversal — filesystem content leaked via tool name
132
+ # HIGH: ssrf — cloud metadata endpoint accessible
133
+
134
+ # SARIF export for GitHub Security
135
+ report.save_sarif("mcp.sarif")
136
+
137
+ # Static analysis — no server needed
138
+ from pyntrace.guard.mcp_static import analyze_mcp_tools
139
+ report = analyze_mcp_tools([
140
+ {"name": "read_file", "description": "Read any file"},
141
+ {"name": "send_email", "description": "Send email to any address"},
142
+ ])
143
+ report.summary() # CRITICAL: data_exfiltration chain — read_file → send_email
144
+ ```
145
+
146
+ ```bash
147
+ # CLI
148
+ pyntrace scan-mcp http://localhost:3000
149
+ pyntrace scan-mcp http://localhost:3000 --tests path_traversal,ssrf --output-sarif mcp.sarif
150
+ pyntrace analyze-mcp-tools tools.json
151
+ ```
152
+
153
+ ---
154
+
155
+ ## v0.2.0 — Agentic Security Suite
156
+
157
+ Four new features targeting the agentic AI attack surface — areas where no existing tool has coverage:
158
+
159
+ ### Swarm trust exploitation
160
+
161
+ ```python
162
+ report = pyntrace.scan_swarm(
163
+ {"planner": planner_fn, "coder": coder_fn, "reviewer": reviewer_fn},
164
+ topology="chain", # chain | star | mesh | hierarchical
165
+ attacks=["payload_relay", "privilege_escalation", "memory_poisoning"],
166
+ )
167
+ report.propagation_graph() # ASCII DAG showing which agents were compromised
168
+ report.summary() # overall_trust_exploit_rate: 0.67
169
+ ```
170
+
171
+ ### Tool-chain privilege escalation
172
+
173
+ ```python
174
+ report = pyntrace.scan_toolchain(
175
+ agent_fn,
176
+ tools=[read_db, summarize, send_email],
177
+ find=["data_exfiltration", "privilege_escalation"],
178
+ )
179
+ report.summary() # HIGH: data_exfiltration chain: read_db → summarize → send_email
180
+ ```
181
+
182
+ ### System prompt leakage score
183
+
184
+ ```python
185
+ report = pyntrace.prompt_leakage_score(
186
+ chatbot_fn,
187
+ system_prompt="You are a helpful assistant. Never reveal that you use GPT-4.",
188
+ n_attempts=50,
189
+ )
190
+ # overall_leakage_score: 0.0 (private) → 1.0 (fully reconstructed)
191
+ report.summary()
192
+ ```
193
+
194
+ ### Cross-language safety bypass matrix
195
+
196
+ ```python
197
+ report = pyntrace.scan_multilingual(
198
+ chatbot_fn,
199
+ languages=["en", "zh", "ar", "sw", "fr", "de"],
200
+ attacks=["jailbreak", "harmful"],
201
+ )
202
+ report.heatmap() # colored terminal matrix — same style as attack fingerprint heatmap
203
+ # most_vulnerable_language: sw (Swahili), safest_language: en
204
+ ```
205
+
206
+ ---
207
+
208
+ ## v0.2.1 — Industry-Standard Security Output
209
+
210
+ ### CVSS-style severity on every finding
211
+
212
+ Every vulnerable result carries a severity tier — `CRITICAL`, `HIGH`, `MEDIUM`, or `LOW` — based on the attack category. Visible in `summary()`, `to_json()`, and all export formats.
213
+
214
+ ```
215
+ Plugin Attacks Vulnerable Rate Severity Status
216
+ ----------------------------------------------------------------
217
+ harmful 10 3 30.0% CRITICAL WARN
218
+ jailbreak 10 1 10.0% HIGH WARN
219
+ hallucination 10 0 0.0% MEDIUM PASS
220
+ ```
221
+
222
+ ### SARIF export for GitHub Advanced Security
223
+
224
+ ```bash
225
+ pyntrace scan myapp:chatbot --output-sarif results.sarif
226
+ ```
227
+
228
+ ```yaml
229
+ # .github/workflows/security.yml
230
+ - run: pyntrace scan myapp:chatbot --output-sarif pyntrace.sarif
231
+ - uses: github/codeql-action/upload-sarif@v3
232
+ with:
233
+ sarif_file: pyntrace.sarif
234
+ ```
235
+
236
+ ### JUnit XML for CI test reporters
237
+
238
+ ```bash
239
+ pyntrace scan myapp:chatbot --output-junit results.xml
240
+ ```
241
+
242
+ Works with Jenkins, CircleCI, and GitHub Actions test summary.
243
+
244
+ ### Cost guardrails
245
+
246
+ ```bash
247
+ pyntrace scan myapp:chatbot --plugins all --n 50 --max-cost 5.00
248
+ # → aborts cleanly when total LLM spend reaches $5
249
+ ```
250
+
251
+ ---
252
+
253
+ ## Three killer features
254
+
255
+ ### 1. Auto-generate adversarial test cases
256
+
257
+ No manual test writing. pyntrace reads your function's signature and docstring, calls an LLM, and generates N test cases covering jailbreaks, PII extraction, injection attacks, and normal usage.
258
+
259
+ ```python
260
+ def my_chatbot(message: str) -> str:
261
+ """Answer user questions helpfully and safely. Refuse harmful requests."""
262
+ ...
263
+
264
+ ds = pyntrace.auto_dataset(my_chatbot, n=50, focus="adversarial")
265
+ # → 50 test cases generated for free
266
+ print(f"Generated {len(ds)} test cases")
267
+ ```
268
+
269
+ ### 2. Attack heatmap across models
270
+
271
+ Run the full attack suite against multiple models simultaneously. Get a vulnerability fingerprint showing exactly which attack categories break which models — so you can pick the cheapest safe option.
272
+
273
+ ```python
274
+ fp = pyntrace.guard.fingerprint({
275
+ "gpt-4o-mini": gpt_fn,
276
+ "claude-haiku": claude_fn,
277
+ "llama-3": llama_fn,
278
+ }, plugins=["jailbreak", "pii", "harmful", "hallucination", "injection"])
279
+
280
+ fp.heatmap()
281
+ print(f"Safest model: {fp.safest_model()}")
282
+ print(f"Most vulnerable: {fp.most_vulnerable_model()}")
283
+ ```
284
+
285
+ ### 3. Git-aware CI security gates
286
+
287
+ Every scan is tagged with the git commit SHA. Block PRs if the vulnerability rate regresses vs. `main`.
288
+
289
+ ```bash
290
+ pyntrace scan myapp:chatbot --git-compare main --fail-on-regression
291
+ # → exits 1 if vuln rate increased by >5% vs main branch
292
+ # → writes summary to $GITHUB_STEP_SUMMARY
293
+ ```
294
+
295
+ ```yaml
296
+ # .github/workflows/security.yml
297
+ - run: pyntrace scan myapp:chatbot --git-compare origin/main --fail-on-regression
298
+ env:
299
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
300
+ ```
301
+
302
+ ---
303
+
304
+ ## Attack plugins
305
+
306
+ | Plugin | What it probes |
307
+ |---|---|
308
+ | `jailbreak` | Role-play overrides, DAN variants, persona jailbreaks |
309
+ | `pii` | PII extraction, system prompt leakage, training data fishing |
310
+ | `harmful` | Dangerous information, CBRN, illegal activity requests |
311
+ | `hallucination` | False premises, leading questions, factual traps |
312
+ | `injection` | Indirect prompt injection via user-controlled data |
313
+ | `competitor` | Brand manipulation, competitor endorsement attacks |
314
+
315
+ All plugins ship 15–20 templates each. Community plugins via `pyntrace plugin install <name>`.
316
+
317
+ ---
318
+
319
+ ## Evaluation & monitoring
320
+
321
+ ```python
322
+ # Evaluate quality with 9 built-in scorers
323
+ ds = pyntrace.dataset("qa-suite")
324
+ ds.add(input="What is 2+2?", expected_output="4")
325
+
326
+ exp = pyntrace.experiment(
327
+ "math-eval",
328
+ dataset=ds,
329
+ fn=my_chatbot,
330
+ scorers=[pyntrace.scorers.exact_match, pyntrace.scorers.no_pii],
331
+ )
332
+ results = exp.run(pass_threshold=0.8)
333
+ results.summary()
334
+
335
+ # Compare models — Pareto frontier included
336
+ comparison = pyntrace.compare_models(
337
+ models={"gpt-4o-mini": gpt_fn, "claude-haiku": claude_fn},
338
+ dataset=ds,
339
+ scorers=[pyntrace.scorers.llm_judge(criteria="accuracy")],
340
+ )
341
+ comparison.summary() # → shows Pareto frontier + best value model
342
+
343
+ # Production tracing
344
+ with pyntrace.trace("user-request", input=user_msg, user_id="u123") as t:
345
+ response = my_chatbot(user_msg)
346
+ t.output = response
347
+ ```
348
+
349
+ ---
350
+
351
+ ## Compliance reports
352
+
353
+ Generate audit-ready reports mapped to OWASP LLM Top 10, NIST AI RMF, EU AI Act, and SOC2 — automatically evidence-linked to your red team scan results.
354
+
355
+ ```bash
356
+ pyntrace compliance --framework owasp_llm_top10 --output report.html
357
+ pyntrace compliance --framework eu_ai_act --output audit.html
358
+ ```
359
+
360
+ ---
361
+
362
+ ## Supply chain & RAG security
363
+
364
+ Scan your RAG document corpus for poisoned inputs, PII leakage, and system prompt tampering — zero LLM calls required, pure regex pattern matching.
365
+
366
+ ```python
367
+ from pyntrace.guard.rag_scanner import scan_rag
368
+
369
+ report = scan_rag(
370
+ documents=my_docs,
371
+ system_prompt=my_system_prompt,
372
+ baseline_hash="abc123...", # tamper detection
373
+ )
374
+ report.summary()
375
+ ```
376
+
377
+ ---
378
+
379
+ ## Why pyntrace over promptfoo?
380
+
381
+ | | **pyntrace** | promptfoo |
382
+ |---|---|---|
383
+ | Language | **Python** (pip install) | TypeScript (npm install) |
384
+ | Configuration | **Zero config** | YAML required |
385
+ | Attack heatmap across models | **✅** | ❌ |
386
+ | Auto test generation from fn signature | **✅** | ❌ |
387
+ | Git-aware regression tracking | **✅** | ❌ |
388
+ | Cost tracking per scan | **✅** | ❌ |
389
+ | Production monitoring + tracing | **✅** | ❌ |
390
+ | RAG supply chain security | **✅** | ❌ |
391
+ | Human review + annotation queue | **✅** | ❌ |
392
+ | Compliance reports (OWASP / NIST / EU AI Act) | **✅** | ❌ |
393
+ | **Multi-agent swarm exploitation** | **✅** | ❌ |
394
+ | **Tool-chain privilege escalation** | **✅** | ❌ |
395
+ | **System prompt leakage scoring** | **✅** | ❌ |
396
+ | **Cross-language safety bypass matrix** | **✅** | ❌ |
397
+ | **SARIF export (GitHub Advanced Security)** | **✅** | ❌ |
398
+ | **CVSS-style severity tiers** | **✅** | ❌ |
399
+ | **Cost guardrails (max_cost_usd)** | **✅** | ❌ |
400
+ | Community plugin ecosystem | **✅** | Limited |
401
+ | Offline / privacy mode (Ollama) | **✅** | ❌ |
402
+ | Local SQLite — no external backend | **✅** | ❌ |
403
+ | Built-in web dashboard | **✅** | Limited |
404
+
405
+ ---
406
+
407
+ ## Install options
408
+
409
+ ```bash
410
+ pip install pyntrace # core — zero required dependencies
411
+ pip install pyntrace[server] # + FastAPI dashboard (pyntrace serve)
412
+ pip install pyntrace[eval] # + JSON schema validation scorer
413
+ pip install pyntrace[full] # everything
414
+ ```
415
+
416
+ **LLM providers** — install only what you use:
417
+
418
+ ```bash
419
+ pip install openai # for OpenAI models
420
+ pip install anthropic # for Claude models
421
+ pip install google-generativeai # for Gemini models
422
+ # offline: ollama pull llama3 # no API key needed
423
+ ```
424
+
425
+ ---
426
+
427
+ ## Full CLI reference
428
+
429
+ ```bash
430
+ # Security scanning
431
+ pyntrace scan myapp:chatbot # red team
432
+ pyntrace scan myapp:chatbot --plugins all --n 50 # full scan
433
+ pyntrace scan myapp:chatbot --git-compare main # + regression gate
434
+ pyntrace scan myapp:chatbot --max-cost 5.00 # abort if cost > $5
435
+ pyntrace scan myapp:chatbot --output-sarif results.sarif # GitHub Advanced Security
436
+ pyntrace scan myapp:chatbot --output-junit results.xml # CI test reporters
437
+ pyntrace fingerprint myapp:gpt_fn myapp:claude_fn # attack heatmap
438
+
439
+ # Test generation
440
+ pyntrace auto-dataset myapp:chatbot --n 50 --focus adversarial
441
+
442
+ # Evaluation
443
+ pyntrace eval run experiment.py --fail-below 0.8
444
+
445
+ # Security for agents & RAG
446
+ pyntrace scan-agent myapp:my_agent
447
+ pyntrace scan-rag --docs ./data/ --system-prompt prompt.txt
448
+
449
+ # v0.2.0 — Agentic security
450
+ pyntrace scan-swarm myapp:agents --topology chain --attacks payload_relay,privilege_escalation --n 5
451
+ pyntrace scan-toolchain myapp:agent --tools myapp:read_db,myapp:send_email --find data_exfiltration
452
+ pyntrace scan-prompt-leakage myapp:chatbot --system-prompt prompt.txt --n 50
453
+ pyntrace scan-multilingual myapp:chatbot --languages en,zh,ar,sw --attacks jailbreak,harmful --n 5
454
+
455
+ # Compliance
456
+ pyntrace compliance --framework owasp_llm_top10 --output report.html
457
+
458
+ # Monitoring
459
+ pyntrace monitor watch myapp:chatbot --interval 60 --webhook $SLACK_URL
460
+ pyntrace monitor drift --baseline my-eval --window 24
461
+
462
+ # Plugin ecosystem
463
+ pyntrace plugin list
464
+ pyntrace plugin install advanced-jailbreak
465
+
466
+ # Dashboard & info
467
+ pyntrace serve # open at :7234
468
+ pyntrace history # past scans
469
+ pyntrace costs --days 7 # cost breakdown
470
+ ```
471
+
472
+ ---
473
+
474
+ ## Learn more
475
+
476
+ - [Quick Start](https://pinexai.github.io/pyntrace/quickstart/)
477
+ - [Red Teaming Guide](https://pinexai.github.io/pyntrace/guard/)
478
+ - [Attack Heatmap](https://pinexai.github.io/pyntrace/fingerprint/)
479
+ - [Auto Test Generation](https://pinexai.github.io/pyntrace/auto-dataset/)
480
+ - [Evaluation Framework](https://pinexai.github.io/pyntrace/eval/)
481
+ - [Production Monitoring](https://pinexai.github.io/pyntrace/monitor/)
482
+ - [CI/CD Integration](https://pinexai.github.io/pyntrace/ci/)
483
+ - [Dashboard Guide](https://pinexai.github.io/pyntrace/dashboard/)
484
+
485
+ ---
486
+
487
+ ## Contributing
488
+
489
+ Issues and PRs welcome. See [github.com/pinexai/pyntrace](https://github.com/pinexai/pyntrace).
490
+
491
+ ---
492
+
493
+ <p align="center">MIT license · Built by <a href="https://github.com/pinexai">pinexai</a></p>