orvex 0.2.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.

Potentially problematic release.


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

Files changed (70) hide show
  1. orvex-0.2.0/LICENSE +21 -0
  2. orvex-0.2.0/PKG-INFO +134 -0
  3. orvex-0.2.0/README.md +106 -0
  4. orvex-0.2.0/pyproject.toml +58 -0
  5. orvex-0.2.0/setup.cfg +4 -0
  6. orvex-0.2.0/src/agents/__init__.py +0 -0
  7. orvex-0.2.0/src/agents/base.py +104 -0
  8. orvex-0.2.0/src/agents/critic.py +79 -0
  9. orvex-0.2.0/src/agents/investigator.py +141 -0
  10. orvex-0.2.0/src/agents/planner.py +93 -0
  11. orvex-0.2.0/src/agents/recon.py +78 -0
  12. orvex-0.2.0/src/assets/__init__.py +0 -0
  13. orvex-0.2.0/src/audit/__init__.py +0 -0
  14. orvex-0.2.0/src/audit/hashchain.py +212 -0
  15. orvex-0.2.0/src/authorization/__init__.py +0 -0
  16. orvex-0.2.0/src/authorization/approval_manager.py +39 -0
  17. orvex-0.2.0/src/authorization/policy_engine.py +218 -0
  18. orvex-0.2.0/src/authorization/scope_manager.py +334 -0
  19. orvex-0.2.0/src/checklist/__init__.py +0 -0
  20. orvex-0.2.0/src/checklist/engine.py +200 -0
  21. orvex-0.2.0/src/checklist/models.py +156 -0
  22. orvex-0.2.0/src/cli/__init__.py +0 -0
  23. orvex-0.2.0/src/cli/assess.py +214 -0
  24. orvex-0.2.0/src/cli/autonomous.py +304 -0
  25. orvex-0.2.0/src/cli/main.py +596 -0
  26. orvex-0.2.0/src/cli/setup.py +182 -0
  27. orvex-0.2.0/src/config/__init__.py +0 -0
  28. orvex-0.2.0/src/config/settings.py +91 -0
  29. orvex-0.2.0/src/core/__init__.py +0 -0
  30. orvex-0.2.0/src/core/budgets.py +150 -0
  31. orvex-0.2.0/src/core/event_bus.py +40 -0
  32. orvex-0.2.0/src/core/modes.py +77 -0
  33. orvex-0.2.0/src/core/orchestrator/__init__.py +0 -0
  34. orvex-0.2.0/src/core/orchestrator/engine.py +322 -0
  35. orvex-0.2.0/src/core/state.py +788 -0
  36. orvex-0.2.0/src/core/steering.py +206 -0
  37. orvex-0.2.0/src/execution/__init__.py +0 -0
  38. orvex-0.2.0/src/execution/core_tools.py +300 -0
  39. orvex-0.2.0/src/execution/evidence_collector.py +57 -0
  40. orvex-0.2.0/src/execution/network_broker.py +436 -0
  41. orvex-0.2.0/src/execution/tool_registry.py +111 -0
  42. orvex-0.2.0/src/execution/tool_runner.py +200 -0
  43. orvex-0.2.0/src/findings/__init__.py +0 -0
  44. orvex-0.2.0/src/leads/__init__.py +0 -0
  45. orvex-0.2.0/src/models/__init__.py +0 -0
  46. orvex-0.2.0/src/models/anthropic.py +92 -0
  47. orvex-0.2.0/src/models/fallback_manager.py +65 -0
  48. orvex-0.2.0/src/models/identity.py +36 -0
  49. orvex-0.2.0/src/models/ollama.py +79 -0
  50. orvex-0.2.0/src/models/openai_compatible.py +126 -0
  51. orvex-0.2.0/src/models/provider_interface.py +93 -0
  52. orvex-0.2.0/src/models/role_router.py +115 -0
  53. orvex-0.2.0/src/orvex.egg-info/PKG-INFO +134 -0
  54. orvex-0.2.0/src/orvex.egg-info/SOURCES.txt +68 -0
  55. orvex-0.2.0/src/orvex.egg-info/dependency_links.txt +1 -0
  56. orvex-0.2.0/src/orvex.egg-info/entry_points.txt +4 -0
  57. orvex-0.2.0/src/orvex.egg-info/requires.txt +7 -0
  58. orvex-0.2.0/src/orvex.egg-info/top_level.txt +17 -0
  59. orvex-0.2.0/src/reconnaissance/ai_application.py +112 -0
  60. orvex-0.2.0/src/reconnaissance/network.py +142 -0
  61. orvex-0.2.0/src/reconnaissance/web.py +149 -0
  62. orvex-0.2.0/src/reporting/__init__.py +0 -0
  63. orvex-0.2.0/src/reporting/report.py +156 -0
  64. orvex-0.2.0/src/skills/__init__.py +0 -0
  65. orvex-0.2.0/src/skills/base.py +196 -0
  66. orvex-0.2.0/src/ui/__init__.py +0 -0
  67. orvex-0.2.0/src/ui/server.py +270 -0
  68. orvex-0.2.0/src/verification/__init__.py +0 -0
  69. orvex-0.2.0/src/verification/fixtures.py +125 -0
  70. orvex-0.2.0/src/verification/programmatic.py +74 -0
