botsting 0.0.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of botsting might be problematic. Click here for more details.

Files changed (56) hide show
  1. botsting/__init__.py +3 -0
  2. botsting/__main__.py +8 -0
  3. botsting/attacks/__init__.py +0 -0
  4. botsting/attacks/adaptive.py +495 -0
  5. botsting/attacks/library.py +239 -0
  6. botsting/attacks/pyrit_adapter.py +227 -0
  7. botsting/attacks/strategy.py +157 -0
  8. botsting/authorize_cli.py +148 -0
  9. botsting/ci.py +122 -0
  10. botsting/cli.py +464 -0
  11. botsting/console.py +240 -0
  12. botsting/core/__init__.py +0 -0
  13. botsting/core/authorization.py +550 -0
  14. botsting/core/benchmark.py +199 -0
  15. botsting/core/canary.py +80 -0
  16. botsting/core/judge.py +175 -0
  17. botsting/core/matcher.py +367 -0
  18. botsting/core/meter.py +228 -0
  19. botsting/core/models.py +560 -0
  20. botsting/core/preflight.py +283 -0
  21. botsting/core/replay.py +145 -0
  22. botsting/core/runner.py +39 -0
  23. botsting/core/scan.py +917 -0
  24. botsting/core/stats.py +42 -0
  25. botsting/demo.py +215 -0
  26. botsting/doctor.py +271 -0
  27. botsting/egress_trap.py +243 -0
  28. botsting/exits.py +38 -0
  29. botsting/frameworks.py +453 -0
  30. botsting/harness.py +893 -0
  31. botsting/harness_tools.py +260 -0
  32. botsting/llm/__init__.py +0 -0
  33. botsting/llm/base.py +31 -0
  34. botsting/llm/ollama.py +165 -0
  35. botsting/llm/scripted.py +122 -0
  36. botsting/mcp_server.py +643 -0
  37. botsting/practice_server.py +190 -0
  38. botsting/presets.py +222 -0
  39. botsting/quick.py +485 -0
  40. botsting/report_html.py +588 -0
  41. botsting/report_markdown.py +472 -0
  42. botsting/reporting.py +73 -0
  43. botsting/seal.py +245 -0
  44. botsting/shell.py +40 -0
  45. botsting/sterility.py +407 -0
  46. botsting/targets/__init__.py +0 -0
  47. botsting/targets/base.py +207 -0
  48. botsting/targets/hardened.py +360 -0
  49. botsting/targets/http.py +826 -0
  50. botsting/targets/registry.py +96 -0
  51. botsting/targets/toy.py +310 -0
  52. botsting-0.0.3.dist-info/METADATA +495 -0
  53. botsting-0.0.3.dist-info/RECORD +56 -0
  54. botsting-0.0.3.dist-info/WHEEL +4 -0
  55. botsting-0.0.3.dist-info/entry_points.txt +2 -0
  56. botsting-0.0.3.dist-info/licenses/LICENSE +202 -0
