orvex 0.2.0__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 orvex might be problematic. Click here for more details.
- agents/__init__.py +0 -0
- agents/base.py +104 -0
- agents/critic.py +79 -0
- agents/investigator.py +141 -0
- agents/planner.py +93 -0
- agents/recon.py +78 -0
- assets/__init__.py +0 -0
- audit/__init__.py +0 -0
- audit/hashchain.py +212 -0
- authorization/__init__.py +0 -0
- authorization/approval_manager.py +39 -0
- authorization/policy_engine.py +218 -0
- authorization/scope_manager.py +334 -0
- checklist/__init__.py +0 -0
- checklist/engine.py +200 -0
- checklist/models.py +156 -0
- cli/__init__.py +0 -0
- cli/assess.py +214 -0
- cli/autonomous.py +304 -0
- cli/main.py +596 -0
- cli/setup.py +182 -0
- config/__init__.py +0 -0
- config/settings.py +91 -0
- core/__init__.py +0 -0
- core/budgets.py +150 -0
- core/event_bus.py +40 -0
- core/modes.py +77 -0
- core/orchestrator/__init__.py +0 -0
- core/orchestrator/engine.py +322 -0
- core/state.py +788 -0
- core/steering.py +206 -0
- execution/__init__.py +0 -0
- execution/core_tools.py +300 -0
- execution/evidence_collector.py +57 -0
- execution/network_broker.py +436 -0
- execution/tool_registry.py +111 -0
- execution/tool_runner.py +200 -0
- findings/__init__.py +0 -0
- leads/__init__.py +0 -0
- models/__init__.py +0 -0
- models/anthropic.py +92 -0
- models/fallback_manager.py +65 -0
- models/identity.py +36 -0
- models/ollama.py +79 -0
- models/openai_compatible.py +126 -0
- models/provider_interface.py +93 -0
- models/role_router.py +115 -0
- orvex-0.2.0.dist-info/METADATA +134 -0
- orvex-0.2.0.dist-info/RECORD +65 -0
- orvex-0.2.0.dist-info/WHEEL +5 -0
- orvex-0.2.0.dist-info/entry_points.txt +4 -0
- orvex-0.2.0.dist-info/licenses/LICENSE +21 -0
- orvex-0.2.0.dist-info/top_level.txt +17 -0
- reconnaissance/ai_application.py +112 -0
- reconnaissance/network.py +142 -0
- reconnaissance/web.py +149 -0
- reporting/__init__.py +0 -0
- reporting/report.py +156 -0
- skills/__init__.py +0 -0
- skills/base.py +196 -0
- ui/__init__.py +0 -0
- ui/server.py +270 -0
- verification/__init__.py +0 -0
- verification/fixtures.py +125 -0
- verification/programmatic.py +74 -0
agents/__init__.py
ADDED
|
File without changes
|
agents/base.py
ADDED
|
@@ -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
|
+
}
|
agents/critic.py
ADDED
|
@@ -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
|
+
}
|
agents/investigator.py
ADDED
|
@@ -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
|
agents/planner.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Planner agent: decides what to test next from a lead.
|
|
2
|
+
|
|
3
|
+
Uses the skill registry to route a lead to a skill, then produces a
|
|
4
|
+
checklist item plus the concrete tool invocation that the orchestrator
|
|
5
|
+
will validate against policy before executing.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from agents.base import AgentRole
|
|
13
|
+
from models.provider_interface import ModelCallParams, ModelMessage
|
|
14
|
+
from skills.base import SkillRegistry
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class PlannerAgent(AgentRole):
|
|
18
|
+
role = "planner"
|
|
19
|
+
|
|
20
|
+
def __init__(self, router, context, skills: SkillRegistry, available_tools: set[str] | None = None, audit=None) -> None:
|
|
21
|
+
super().__init__(router, context, audit=audit)
|
|
22
|
+
self.skills = skills
|
|
23
|
+
self.available_tools = available_tools or set()
|
|
24
|
+
|
|
25
|
+
def propose_for_lead(self, lead: dict[str, Any]) -> dict[str, Any] | None:
|
|
26
|
+
surface = lead.get("surface_type", "")
|
|
27
|
+
hints: list[str] = lead.get("vuln_families") or []
|
|
28
|
+
skill = self.skills.route(surface, hints) or self.skills.route(surface)
|
|
29
|
+
if skill is None:
|
|
30
|
+
return None
|
|
31
|
+
target = lead.get("asset_id", "")
|
|
32
|
+
endpoint = lead.get("source", "")
|
|
33
|
+
tool_args = dict(skill.tool_args)
|
|
34
|
+
if skill.name == "ai_indirect_prompt_injection" and "->" in endpoint:
|
|
35
|
+
doc_url, _, chat_url = endpoint.partition("->")
|
|
36
|
+
tool_args = {"doc_url": doc_url.strip(), "chat_url": chat_url.strip()}
|
|
37
|
+
elif skill.surface in ("network", "shared") and endpoint:
|
|
38
|
+
host, sep, port = endpoint.rpartition(":")
|
|
39
|
+
if sep and port.isdigit() and host:
|
|
40
|
+
tool_args = {"host": host, "port": int(port)}
|
|
41
|
+
elif endpoint:
|
|
42
|
+
tool_args.setdefault("url", endpoint)
|
|
43
|
+
plan: dict[str, Any] = {
|
|
44
|
+
"target": endpoint or target,
|
|
45
|
+
"category": skill.surface,
|
|
46
|
+
"asset_id": lead.get("asset_id", ""),
|
|
47
|
+
"endpoint": endpoint,
|
|
48
|
+
"test_name": skill.name.replace("_", " "),
|
|
49
|
+
"objective": skill.description,
|
|
50
|
+
"reason": f"lead {lead.get('id', '')}: {lead.get('security_relevance', '')}",
|
|
51
|
+
"vuln_category": (skill.vuln_categories or [""])[0],
|
|
52
|
+
"skill": skill.name,
|
|
53
|
+
"skill_version": skill.version,
|
|
54
|
+
"priority": int(lead.get("priority", 3)),
|
|
55
|
+
"safety_level": skill.safety_level,
|
|
56
|
+
"method_authorized": f"skill:{skill.name} v{skill.version} tool:{skill.tool}",
|
|
57
|
+
"tool": skill.tool,
|
|
58
|
+
"tool_args": tool_args,
|
|
59
|
+
}
|
|
60
|
+
# Model-assisted planning when configured; never required.
|
|
61
|
+
if self.configured:
|
|
62
|
+
ok, text, _ = self._call_model(
|
|
63
|
+
[
|
|
64
|
+
ModelMessage(
|
|
65
|
+
"user",
|
|
66
|
+
"Propose a checklist test for this lead. Return JSON with "
|
|
67
|
+
"test_name, objective, safety_level, tool, tool_args.\n"
|
|
68
|
+
f"Lead: {lead}",
|
|
69
|
+
)
|
|
70
|
+
],
|
|
71
|
+
ModelCallParams(max_tokens=500),
|
|
72
|
+
)
|
|
73
|
+
if ok and text.strip().startswith("{"):
|
|
74
|
+
try:
|
|
75
|
+
import json
|
|
76
|
+
|
|
77
|
+
parsed = json.loads(text)
|
|
78
|
+
model_tool = parsed.get("tool")
|
|
79
|
+
tool_accepted = bool(
|
|
80
|
+
model_tool and self.available_tools and model_tool in self.available_tools
|
|
81
|
+
)
|
|
82
|
+
for key in ("test_name", "objective", "safety_level"):
|
|
83
|
+
if key in parsed:
|
|
84
|
+
plan[key] = parsed[key]
|
|
85
|
+
if tool_accepted:
|
|
86
|
+
plan["tool"] = model_tool
|
|
87
|
+
if isinstance(parsed.get("tool_args"), dict):
|
|
88
|
+
plan["tool_args"] = parsed["tool_args"]
|
|
89
|
+
# unknown tool proposals are silently ignored so the
|
|
90
|
+
# deterministic skill route decides execution
|
|
91
|
+
except ValueError:
|
|
92
|
+
pass
|
|
93
|
+
return plan
|
agents/recon.py
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"""Reconnaissance agent: converts observations into assets and leads.
|
|
2
|
+
|
|
3
|
+
For the first pass this is deterministic: given an observed surface
|
|
4
|
+
(a URL, host, or AI chat endpoint), it records an asset and emits leads
|
|
5
|
+
with security relevance and suggested vulnerability families.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from agents.base import AgentRole
|
|
13
|
+
|
|
14
|
+
_SURFACE_LEADS: dict[str, list[dict[str, Any]]] = {
|
|
15
|
+
"web": [
|
|
16
|
+
{
|
|
17
|
+
"surface_type": "web",
|
|
18
|
+
"security_relevance": "login/auth boundary",
|
|
19
|
+
"vuln_families": ["authentication", "session_management"],
|
|
20
|
+
"priority": 8,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"surface_type": "web",
|
|
24
|
+
"security_relevance": "HTTP API surface",
|
|
25
|
+
"vuln_families": ["api_security", "authorization"],
|
|
26
|
+
"priority": 7,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
"network": [
|
|
30
|
+
{
|
|
31
|
+
"surface_type": "network",
|
|
32
|
+
"security_relevance": "exposed network service",
|
|
33
|
+
"vuln_families": ["exposed_service", "misconfiguration"],
|
|
34
|
+
"priority": 6,
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"ai_application": [
|
|
38
|
+
{
|
|
39
|
+
"surface_type": "ai_application",
|
|
40
|
+
"security_relevance": "LLM chat interface",
|
|
41
|
+
"vuln_families": ["prompt_injection", "instruction_boundary"],
|
|
42
|
+
"priority": 9,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"surface_type": "ai_application",
|
|
46
|
+
"security_relevance": "AI API endpoint",
|
|
47
|
+
"vuln_families": ["api_security"],
|
|
48
|
+
"priority": 7,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class ReconAgent(AgentRole):
|
|
55
|
+
role = "recon"
|
|
56
|
+
|
|
57
|
+
def process_observation(
|
|
58
|
+
self, kind: str, identifier: str, *, evidence_ref: str = "", discovered_by: str = "recon"
|
|
59
|
+
) -> list[str]:
|
|
60
|
+
"""Record one asset and return the lead ids created for it."""
|
|
61
|
+
asset_id = self.context.add_asset(
|
|
62
|
+
kind, identifier, discovered_by=discovered_by, evidence_ref=evidence_ref
|
|
63
|
+
)
|
|
64
|
+
lead_ids: list[str] = []
|
|
65
|
+
for lead in _SURFACE_LEADS.get(kind, []):
|
|
66
|
+
lead_ids.append(
|
|
67
|
+
self.context.add_lead(
|
|
68
|
+
asset_id,
|
|
69
|
+
lead["surface_type"],
|
|
70
|
+
source=identifier,
|
|
71
|
+
evidence_ref=evidence_ref,
|
|
72
|
+
security_relevance=lead["security_relevance"],
|
|
73
|
+
vuln_families=lead["vuln_families"],
|
|
74
|
+
priority=lead["priority"],
|
|
75
|
+
confidence="observed",
|
|
76
|
+
)
|
|
77
|
+
)
|
|
78
|
+
return lead_ids
|
assets/__init__.py
ADDED
|
File without changes
|
audit/__init__.py
ADDED
|
File without changes
|