orvex-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ai-agent contributors
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.
orvex-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.4
2
+ Name: orvex
3
+ Version: 0.2.0
4
+ Summary: ORVEX — Offensive Reasoning and Vulnerability Exploration (autonomous red-team security testing: web + network + AI application)
5
+ Author: ORVEX contributors
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/orvex/orvex
8
+ Project-URL: Documentation, https://github.com/orvex/orvex/blob/main/README.md
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Information Technology
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Security
17
+ Classifier: Topic :: Software Development :: Quality Assurance
18
+ Requires-Python: >=3.11
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: PyYAML>=6.0
22
+ Requires-Dist: httpx>=0.27
23
+ Requires-Dist: cryptography>=42.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=8; extra == "dev"
26
+ Requires-Dist: ruff; extra == "dev"
27
+ Dynamic: license-file
28
+
29
+ # ORVEX
30
+
31
+ **Offensive Reasoning and Vulnerability Exploration**
32
+
33
+ An autonomous red-team security-testing platform — one unified engine for
34
+ **web applications**, **IP/network infrastructure**, and **AI applications**
35
+ (LLM chat, RAG, agentic systems), with strict authorization, scope
36
+ enforcement, and evidence-driven verification.
37
+
38
+ > Status: v0.2.0 · 176+ tests passing · core platform complete; roadmap items
39
+ > listed at the end.
40
+
41
+ ## Highlights
42
+
43
+ - **Autonomous mode** — give it targets, it recons, plans, tests (via gated
44
+ tool calls), verifies, and reports: `orvex assess --target <url|host|ip|ip:port|cidr> [--mode surface|medium|deep]`
45
+ - **Engage** — start from an explicit scope declaration:
46
+ `orvex engage --scope engagement.yaml`
47
+ - **Modes** — surface (quick sweep), medium (balanced), deep (full crawl, all
48
+ AI candidates, wide ports, second-order banner/TLS analysis, indirect
49
+ canary pairing).
50
+ - **Resume** — `orvex resume --engagement ID [--chat] [--retry-failed] [--recon]` continues a stopped engagement.
51
+ - **Web UI + live chat** — `orvex ui --port 8080` serves a real-state
52
+ dashboard (overview, agent activity, model/tool-call ledger with live-vs-
53
+ fallback badges, scenarios, findings, readable audit trail) with SSE live
54
+ updates and operator chat steering — all scope-safe and audited.
55
+ - **Guardrails first** — explicit scope required; every outbound action
56
+ (HTTP/DNS/TCP/redirects, model endpoints) passes one policy engine; budgets,
57
+ kill switch, and hash-chained audit log enforced throughout. The model
58
+ proposes; deterministic policy decides.
59
+ - **Provider-agnostic** — `orvex setup` interactively configures any
60
+ OpenAI-compatible API (including custom endpoints), Anthropic, or local
61
+ Ollama per role, with fallback chains. API keys are never hardcoded: use
62
+ environment variables (`AIAGENT_PLANNER_API_KEY`, …); config file is 0600;
63
+ values are redacted from logs/evidence/reports.
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ pip install orvex
69
+ orvex --help
70
+ ```
71
+
72
+ Requires Python ≥ 3.11. (Legacy aliases `aethra` and `ai-agent` remain
73
+ available in published releases for backward compatibility.)
74
+
75
+ ## Quick start
76
+
77
+ ```bash
78
+ orvex setup # one-time provider/model config (interactive)
79
+ orvex engage --scope engagement.yaml # start an authorized engagement
80
+ orvex assess --target https://example.com/ --mode medium
81
+ orvex assess --target 203.0.113.7:443 --mode deep --chat
82
+ orvex resume --engagement ENG-AUTO-XXXXXXXX --chat
83
+ orvex ui --db data/engagements.db --port 8080 # http://127.0.0.1:8080
84
+ orvex steer --engagement ENG-AUTO-XXXXXXXX "skip ai_application"
85
+ ```
86
+
87
+ Offline demo (no external targets):
88
+
89
+ ```bash
90
+ python3 demo/vuln_lab.py --http-port 47123 --tls-port 47125 --banner-port 47124
91
+ orvex assess --target http://127.0.0.1:47123/ \
92
+ --target https://127.0.0.1:47125/ \
93
+ --target 127.0.0.1:47124 --mode deep
94
+ ```
95
+
96
+ ## CLI reference
97
+
98
+ | Command | Purpose |
99
+ |---|---|
100
+ | `setup` | interactive provider/model configuration (per role, fallback, env-var keys) |
101
+ | `engage` / `init` | create an engagement from an explicit scope YAML |
102
+ | `assess` | autonomous assessment (target → recon → test → verify → report) |
103
+ | `resume` | continue a stopped engagement (optional chat/retry/recon) |
104
+ | `recon` | run discovery only (web/network/AI) |
105
+ | `run` | batch assessment of seeded observations |
106
+ | `steer` | send an operator instruction (CLI parity with UI chat) |
107
+ | `ui` | local web dashboard + chat (SSE) |
108
+ | `report` | evidence-driven report (markdown/html/json) |
109
+ | `evidence` | inspect evidence records |
110
+ | `engagements` | list engagements |
111
+ | `checklist` / `status` | engagement state views |
112
+ | `audit-verify` | verify the tamper-evident hash chain |
113
+
114
+ ## Development
115
+
116
+ - `python3 -m pytest tests -q` — full suite.
117
+ - `research/` — Phase-0 comparison and architecture decision records.
118
+ - `docs/` — security model, scope/authorization, checklist engine, model
119
+ configuration, user guide, review records.
120
+
121
+ ## Remaining roadmap (honest)
122
+
123
+ 1. Critic-independence in shipped config (config supports it; guardrail
124
+ warns when the critic shares the investigator's provider/model).
125
+ 2. Finding dedup / attack-chain correlation.
126
+ 3. External tool wrappers (katana, nmap, httpx, sslyze) with version pinning.
127
+ 4. Broader skill families (IDOR/API/file-upload/business-logic).
128
+ 5. Model-driven chat translation tuning; PDF report export.
129
+
130
+ ## License
131
+
132
+ MIT — see `LICENSE`. Independent implementation; research inspiration is
133
+ credited in `research/RESEARCH_COMPARISON.md`. Use only against targets you
134
+ are authorized to test.
orvex-0.2.0/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # ORVEX
2
+
3
+ **Offensive Reasoning and Vulnerability Exploration**
4
+
5
+ An autonomous red-team security-testing platform — one unified engine for
6
+ **web applications**, **IP/network infrastructure**, and **AI applications**
7
+ (LLM chat, RAG, agentic systems), with strict authorization, scope
8
+ enforcement, and evidence-driven verification.
9
+
10
+ > Status: v0.2.0 · 176+ tests passing · core platform complete; roadmap items
11
+ > listed at the end.
12
+
13
+ ## Highlights
14
+
15
+ - **Autonomous mode** — give it targets, it recons, plans, tests (via gated
16
+ tool calls), verifies, and reports: `orvex assess --target <url|host|ip|ip:port|cidr> [--mode surface|medium|deep]`
17
+ - **Engage** — start from an explicit scope declaration:
18
+ `orvex engage --scope engagement.yaml`
19
+ - **Modes** — surface (quick sweep), medium (balanced), deep (full crawl, all
20
+ AI candidates, wide ports, second-order banner/TLS analysis, indirect
21
+ canary pairing).
22
+ - **Resume** — `orvex resume --engagement ID [--chat] [--retry-failed] [--recon]` continues a stopped engagement.
23
+ - **Web UI + live chat** — `orvex ui --port 8080` serves a real-state
24
+ dashboard (overview, agent activity, model/tool-call ledger with live-vs-
25
+ fallback badges, scenarios, findings, readable audit trail) with SSE live
26
+ updates and operator chat steering — all scope-safe and audited.
27
+ - **Guardrails first** — explicit scope required; every outbound action
28
+ (HTTP/DNS/TCP/redirects, model endpoints) passes one policy engine; budgets,
29
+ kill switch, and hash-chained audit log enforced throughout. The model
30
+ proposes; deterministic policy decides.
31
+ - **Provider-agnostic** — `orvex setup` interactively configures any
32
+ OpenAI-compatible API (including custom endpoints), Anthropic, or local
33
+ Ollama per role, with fallback chains. API keys are never hardcoded: use
34
+ environment variables (`AIAGENT_PLANNER_API_KEY`, …); config file is 0600;
35
+ values are redacted from logs/evidence/reports.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install orvex
41
+ orvex --help
42
+ ```
43
+
44
+ Requires Python ≥ 3.11. (Legacy aliases `aethra` and `ai-agent` remain
45
+ available in published releases for backward compatibility.)
46
+
47
+ ## Quick start
48
+
49
+ ```bash
50
+ orvex setup # one-time provider/model config (interactive)
51
+ orvex engage --scope engagement.yaml # start an authorized engagement
52
+ orvex assess --target https://example.com/ --mode medium
53
+ orvex assess --target 203.0.113.7:443 --mode deep --chat
54
+ orvex resume --engagement ENG-AUTO-XXXXXXXX --chat
55
+ orvex ui --db data/engagements.db --port 8080 # http://127.0.0.1:8080
56
+ orvex steer --engagement ENG-AUTO-XXXXXXXX "skip ai_application"
57
+ ```
58
+
59
+ Offline demo (no external targets):
60
+
61
+ ```bash
62
+ python3 demo/vuln_lab.py --http-port 47123 --tls-port 47125 --banner-port 47124
63
+ orvex assess --target http://127.0.0.1:47123/ \
64
+ --target https://127.0.0.1:47125/ \
65
+ --target 127.0.0.1:47124 --mode deep
66
+ ```
67
+
68
+ ## CLI reference
69
+
70
+ | Command | Purpose |
71
+ |---|---|
72
+ | `setup` | interactive provider/model configuration (per role, fallback, env-var keys) |
73
+ | `engage` / `init` | create an engagement from an explicit scope YAML |
74
+ | `assess` | autonomous assessment (target → recon → test → verify → report) |
75
+ | `resume` | continue a stopped engagement (optional chat/retry/recon) |
76
+ | `recon` | run discovery only (web/network/AI) |
77
+ | `run` | batch assessment of seeded observations |
78
+ | `steer` | send an operator instruction (CLI parity with UI chat) |
79
+ | `ui` | local web dashboard + chat (SSE) |
80
+ | `report` | evidence-driven report (markdown/html/json) |
81
+ | `evidence` | inspect evidence records |
82
+ | `engagements` | list engagements |
83
+ | `checklist` / `status` | engagement state views |
84
+ | `audit-verify` | verify the tamper-evident hash chain |
85
+
86
+ ## Development
87
+
88
+ - `python3 -m pytest tests -q` — full suite.
89
+ - `research/` — Phase-0 comparison and architecture decision records.
90
+ - `docs/` — security model, scope/authorization, checklist engine, model
91
+ configuration, user guide, review records.
92
+
93
+ ## Remaining roadmap (honest)
94
+
95
+ 1. Critic-independence in shipped config (config supports it; guardrail
96
+ warns when the critic shares the investigator's provider/model).
97
+ 2. Finding dedup / attack-chain correlation.
98
+ 3. External tool wrappers (katana, nmap, httpx, sslyze) with version pinning.
99
+ 4. Broader skill families (IDOR/API/file-upload/business-logic).
100
+ 5. Model-driven chat translation tuning; PDF report export.
101
+
102
+ ## License
103
+
104
+ MIT — see `LICENSE`. Independent implementation; research inspiration is
105
+ credited in `research/RESEARCH_COMPARISON.md`. Use only against targets you
106
+ are authorized to test.
@@ -0,0 +1,58 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "orvex"
7
+ version = "0.2.0"
8
+ description = "ORVEX — Offensive Reasoning and Vulnerability Exploration (autonomous red-team security testing: web + network + AI application)"
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.11"
12
+ authors = [{ name = "ORVEX contributors" }]
13
+ classifiers = [
14
+ "Development Status :: 4 - Beta",
15
+ "Intended Audience :: Information Technology",
16
+ "Operating System :: POSIX :: Linux",
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Topic :: Security",
22
+ "Topic :: Software Development :: Quality Assurance",
23
+ ]
24
+ dependencies = [
25
+ "PyYAML>=6.0",
26
+ "httpx>=0.27",
27
+ "cryptography>=42.0",
28
+ ]
29
+
30
+ [project.scripts]
31
+ orvex = "cli.main:main"
32
+ aethra = "cli.main:main" # backward-compatible alias
33
+ ai-agent = "cli.main:main" # backward-compatible alias
34
+
35
+ [project.urls]
36
+ Homepage = "https://github.com/orvex/orvex"
37
+ Documentation = "https://github.com/orvex/orvex/blob/main/README.md"
38
+
39
+ [project.optional-dependencies]
40
+ dev = ["pytest>=8", "ruff"]
41
+
42
+ [tool.setuptools.packages.find]
43
+ where = ["src"]
44
+
45
+ [tool.pytest.ini_options]
46
+ pythonpath = ["src"]
47
+ testpaths = ["tests"]
48
+ addopts = "-q"
49
+
50
+ [tool.ruff]
51
+ line-length = 100
52
+ target-version = "py311"
53
+
54
+ [tool.ruff.lint]
55
+ select = ["E", "F", "I", "UP", "B", "SIM"]
56
+
57
+ [tool.ruff.lint.per-file-ignores]
58
+ "tests/*" = ["S101"]
orvex-0.2.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
File without changes
@@ -0,0 +1,104 @@
1
+ """Base agent role.
2
+
3
+ An agent role is a thin layer over the role router: it builds prompts,
4
+ calls the configured model via its fallback chain, and records usage.
5
+ When no model is configured for a role, the agent falls back to
6
+ deterministic behavior (never fabricating results).
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Any
12
+
13
+ from core.state import EngagementContext
14
+ from models.provider_interface import ModelCallParams, ModelMessage
15
+ from models.role_router import RoleRouter
16
+
17
+
18
+ class AgentRole:
19
+ role: str = "base"
20
+
21
+ def __init__(
22
+ self,
23
+ router: RoleRouter | None,
24
+ context: EngagementContext,
25
+ *,
26
+ fallback_ok: bool = True,
27
+ audit=None,
28
+ ) -> None:
29
+ self.router = router
30
+ self.context = context
31
+ self.fallback_ok = fallback_ok
32
+ self.audit = audit
33
+
34
+ @property
35
+ def configured(self) -> bool:
36
+ return self.router is not None and self.router.has_role(self.role)
37
+
38
+ def _call_model(
39
+ self,
40
+ messages: list[ModelMessage],
41
+ params: ModelCallParams | None = None,
42
+ ) -> tuple[bool, str, dict[str, Any]]:
43
+ """Call the configured model. Returns (ok, text, meta).
44
+
45
+ Provider errors never propagate: they degrade to deterministic
46
+ behavior and are recorded (never treated as a clean result).
47
+ """
48
+ if not self.configured:
49
+ return False, "", {"reason": f"no provider configured for role {self.role}"}
50
+ try:
51
+ fb, result = self.router.call(self.role, messages, params)
52
+ except Exception as exc: # noqa: BLE001 - provider/network/parse
53
+ self.context.add_activity(
54
+ "model",
55
+ f"{self.role} provider error",
56
+ detail=f"{type(exc).__name__}: {str(exc)[:200]}",
57
+ )
58
+ if self.audit is not None:
59
+ self.audit.write(
60
+ "model.error",
61
+ self.role,
62
+ {"error": f"{type(exc).__name__}: {str(exc)[:200]}"},
63
+ self.context.engagement_id,
64
+ )
65
+ return False, "", {"reason": f"provider error: {exc}", "degraded": True}
66
+ resp = result.response
67
+ self.context.record_model_usage(
68
+ self.role,
69
+ resp.provider,
70
+ resp.model,
71
+ prompt_tokens=resp.usage.prompt_tokens,
72
+ completion_tokens=resp.usage.completion_tokens,
73
+ cost_estimate=resp.usage.cost_estimate,
74
+ )
75
+ # Live model-call ledger (provider/model/fallback transparency).
76
+ self.context.add_model_call(
77
+ self.role,
78
+ resp.provider,
79
+ resp.model,
80
+ fallback=result.fallback_used,
81
+ prompt_tokens=resp.usage.prompt_tokens,
82
+ completion_tokens=resp.usage.completion_tokens,
83
+ description=f"{self.role} model call ({len(messages)} messages)",
84
+ )
85
+ if self.audit is not None:
86
+ self.audit.write(
87
+ "model.call",
88
+ self.role,
89
+ {
90
+ "provider": resp.provider,
91
+ "model": resp.model,
92
+ "fallback": result.fallback_used,
93
+ "prompt_tokens": resp.usage.prompt_tokens,
94
+ "completion_tokens": resp.usage.completion_tokens,
95
+ "attempts": result.attempts,
96
+ },
97
+ self.context.engagement_id,
98
+ )
99
+ return True, resp.text, {
100
+ "provider": resp.provider,
101
+ "model": resp.model,
102
+ "fallback": result.fallback_used,
103
+ "attempts": result.attempts,
104
+ }
@@ -0,0 +1,79 @@
1
+ """Independent critic agent (Gate 2).
2
+
3
+ The critic attempts to disprove a finding: it re-checks the evidence,
4
+ applies the skill's false-positive disqualifiers, and -- when a separate
5
+ model is configured -- asks it to challenge the conclusion. The critic's
6
+ output is advisory; programmatic gate 1 must already have passed.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Any
12
+
13
+ from agents.base import AgentRole
14
+ from models.provider_interface import ModelCallParams, ModelMessage
15
+ from skills.base import SkillSpec
16
+ from verification.programmatic import verify_finding
17
+
18
+
19
+ class CriticAgent(AgentRole):
20
+ role = "critic"
21
+
22
+ def review(
23
+ self, context: Any, finding_id: str, skill: SkillSpec | None
24
+ ) -> dict[str, Any]:
25
+ gate1 = verify_finding(context, finding_id)
26
+ finding = context.finding(finding_id)
27
+ disqualifiers: list[str] = list(skill.fp_disqualifiers) if skill is not None else []
28
+ # Evaluate false-positive disqualifiers against the actual evidence.
29
+ haystack = (finding.get("description") or "").lower()
30
+ for ref in finding.get("evidence_refs") or []:
31
+ ev = context.evidence(ref)
32
+ if ev is not None:
33
+ haystack += " " + (ev.get("content") or "").lower()
34
+ disqualifier_matches = [dq for dq in disqualifiers if dq.lower() in haystack]
35
+ if not gate1.passed:
36
+ return {
37
+ "verdict": "rejected",
38
+ "detail": "programmatic gate failed: " + "; ".join(gate1.reasons),
39
+ "model_used": "",
40
+ }
41
+ if self.configured:
42
+ finding = context.finding(finding_id)
43
+ ok, text, meta = self._call_model(
44
+ [
45
+ ModelMessage(
46
+ "user",
47
+ "You are an adversarial critic. Challenge this finding: "
48
+ "can the evidence be explained without a vulnerability? "
49
+ "Cite specific evidence or say CLEAR.\n"
50
+ f"Finding: {finding}\n"
51
+ f"FP disqualifiers: {disqualifiers}",
52
+ )
53
+ ],
54
+ ModelCallParams(max_tokens=600),
55
+ )
56
+ if ok:
57
+ rejected = "reject" in text.lower() or "not a vulnerability" in text.lower()
58
+ return {
59
+ "verdict": "rejected" if rejected else "upheld",
60
+ "detail": text[:1500],
61
+ "model_used": f"{meta.get('provider')}/{meta.get('model')}",
62
+ }
63
+ reason = meta.get("reason", "unavailable") if isinstance(meta, dict) else "unavailable"
64
+ return {
65
+ "verdict": "upheld",
66
+ "detail": f"critic model unavailable ({reason}); deterministic critic used (FP disqualifiers evaluated)",
67
+ "model_used": "",
68
+ }
69
+ fp_note = (
70
+ f"; FP disqualifiers evaluated: {len(disqualifiers)} "
71
+ f"({len(disqualifier_matches)} matched evidence)"
72
+ if disqualifiers
73
+ else ""
74
+ )
75
+ return {
76
+ "verdict": "upheld",
77
+ "detail": "programmatic gate passed; no critic model configured" + fp_note,
78
+ "model_used": "",
79
+ }
@@ -0,0 +1,141 @@
1
+ """Investigator agent: interprets test observations.
2
+
3
+ Maps tool output to a checklist result (confirmed / not observed /
4
+ inconclusive) while applying the skill's false-positive disqualifiers.
5
+ This is deterministic by default; a configured model may add analysis
6
+ notes, but never overrides a deterministic verdict.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ from typing import Any
12
+
13
+ from agents.base import AgentRole
14
+ from checklist.models import (
15
+ RESULT_CONFIRMED,
16
+ RESULT_INCONCLUSIVE,
17
+ RESULT_MANUAL,
18
+ RESULT_NOT_OBSERVED,
19
+ )
20
+ from skills.base import SkillSpec
21
+ from execution.tool_runner import RunResult
22
+
23
+
24
+ class InvestigatorAgent(AgentRole):
25
+ role = "investigator"
26
+
27
+ @staticmethod
28
+ def _header_version_leaks(headers: dict) -> list[str]:
29
+ import re as _re
30
+
31
+ leaks: list[str] = []
32
+ for header, value in (headers or {}).items():
33
+ if isinstance(value, str) and _re.search(r"\b\d+\.\d+\.\d+\b", value):
34
+ leaks.append(f"{header}={value.strip()[:40]}")
35
+ return leaks
36
+
37
+ def evaluate(self, skill: SkillSpec, run: RunResult) -> tuple[str, str, str]:
38
+ """Return (result_code, analysis, confidence)."""
39
+ if not run.success:
40
+ return RESULT_INCONCLUSIVE, f"execution failed: {run.error}", "low"
41
+
42
+ out = run.output or {}
43
+ analysis_parts: list[str] = []
44
+ verdict = RESULT_NOT_OBSERVED
45
+ confidence = "high"
46
+
47
+ if "missing_security_headers" in out:
48
+ status = out.get("status_code")
49
+ if status is not None and not (200 <= status < 400):
50
+ return (
51
+ RESULT_INCONCLUSIVE,
52
+ f"unexpected HTTP status {status}; application response not obtained",
53
+ "low",
54
+ )
55
+ missing = out.get("missing_security_headers") or []
56
+ if missing:
57
+ verdict = RESULT_CONFIRMED
58
+ analysis_parts.append(f"missing security headers: {', '.join(missing)}")
59
+ else:
60
+ verdict = RESULT_NOT_OBSERVED
61
+ analysis_parts.append("all expected security headers present")
62
+ leaks = self._header_version_leaks(out.get("headers", {}))
63
+ if leaks:
64
+ out["version_leaks"] = leaks
65
+ verdict = RESULT_CONFIRMED
66
+ analysis_parts.append(f"version disclosure: {', '.join(leaks)}")
67
+
68
+ if "open" in out:
69
+ if out.get("open"):
70
+ verdict = RESULT_MANUAL
71
+ analysis_parts.append(
72
+ f"service reachable on {out.get('host')}:{out.get('port')}; "
73
+ "service-level fingerprinting required"
74
+ )
75
+ else:
76
+ verdict = RESULT_NOT_OBSERVED
77
+ analysis_parts.append("port not reachable")
78
+
79
+ if "injected_instruction_obeyed" in out:
80
+ obeys = out.get("injected_instruction_obeyed")
81
+ leaked = out.get("system_prompt_leaked")
82
+ if obeys:
83
+ verdict = RESULT_CONFIRMED
84
+ analysis_parts.append("model obeyed injected instruction over governing prompt")
85
+ elif leaked:
86
+ verdict = RESULT_CONFIRMED
87
+ analysis_parts.append("model leaked system-prompt material in response")
88
+ else:
89
+ verdict = RESULT_NOT_OBSERVED
90
+ analysis_parts.append("no behavioral difference from baseline")
91
+
92
+ if "expired" in out:
93
+ if out.get("expired"):
94
+ verdict = RESULT_CONFIRMED
95
+ analysis_parts.append(
96
+ f"TLS certificate expired (not after {out.get('not_after')})"
97
+ )
98
+ elif out.get("verify_failed"):
99
+ verdict = RESULT_MANUAL
100
+ analysis_parts.append(
101
+ f"TLS certificate verification failed: {out.get('tls_error', 'untrusted')}"
102
+ )
103
+ elif out.get("protocol") in ("TLSv1", "TLSv1.1"):
104
+ verdict = RESULT_CONFIRMED
105
+ analysis_parts.append(f"legacy TLS protocol in use: {out.get('protocol')}")
106
+ else:
107
+ verdict = RESULT_NOT_OBSERVED
108
+ analysis_parts.append(f"TLS configuration nominal ({out.get('protocol')})")
109
+
110
+ if "fingerprint" in out:
111
+ fp = out.get("fingerprint")
112
+ if fp and fp != "unknown":
113
+ verdict = RESULT_CONFIRMED
114
+ analysis_parts.append(f"exposed service identified via banner: {fp}")
115
+ else:
116
+ verdict = RESULT_NOT_OBSERVED
117
+ analysis_parts.append("no identifying banner observed")
118
+
119
+ if "canary_in_retrieved_response" in out:
120
+ if out.get("canary_in_retrieved_response"):
121
+ verdict = RESULT_CONFIRMED
122
+ analysis_parts.append("retrieved-context canary leaked into model response")
123
+ else:
124
+ verdict = RESULT_NOT_OBSERVED
125
+ analysis_parts.append("no canary leakage from retrieved context")
126
+
127
+ if "version_leaks" in out and out.get("version_leaks"):
128
+ verdict = RESULT_CONFIRMED
129
+ analysis_parts.append("server/technology version information disclosed in headers")
130
+
131
+ if not analysis_parts:
132
+ if out.get("ok") and str(out.get("status_code", "")) not in ("200", "204"):
133
+ verdict = RESULT_INCONCLUSIVE
134
+ analysis_parts.append(
135
+ f"unexpected status {out.get('status_code')}; manual review needed"
136
+ )
137
+ confidence = "low"
138
+ else:
139
+ analysis_parts.append("no vulnerability signals observed in output")
140
+
141
+ return verdict, "; ".join(analysis_parts), confidence