botsting/frameworks.py ADDED
@@ -0,0 +1,453 @@
1
+ """Data-only mapping from BotSting objective kinds to public security frameworks.
2
+
3
+ Every id, edition and title below was checked against the framework's own publication,
4
+ and then checked again by a second, independent pass on 2026-11-22:
5
+ - OWASP Top 10 for LLM Applications (2026, published August 2026)
6
+ - OWASP Top 10 for Agentic Applications (2026, published December 2025)
7
+ - MITRE ATLAS (v2026.10, October 2026)
8
+ - NIST AI 600-1: Artificial Intelligence Risk Management Framework: Generative AI Profile (July 2024)
9
+ - AIUC-1 (Q4 2026, October 2026)
10
+
11
+ Notes for whoever updates this:
12
+ - NIST AI 600-1 gives its suggested actions no titles. The text shown for an action id is
13
+ the opening of the action, word for word, ending in "..." where it is cut.
14
+ - The atlas.mitre.org technique pages are drawn in the browser; a plain fetch of them
15
+ answers 404. The ids and names here were checked against MITRE's ATLAS-2026.10 data
16
+ release.
17
+ - An entry is listed for an objective only where the entry's own text covers it. Entries
18
+ that fit only loosely were removed after the second pass (AIUC-1 B007 and B009, NIST
19
+ MS-4.2-001, and ASI01 and MS-2.10-001 for an instruction secret). AIUC-1 A006 (personal
20
+ data) was removed because a planted record need not be personal data.
21
+ - AIUC-1 A009 and B001 ask for testing by an appointed third party at least every three
22
+ months. A scan can be evidence toward them; it does not meet them alone.
23
+
24
+ This mapping covers only the four objective kinds BotSting tests. It is never full
25
+ coverage of any framework, and a scan result is never a claim of compliance,
26
+ certification, or passing a framework.
27
+ """
28
+
29
+ from __future__ import annotations
30
+
31
+ from collections.abc import Sequence
32
+ from dataclasses import dataclass
33
+ from typing import Literal
34
+
35
+ from botsting.core.models import Finding, ScanReport, SlotStatus
36
+
37
+ ObjectiveKind = Literal[
38
+ "instruction_secret",
39
+ "other_user_record",
40
+ "tool_rule",
41
+ "injection_point",
42
+ ]
43
+
44
+ OBJECTIVE_KINDS: tuple[ObjectiveKind, ...] = (
45
+ "instruction_secret",
46
+ "other_user_record",
47
+ "tool_rule",
48
+ "injection_point",
49
+ )
50
+
51
+ OBJECTIVE_LABELS: dict[ObjectiveKind, str] = {
52
+ "instruction_secret": "Leak of an instruction secret",
53
+ "other_user_record": "Leak of another user's record",
54
+ "tool_rule": "Unauthorized tool action by direct request",
55
+ "injection_point": "Unauthorized tool action through injected content",
56
+ }
57
+
58
+ CoverageResult = Literal["proven finding", "no verified violation", "inconclusive"]
59
+
60
+
61
+ @dataclass(frozen=True)
62
+ class FrameworkEntry:
63
+ """One verified reference in a public AI security or risk framework."""
64
+
65
+ framework: str
66
+ version: str
67
+ id: str
68
+ title: str
69
+ url: str
70
+
71
+
72
+ # -- OWASP Top 10 for LLM Applications (2026) -----------------------------------------------
73
+
74
+ _OWASP_LLM = "OWASP Top 10 for LLM Applications"
75
+ _OWASP_LLM_VER = "2026"
76
+
77
+ _LLM01 = FrameworkEntry(
78
+ framework=_OWASP_LLM,
79
+ version=_OWASP_LLM_VER,
80
+ id="LLM01:2026",
81
+ title="Prompt Injection",
82
+ url="https://github.com/GenAI-Security-Project/GenAI-LLM-Top10/blob/main/2026/final/LLM01_PromptInjection.md",
83
+ )
84
+ _LLM02 = FrameworkEntry(
85
+ framework=_OWASP_LLM,
86
+ version=_OWASP_LLM_VER,
87
+ id="LLM02:2026",
88
+ title="Sensitive Information Disclosure",
89
+ url="https://github.com/GenAI-Security-Project/GenAI-LLM-Top10/blob/main/2026/final/LLM02_SensitiveInformationDisclosure.md",
90
+ )
91
+ _LLM03 = FrameworkEntry(
92
+ framework=_OWASP_LLM,
93
+ version=_OWASP_LLM_VER,
94
+ id="LLM03:2026",
95
+ title="Excessive Agency",
96
+ url="https://github.com/GenAI-Security-Project/GenAI-LLM-Top10/blob/main/2026/final/LLM03_ExcessiveAgency.md",
97
+ )
98
+ _LLM08 = FrameworkEntry(
99
+ framework=_OWASP_LLM,
100
+ version=_OWASP_LLM_VER,
101
+ id="LLM08:2026",
102
+ title="Hidden Context Exposure",
103
+ url="https://github.com/GenAI-Security-Project/GenAI-LLM-Top10/blob/main/2026/final/LLM08_HiddenContextExposure.md",
104
+ )
105
+
106
+ # -- OWASP Top 10 for Agentic Applications (2026) -------------------------------------------
107
+
108
+ _OWASP_AGENTIC = "OWASP Top 10 for Agentic Applications"
109
+ _OWASP_AGENTIC_VER = "2026"
110
+ _OWASP_AGENTIC_URL = "https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/"
111
+
112
+ _ASI01 = FrameworkEntry(
113
+ framework=_OWASP_AGENTIC,
114
+ version=_OWASP_AGENTIC_VER,
115
+ id="ASI01",
116
+ title="Agent Goal Hijack",
117
+ url=_OWASP_AGENTIC_URL,
118
+ )
119
+ _ASI02 = FrameworkEntry(
120
+ framework=_OWASP_AGENTIC,
121
+ version=_OWASP_AGENTIC_VER,
122
+ id="ASI02",
123
+ title="Tool Misuse and Exploitation",
124
+ url=_OWASP_AGENTIC_URL,
125
+ )
126
+ _ASI03 = FrameworkEntry(
127
+ framework=_OWASP_AGENTIC,
128
+ version=_OWASP_AGENTIC_VER,
129
+ id="ASI03",
130
+ title="Identity and Privilege Abuse",
131
+ url=_OWASP_AGENTIC_URL,
132
+ )
133
+
134
+ # -- MITRE ATLAS (v2026.10) -----------------------------------------------------------------
135
+
136
+ _ATLAS = "MITRE ATLAS"
137
+ _ATLAS_VER = "v2026.10"
138
+
139
+ _ATLAS_DIRECT_PI = FrameworkEntry(
140
+ framework=_ATLAS,
141
+ version=_ATLAS_VER,
142
+ id="AML.T0051.000",
143
+ title="LLM Prompt Injection: Direct",
144
+ url="https://atlas.mitre.org/techniques/AML.T0051.000",
145
+ )
146
+ _ATLAS_INDIRECT_PI = FrameworkEntry(
147
+ framework=_ATLAS,
148
+ version=_ATLAS_VER,
149
+ id="AML.T0051.001",
150
+ title="LLM Prompt Injection: Indirect",
151
+ url="https://atlas.mitre.org/techniques/AML.T0051.001",
152
+ )
153
+ _ATLAS_TOOL_INVOCATION = FrameworkEntry(
154
+ framework=_ATLAS,
155
+ version=_ATLAS_VER,
156
+ id="AML.T0053",
157
+ title="AI Agent Tool Invocation",
158
+ url="https://atlas.mitre.org/techniques/AML.T0053",
159
+ )
160
+ _ATLAS_DATA_AI_SERVICES = FrameworkEntry(
161
+ framework=_ATLAS,
162
+ version=_ATLAS_VER,
163
+ id="AML.T0085",
164
+ title="Data from AI Services",
165
+ url="https://atlas.mitre.org/techniques/AML.T0085",
166
+ )
167
+ _ATLAS_SYSTEM_INSTRUCTIONS = FrameworkEntry(
168
+ framework=_ATLAS,
169
+ version=_ATLAS_VER,
170
+ id="AML.T0085.003",
171
+ title="Data from AI Services: System Instructions",
172
+ url="https://atlas.mitre.org/techniques/AML.T0085.003",
173
+ )
174
+ _ATLAS_EXFIL_UI = FrameworkEntry(
175
+ framework=_ATLAS,
176
+ version=_ATLAS_VER,
177
+ id="AML.T0136",
178
+ title="Exfiltration via AI User Interface",
179
+ url="https://atlas.mitre.org/techniques/AML.T0136",
180
+ )
181
+
182
+ # -- NIST AI 600-1 (July 2024) --------------------------------------------------------------
183
+
184
+ _NIST = "NIST AI 600-1"
185
+ _NIST_VER = "July 2024"
186
+ _NIST_URL = "https://nvlpubs.nist.gov/nistpubs/AI/NIST.AI.600-1.pdf"
187
+
188
+ _NIST_DATA_PRIVACY = FrameworkEntry(
189
+ framework=_NIST,
190
+ version=_NIST_VER,
191
+ id="Section 2.4",
192
+ title="Data Privacy",
193
+ url=_NIST_URL,
194
+ )
195
+ _NIST_INFO_SECURITY = FrameworkEntry(
196
+ framework=_NIST,
197
+ version=_NIST_VER,
198
+ id="Section 2.9",
199
+ title="Information Security",
200
+ url=_NIST_URL,
201
+ )
202
+ _NIST_MS_2_7_001 = FrameworkEntry(
203
+ framework=_NIST,
204
+ version=_NIST_VER,
205
+ id="MS-2.7-001",
206
+ title=(
207
+ "Apply established security measures to: Assess likelihood and magnitude of vulnerabilities and threats "
208
+ "such as backdoors, compromised dependencies, data breaches, eavesdropping, man-in-the-middle attacks, ..."
209
+ ),
210
+ url=_NIST_URL,
211
+ )
212
+ _NIST_MS_2_7_007 = FrameworkEntry(
213
+ framework=_NIST,
214
+ version=_NIST_VER,
215
+ id="MS-2.7-007",
216
+ title=(
217
+ "Perform AI red-teaming to assess resilience against: Abuse to facilitate attacks on other systems "
218
+ "(e.g., malicious code generation, enhanced phishing content), GAI attacks (e.g., prompt injection), ..."
219
+ ),
220
+ url=_NIST_URL,
221
+ )
222
+ _NIST_MS_2_10_001 = FrameworkEntry(
223
+ framework=_NIST,
224
+ version=_NIST_VER,
225
+ id="MS-2.10-001",
226
+ title=(
227
+ "Conduct AI red-teaming to assess issues such as: Outputting of training data samples, and subsequent "
228
+ "reverse engineering, model extraction, and membership inference risks; Revealing biometric, confidential, "
229
+ "copyrighted, licensed, patented, personal, proprietary, sensitive, or trade-marked information; ..."
230
+ ),
231
+ url=_NIST_URL,
232
+ )
233
+
234
+ # -- AIUC-1 (Q4 2026) -----------------------------------------------------------------------
235
+
236
+ _AIUC = "AIUC-1"
237
+ _AIUC_VER = "Q4 2026"
238
+
239
+ _AIUC_A005 = FrameworkEntry(
240
+ framework=_AIUC,
241
+ version=_AIUC_VER,
242
+ id="A005",
243
+ title="Prevent cross-customer data exposure",
244
+ url="https://standard.aiuc-1.com/data-and-privacy/prevent-cross-customer-data-exposure",
245
+ )
246
+ _AIUC_A008 = FrameworkEntry(
247
+ framework=_AIUC,
248
+ version=_AIUC_VER,
249
+ id="A008",
250
+ title="Prevent leakage of credentials and secrets",
251
+ url="https://standard.aiuc-1.com/data-and-privacy/prevent-secrets-leakage",
252
+ )
253
+ _AIUC_A009 = FrameworkEntry(
254
+ framework=_AIUC,
255
+ version=_AIUC_VER,
256
+ id="A009",
257
+ title="Third-party testing for data & privacy risk",
258
+ url="https://standard.aiuc-1.com/data-and-privacy/3rd-party-testing-for-data-and-privacy-risk",
259
+ )
260
+ _AIUC_B001 = FrameworkEntry(
261
+ framework=_AIUC,
262
+ version=_AIUC_VER,
263
+ id="B001",
264
+ title="Third-party testing for security risk",
265
+ url="https://standard.aiuc-1.com/security/test-adversarial-robustness",
266
+ )
267
+ _AIUC_B006 = FrameworkEntry(
268
+ framework=_AIUC,
269
+ version=_AIUC_VER,
270
+ id="B006",
271
+ title="Prevent unauthorized AI agent actions",
272
+ url="https://standard.aiuc-1.com/security/enforce-contextual-access-controls",
273
+ )
274
+
275
+ ALL_FRAMEWORK_ENTRIES: tuple[FrameworkEntry, ...] = (
276
+ _LLM01,
277
+ _LLM02,
278
+ _LLM03,
279
+ _LLM08,
280
+ _ASI01,
281
+ _ASI02,
282
+ _ASI03,
283
+ _ATLAS_DIRECT_PI,
284
+ _ATLAS_INDIRECT_PI,
285
+ _ATLAS_TOOL_INVOCATION,
286
+ _ATLAS_DATA_AI_SERVICES,
287
+ _ATLAS_SYSTEM_INSTRUCTIONS,
288
+ _ATLAS_EXFIL_UI,
289
+ _NIST_DATA_PRIVACY,
290
+ _NIST_INFO_SECURITY,
291
+ _NIST_MS_2_7_001,
292
+ _NIST_MS_2_7_007,
293
+ _NIST_MS_2_10_001,
294
+ _AIUC_A005,
295
+ _AIUC_A008,
296
+ _AIUC_A009,
297
+ _AIUC_B001,
298
+ _AIUC_B006,
299
+ )
300
+
301
+ FRAMEWORK_MAPPINGS: dict[ObjectiveKind, tuple[FrameworkEntry, ...]] = {
302
+ "instruction_secret": (
303
+ _LLM01,
304
+ _LLM02,
305
+ _LLM08,
306
+ _ATLAS_DIRECT_PI,
307
+ _ATLAS_SYSTEM_INSTRUCTIONS,
308
+ _ATLAS_EXFIL_UI,
309
+ _NIST_INFO_SECURITY,
310
+ _NIST_MS_2_7_007,
311
+ _AIUC_A008,
312
+ _AIUC_B001,
313
+ ),
314
+ "other_user_record": (
315
+ _LLM02,
316
+ _ASI03,
317
+ _ATLAS_DATA_AI_SERVICES,
318
+ _ATLAS_EXFIL_UI,
319
+ _NIST_DATA_PRIVACY,
320
+ _NIST_INFO_SECURITY,
321
+ _NIST_MS_2_10_001,
322
+ _AIUC_A005,
323
+ _AIUC_A009,
324
+ ),
325
+ "tool_rule": (
326
+ _LLM01,
327
+ _LLM03,
328
+ _ASI02,
329
+ _ASI03,
330
+ _ATLAS_DIRECT_PI,
331
+ _ATLAS_TOOL_INVOCATION,
332
+ _NIST_INFO_SECURITY,
333
+ _NIST_MS_2_7_001,
334
+ _NIST_MS_2_7_007,
335
+ _AIUC_B001,
336
+ _AIUC_B006,
337
+ ),
338
+ "injection_point": (
339
+ _LLM01,
340
+ _LLM03,
341
+ _ASI01,
342
+ _ASI02,
343
+ _ATLAS_INDIRECT_PI,
344
+ _ATLAS_TOOL_INVOCATION,
345
+ _NIST_INFO_SECURITY,
346
+ _NIST_MS_2_7_007,
347
+ _AIUC_B001,
348
+ _AIUC_B006,
349
+ ),
350
+ }
351
+
352
+
353
+ @dataclass(frozen=True)
354
+ class CoverageRow:
355
+ """One row of the framework coverage table for an objective kind exercised in a scan."""
356
+
357
+ kind: ObjectiveKind
358
+ label: str
359
+ entries: tuple[FrameworkEntry, ...]
360
+ attempts: int
361
+ result: CoverageResult
362
+
363
+
364
+ def entries_for(kind: str) -> tuple[FrameworkEntry, ...]:
365
+ """Framework entries mapped to `kind`, or an empty tuple if `kind` is not a known objective kind."""
366
+ if kind in FRAMEWORK_MAPPINGS:
367
+ return FRAMEWORK_MAPPINGS[kind] # type: ignore[index]
368
+ return ()
369
+
370
+
371
+ def objective_kind_for(finding: Finding, slots: Sequence[SlotStatus]) -> ObjectiveKind | None:
372
+ """Determine which BotSting objective kind a finding belongs to."""
373
+ if finding.kind == "action":
374
+ return "tool_rule"
375
+ if finding.kind == "injection":
376
+ return "injection_point"
377
+ for slot in slots:
378
+ if slot.slot_id == finding.slot_id and slot.kind in FRAMEWORK_MAPPINGS:
379
+ return slot.kind # type: ignore[return-value]
380
+ return None
381
+
382
+
383
+ def group_entries(entries: Sequence[FrameworkEntry]) -> list[tuple[str, list[FrameworkEntry]]]:
384
+ """Group entries by `framework (version)`, preserving order."""
385
+ grouped: dict[str, list[FrameworkEntry]] = {}
386
+ for entry in entries:
387
+ key = f"{entry.framework} ({entry.version})"
388
+ grouped.setdefault(key, []).append(entry)
389
+ return list(grouped.items())
390
+
391
+
392
+ def coverage_rows(report: ScanReport) -> list[CoverageRow]:
393
+ """One row per objective kind this scan actually exercised, in canonical order."""
394
+ present = {slot.kind for slot in report.slots if slot.kind in FRAMEWORK_MAPPINGS}
395
+ findings_by_kind: dict[ObjectiveKind, list[Finding]] = {kind: [] for kind in OBJECTIVE_KINDS}
396
+ for finding in report.findings:
397
+ kind = objective_kind_for(finding, report.slots)
398
+ if kind is not None:
399
+ findings_by_kind[kind].append(finding)
400
+
401
+ scan_has_problems = (
402
+ report.status == "inconclusive"
403
+ or bool(report.stopped_early)
404
+ or any(not task.passed for task in report.tasks)
405
+ or bool(report.errors)
406
+ )
407
+
408
+ rows: list[CoverageRow] = []
409
+ for kind in OBJECTIVE_KINDS:
410
+ if kind not in present:
411
+ continue
412
+ kind_slots = [slot for slot in report.slots if slot.kind == kind]
413
+ attempts = sum(slot.judged_attempts for slot in kind_slots)
414
+ result: CoverageResult
415
+ if findings_by_kind[kind]:
416
+ result = "proven finding"
417
+ elif (
418
+ any(slot.state != "reachable" for slot in kind_slots)
419
+ or scan_has_problems
420
+ or (any(slot.judged_attempts == 0 for slot in kind_slots) and report.status != "no_verified_violations")
421
+ ):
422
+ result = "inconclusive"
423
+ else:
424
+ result = "no verified violation"
425
+ rows.append(
426
+ CoverageRow(
427
+ kind=kind,
428
+ label=OBJECTIVE_LABELS[kind],
429
+ entries=FRAMEWORK_MAPPINGS[kind],
430
+ attempts=attempts,
431
+ result=result,
432
+ )
433
+ )
434
+ return rows
435
+
436
+
437
+ def not_covered_sentence(exercised: Sequence[ObjectiveKind]) -> str:
438
+ """One plain sentence naming what this scan did not cover, preventing over-claiming."""
439
+ missing = [OBJECTIVE_LABELS[kind].lower() for kind in OBJECTIVE_KINDS if kind not in exercised]
440
+ broader = (
441
+ "supply chain, training or data poisoning, denial of service or unbounded consumption, "
442
+ "misinformation or hallucinations, bias and fairness, harmful content generation, "
443
+ "multi-agent or memory poisoning, output handling, or organizational governance"
444
+ )
445
+ if missing:
446
+ missing_text = ", ".join(missing)
447
+ return (
448
+ f"This scan did not cover {missing_text}, nor other categories of these frameworks "
449
+ f"such as {broader}."
450
+ )
451
+ return (
452
+ f"This scan did not cover other categories of these frameworks, including {broader}."
453
+ )