aiptx 2.0.7__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.
- aipt_v2/__init__.py +110 -0
- aipt_v2/__main__.py +24 -0
- aipt_v2/agents/AIPTxAgent/__init__.py +10 -0
- aipt_v2/agents/AIPTxAgent/aiptx_agent.py +211 -0
- aipt_v2/agents/__init__.py +46 -0
- aipt_v2/agents/base.py +520 -0
- aipt_v2/agents/exploit_agent.py +688 -0
- aipt_v2/agents/ptt.py +406 -0
- aipt_v2/agents/state.py +168 -0
- aipt_v2/app.py +957 -0
- aipt_v2/browser/__init__.py +31 -0
- aipt_v2/browser/automation.py +458 -0
- aipt_v2/browser/crawler.py +453 -0
- aipt_v2/cli.py +2933 -0
- aipt_v2/compliance/__init__.py +71 -0
- aipt_v2/compliance/compliance_report.py +449 -0
- aipt_v2/compliance/framework_mapper.py +424 -0
- aipt_v2/compliance/nist_mapping.py +345 -0
- aipt_v2/compliance/owasp_mapping.py +330 -0
- aipt_v2/compliance/pci_mapping.py +297 -0
- aipt_v2/config.py +341 -0
- aipt_v2/core/__init__.py +43 -0
- aipt_v2/core/agent.py +630 -0
- aipt_v2/core/llm.py +395 -0
- aipt_v2/core/memory.py +305 -0
- aipt_v2/core/ptt.py +329 -0
- aipt_v2/database/__init__.py +14 -0
- aipt_v2/database/models.py +232 -0
- aipt_v2/database/repository.py +384 -0
- aipt_v2/docker/__init__.py +23 -0
- aipt_v2/docker/builder.py +260 -0
- aipt_v2/docker/manager.py +222 -0
- aipt_v2/docker/sandbox.py +371 -0
- aipt_v2/evasion/__init__.py +58 -0
- aipt_v2/evasion/request_obfuscator.py +272 -0
- aipt_v2/evasion/tls_fingerprint.py +285 -0
- aipt_v2/evasion/ua_rotator.py +301 -0
- aipt_v2/evasion/waf_bypass.py +439 -0
- aipt_v2/execution/__init__.py +23 -0
- aipt_v2/execution/executor.py +302 -0
- aipt_v2/execution/parser.py +544 -0
- aipt_v2/execution/terminal.py +337 -0
- aipt_v2/health.py +437 -0
- aipt_v2/intelligence/__init__.py +194 -0
- aipt_v2/intelligence/adaptation.py +474 -0
- aipt_v2/intelligence/auth.py +520 -0
- aipt_v2/intelligence/chaining.py +775 -0
- aipt_v2/intelligence/correlation.py +536 -0
- aipt_v2/intelligence/cve_aipt.py +334 -0
- aipt_v2/intelligence/cve_info.py +1111 -0
- aipt_v2/intelligence/knowledge_graph.py +590 -0
- aipt_v2/intelligence/learning.py +626 -0
- aipt_v2/intelligence/llm_analyzer.py +502 -0
- aipt_v2/intelligence/llm_tool_selector.py +518 -0
- aipt_v2/intelligence/payload_generator.py +562 -0
- aipt_v2/intelligence/rag.py +239 -0
- aipt_v2/intelligence/scope.py +442 -0
- aipt_v2/intelligence/searchers/__init__.py +5 -0
- aipt_v2/intelligence/searchers/exploitdb_searcher.py +523 -0
- aipt_v2/intelligence/searchers/github_searcher.py +467 -0
- aipt_v2/intelligence/searchers/google_searcher.py +281 -0
- aipt_v2/intelligence/tools.json +443 -0
- aipt_v2/intelligence/triage.py +670 -0
- aipt_v2/interactive_shell.py +559 -0
- aipt_v2/interface/__init__.py +5 -0
- aipt_v2/interface/cli.py +230 -0
- aipt_v2/interface/main.py +501 -0
- aipt_v2/interface/tui.py +1276 -0
- aipt_v2/interface/utils.py +583 -0
- aipt_v2/llm/__init__.py +39 -0
- aipt_v2/llm/config.py +26 -0
- aipt_v2/llm/llm.py +514 -0
- aipt_v2/llm/memory.py +214 -0
- aipt_v2/llm/request_queue.py +89 -0
- aipt_v2/llm/utils.py +89 -0
- aipt_v2/local_tool_installer.py +1467 -0
- aipt_v2/models/__init__.py +15 -0
- aipt_v2/models/findings.py +295 -0
- aipt_v2/models/phase_result.py +224 -0
- aipt_v2/models/scan_config.py +207 -0
- aipt_v2/monitoring/grafana/dashboards/aipt-dashboard.json +355 -0
- aipt_v2/monitoring/grafana/dashboards/default.yml +17 -0
- aipt_v2/monitoring/grafana/datasources/prometheus.yml +17 -0
- aipt_v2/monitoring/prometheus.yml +60 -0
- aipt_v2/orchestration/__init__.py +52 -0
- aipt_v2/orchestration/pipeline.py +398 -0
- aipt_v2/orchestration/progress.py +300 -0
- aipt_v2/orchestration/scheduler.py +296 -0
- aipt_v2/orchestrator.py +2427 -0
- aipt_v2/payloads/__init__.py +27 -0
- aipt_v2/payloads/cmdi.py +150 -0
- aipt_v2/payloads/sqli.py +263 -0
- aipt_v2/payloads/ssrf.py +204 -0
- aipt_v2/payloads/templates.py +222 -0
- aipt_v2/payloads/traversal.py +166 -0
- aipt_v2/payloads/xss.py +204 -0
- aipt_v2/prompts/__init__.py +60 -0
- aipt_v2/proxy/__init__.py +29 -0
- aipt_v2/proxy/history.py +352 -0
- aipt_v2/proxy/interceptor.py +452 -0
- aipt_v2/recon/__init__.py +44 -0
- aipt_v2/recon/dns.py +241 -0
- aipt_v2/recon/osint.py +367 -0
- aipt_v2/recon/subdomain.py +372 -0
- aipt_v2/recon/tech_detect.py +311 -0
- aipt_v2/reports/__init__.py +17 -0
- aipt_v2/reports/generator.py +313 -0
- aipt_v2/reports/html_report.py +378 -0
- aipt_v2/runtime/__init__.py +53 -0
- aipt_v2/runtime/base.py +30 -0
- aipt_v2/runtime/docker.py +401 -0
- aipt_v2/runtime/local.py +346 -0
- aipt_v2/runtime/tool_server.py +205 -0
- aipt_v2/runtime/vps.py +830 -0
- aipt_v2/scanners/__init__.py +28 -0
- aipt_v2/scanners/base.py +273 -0
- aipt_v2/scanners/nikto.py +244 -0
- aipt_v2/scanners/nmap.py +402 -0
- aipt_v2/scanners/nuclei.py +273 -0
- aipt_v2/scanners/web.py +454 -0
- aipt_v2/scripts/security_audit.py +366 -0
- aipt_v2/setup_wizard.py +941 -0
- aipt_v2/skills/__init__.py +80 -0
- aipt_v2/skills/agents/__init__.py +14 -0
- aipt_v2/skills/agents/api_tester.py +706 -0
- aipt_v2/skills/agents/base.py +477 -0
- aipt_v2/skills/agents/code_review.py +459 -0
- aipt_v2/skills/agents/security_agent.py +336 -0
- aipt_v2/skills/agents/web_pentest.py +818 -0
- aipt_v2/skills/prompts/__init__.py +647 -0
- aipt_v2/system_detector.py +539 -0
- aipt_v2/telemetry/__init__.py +7 -0
- aipt_v2/telemetry/tracer.py +347 -0
- aipt_v2/terminal/__init__.py +28 -0
- aipt_v2/terminal/executor.py +400 -0
- aipt_v2/terminal/sandbox.py +350 -0
- aipt_v2/tools/__init__.py +44 -0
- aipt_v2/tools/active_directory/__init__.py +78 -0
- aipt_v2/tools/active_directory/ad_config.py +238 -0
- aipt_v2/tools/active_directory/bloodhound_wrapper.py +447 -0
- aipt_v2/tools/active_directory/kerberos_attacks.py +430 -0
- aipt_v2/tools/active_directory/ldap_enum.py +533 -0
- aipt_v2/tools/active_directory/smb_attacks.py +505 -0
- aipt_v2/tools/agents_graph/__init__.py +19 -0
- aipt_v2/tools/agents_graph/agents_graph_actions.py +69 -0
- aipt_v2/tools/api_security/__init__.py +76 -0
- aipt_v2/tools/api_security/api_discovery.py +608 -0
- aipt_v2/tools/api_security/graphql_scanner.py +622 -0
- aipt_v2/tools/api_security/jwt_analyzer.py +577 -0
- aipt_v2/tools/api_security/openapi_fuzzer.py +761 -0
- aipt_v2/tools/browser/__init__.py +5 -0
- aipt_v2/tools/browser/browser_actions.py +238 -0
- aipt_v2/tools/browser/browser_instance.py +535 -0
- aipt_v2/tools/browser/tab_manager.py +344 -0
- aipt_v2/tools/cloud/__init__.py +70 -0
- aipt_v2/tools/cloud/cloud_config.py +273 -0
- aipt_v2/tools/cloud/cloud_scanner.py +639 -0
- aipt_v2/tools/cloud/prowler_tool.py +571 -0
- aipt_v2/tools/cloud/scoutsuite_tool.py +359 -0
- aipt_v2/tools/executor.py +307 -0
- aipt_v2/tools/parser.py +408 -0
- aipt_v2/tools/proxy/__init__.py +5 -0
- aipt_v2/tools/proxy/proxy_actions.py +103 -0
- aipt_v2/tools/proxy/proxy_manager.py +789 -0
- aipt_v2/tools/registry.py +196 -0
- aipt_v2/tools/scanners/__init__.py +343 -0
- aipt_v2/tools/scanners/acunetix_tool.py +712 -0
- aipt_v2/tools/scanners/burp_tool.py +631 -0
- aipt_v2/tools/scanners/config.py +156 -0
- aipt_v2/tools/scanners/nessus_tool.py +588 -0
- aipt_v2/tools/scanners/zap_tool.py +612 -0
- aipt_v2/tools/terminal/__init__.py +5 -0
- aipt_v2/tools/terminal/terminal_actions.py +37 -0
- aipt_v2/tools/terminal/terminal_manager.py +153 -0
- aipt_v2/tools/terminal/terminal_session.py +449 -0
- aipt_v2/tools/tool_processing.py +108 -0
- aipt_v2/utils/__init__.py +17 -0
- aipt_v2/utils/logging.py +202 -0
- aipt_v2/utils/model_manager.py +187 -0
- aipt_v2/utils/searchers/__init__.py +269 -0
- aipt_v2/verify_install.py +793 -0
- aiptx-2.0.7.dist-info/METADATA +345 -0
- aiptx-2.0.7.dist-info/RECORD +187 -0
- aiptx-2.0.7.dist-info/WHEEL +5 -0
- aiptx-2.0.7.dist-info/entry_points.txt +7 -0
- aiptx-2.0.7.dist-info/licenses/LICENSE +21 -0
- aiptx-2.0.7.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Security Agent - Main coordinator for AI-powered security testing.
|
|
3
|
+
|
|
4
|
+
This is the primary entry point for AI-driven security assessments.
|
|
5
|
+
It can coordinate multiple specialized agents or perform comprehensive
|
|
6
|
+
testing on its own.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import asyncio
|
|
10
|
+
import json
|
|
11
|
+
from typing import Any, Dict, List, Optional
|
|
12
|
+
|
|
13
|
+
import structlog
|
|
14
|
+
|
|
15
|
+
from aipt_v2.skills.agents.base import (
|
|
16
|
+
AgentConfig,
|
|
17
|
+
AgentResult,
|
|
18
|
+
BaseSecurityAgent,
|
|
19
|
+
Finding,
|
|
20
|
+
Severity,
|
|
21
|
+
)
|
|
22
|
+
from aipt_v2.skills.prompts import SkillPrompts, VULNERABILITY_PROMPTS
|
|
23
|
+
|
|
24
|
+
logger = structlog.get_logger()
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
SECURITY_AGENT_SYSTEM_PROMPT = """You are an elite AI security testing agent with expertise across:
|
|
28
|
+
- Web application security (OWASP Top 10)
|
|
29
|
+
- API security (OWASP API Top 10)
|
|
30
|
+
- Source code security review
|
|
31
|
+
- Network security assessment
|
|
32
|
+
- Cloud security
|
|
33
|
+
|
|
34
|
+
Your mission is to perform comprehensive security testing and discover vulnerabilities.
|
|
35
|
+
|
|
36
|
+
## CAPABILITIES
|
|
37
|
+
|
|
38
|
+
1. **Web Testing**: XSS, SQLi, SSRF, RCE, authentication bypass
|
|
39
|
+
2. **API Testing**: BOLA, BFLA, injection, mass assignment
|
|
40
|
+
3. **Code Review**: Static analysis, secret detection, dependency scanning
|
|
41
|
+
4. **Configuration**: Security headers, TLS, misconfigurations
|
|
42
|
+
|
|
43
|
+
## TESTING PHILOSOPHY
|
|
44
|
+
|
|
45
|
+
- Be thorough and systematic
|
|
46
|
+
- Test ALL inputs and endpoints
|
|
47
|
+
- Use multiple payloads and techniques
|
|
48
|
+
- Document everything with evidence
|
|
49
|
+
- Prioritize critical vulnerabilities
|
|
50
|
+
|
|
51
|
+
## SEVERITY GUIDELINES
|
|
52
|
+
|
|
53
|
+
- **CRITICAL**: Remote code execution, authentication bypass, admin access
|
|
54
|
+
- **HIGH**: SQL injection, XSS (stored), sensitive data exposure
|
|
55
|
+
- **MEDIUM**: XSS (reflected), CSRF, information disclosure
|
|
56
|
+
- **LOW**: Missing headers, verbose errors, minor issues
|
|
57
|
+
- **INFO**: Best practice recommendations
|
|
58
|
+
|
|
59
|
+
## OUTPUT FORMAT
|
|
60
|
+
|
|
61
|
+
For each finding, provide:
|
|
62
|
+
- Clear title describing the issue
|
|
63
|
+
- Accurate severity rating
|
|
64
|
+
- Detailed description with impact
|
|
65
|
+
- Steps to reproduce with payloads
|
|
66
|
+
- Evidence (requests/responses/code)
|
|
67
|
+
- Specific remediation steps
|
|
68
|
+
|
|
69
|
+
Continue testing until exhausted or stopped."""
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class SecurityAgent(BaseSecurityAgent):
|
|
73
|
+
"""
|
|
74
|
+
Main AI security agent that coordinates comprehensive testing.
|
|
75
|
+
|
|
76
|
+
This is the primary interface for AI-powered security assessments.
|
|
77
|
+
It can:
|
|
78
|
+
- Perform standalone security testing
|
|
79
|
+
- Coordinate multiple specialized agents
|
|
80
|
+
- Combine results from different testing approaches
|
|
81
|
+
|
|
82
|
+
Usage:
|
|
83
|
+
# Standalone testing
|
|
84
|
+
agent = SecurityAgent(target="https://example.com")
|
|
85
|
+
result = await agent.run()
|
|
86
|
+
|
|
87
|
+
# Coordinated testing
|
|
88
|
+
agent = SecurityAgent(target="https://example.com")
|
|
89
|
+
result = await agent.run_full_assessment()
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
def __init__(
|
|
93
|
+
self,
|
|
94
|
+
target: str,
|
|
95
|
+
config: Optional[AgentConfig] = None,
|
|
96
|
+
test_types: Optional[List[str]] = None,
|
|
97
|
+
credentials: Optional[Dict[str, str]] = None
|
|
98
|
+
):
|
|
99
|
+
"""
|
|
100
|
+
Initialize the security agent.
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
target: Target URL, path, or identifier to test
|
|
104
|
+
config: Agent configuration
|
|
105
|
+
test_types: List of test types to perform (web, api, code)
|
|
106
|
+
credentials: Authentication credentials
|
|
107
|
+
"""
|
|
108
|
+
super().__init__(config)
|
|
109
|
+
self.target = target
|
|
110
|
+
self.test_types = test_types or ["web"]
|
|
111
|
+
self.credentials = credentials or {}
|
|
112
|
+
|
|
113
|
+
def get_system_prompt(self) -> str:
|
|
114
|
+
"""Get the security agent system prompt."""
|
|
115
|
+
# Build combined prompt from selected vulnerability types
|
|
116
|
+
prompts = SkillPrompts()
|
|
117
|
+
|
|
118
|
+
# Get vulnerability-specific prompts based on test types
|
|
119
|
+
vuln_prompts = []
|
|
120
|
+
if "web" in self.test_types:
|
|
121
|
+
for vid in ["sqli", "xss", "ssrf", "rce"]:
|
|
122
|
+
if vid in VULNERABILITY_PROMPTS:
|
|
123
|
+
vuln_prompts.append(VULNERABILITY_PROMPTS[vid].system_prompt[:500])
|
|
124
|
+
|
|
125
|
+
combined = SECURITY_AGENT_SYSTEM_PROMPT
|
|
126
|
+
|
|
127
|
+
if vuln_prompts:
|
|
128
|
+
combined += "\n\n## VULNERABILITY EXPERTISE\n\n"
|
|
129
|
+
combined += "\n---\n".join(vuln_prompts)
|
|
130
|
+
|
|
131
|
+
return combined
|
|
132
|
+
|
|
133
|
+
def get_tools(self) -> List[Dict[str, Any]]:
|
|
134
|
+
"""Get tools for security testing."""
|
|
135
|
+
# Import tools from specialized agents
|
|
136
|
+
from aipt_v2.skills.agents.base import get_all_tools
|
|
137
|
+
|
|
138
|
+
tools = []
|
|
139
|
+
|
|
140
|
+
# Add appropriate tools based on test types
|
|
141
|
+
if "web" in self.test_types:
|
|
142
|
+
tools.extend([
|
|
143
|
+
{
|
|
144
|
+
"name": "fetch_page",
|
|
145
|
+
"description": "Fetch a web page and analyze its content",
|
|
146
|
+
"parameters": {
|
|
147
|
+
"url": {"type": "string", "description": "URL to fetch"},
|
|
148
|
+
"headers": {"type": "object", "description": "Optional headers"},
|
|
149
|
+
"method": {"type": "string", "description": "HTTP method"}
|
|
150
|
+
},
|
|
151
|
+
"required": ["url"]
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"name": "test_xss",
|
|
155
|
+
"description": "Test for XSS vulnerabilities",
|
|
156
|
+
"parameters": {
|
|
157
|
+
"url": {"type": "string"},
|
|
158
|
+
"param": {"type": "string"},
|
|
159
|
+
"method": {"type": "string"}
|
|
160
|
+
},
|
|
161
|
+
"required": ["url", "param"]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "test_sqli",
|
|
165
|
+
"description": "Test for SQL injection",
|
|
166
|
+
"parameters": {
|
|
167
|
+
"url": {"type": "string"},
|
|
168
|
+
"param": {"type": "string"},
|
|
169
|
+
"method": {"type": "string"}
|
|
170
|
+
},
|
|
171
|
+
"required": ["url", "param"]
|
|
172
|
+
},
|
|
173
|
+
])
|
|
174
|
+
|
|
175
|
+
if "api" in self.test_types:
|
|
176
|
+
tools.extend([
|
|
177
|
+
{
|
|
178
|
+
"name": "http_request",
|
|
179
|
+
"description": "Send an HTTP request to test an API endpoint",
|
|
180
|
+
"parameters": {
|
|
181
|
+
"method": {"type": "string"},
|
|
182
|
+
"url": {"type": "string"},
|
|
183
|
+
"headers": {"type": "object"},
|
|
184
|
+
"body": {"type": "string"},
|
|
185
|
+
"params": {"type": "object"}
|
|
186
|
+
},
|
|
187
|
+
"required": ["method", "url"]
|
|
188
|
+
},
|
|
189
|
+
])
|
|
190
|
+
|
|
191
|
+
if "code" in self.test_types:
|
|
192
|
+
tools.extend([
|
|
193
|
+
{
|
|
194
|
+
"name": "read_file",
|
|
195
|
+
"description": "Read a source code file",
|
|
196
|
+
"parameters": {
|
|
197
|
+
"file_path": {"type": "string"}
|
|
198
|
+
},
|
|
199
|
+
"required": ["file_path"]
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"name": "search_code",
|
|
203
|
+
"description": "Search for patterns in code",
|
|
204
|
+
"parameters": {
|
|
205
|
+
"directory": {"type": "string"},
|
|
206
|
+
"pattern": {"type": "string"},
|
|
207
|
+
"file_extension": {"type": "string"}
|
|
208
|
+
},
|
|
209
|
+
"required": ["directory", "pattern"]
|
|
210
|
+
},
|
|
211
|
+
])
|
|
212
|
+
|
|
213
|
+
# Always include reporting tool
|
|
214
|
+
tools.append({
|
|
215
|
+
"name": "report_finding",
|
|
216
|
+
"description": "Report a security vulnerability finding",
|
|
217
|
+
"parameters": {
|
|
218
|
+
"title": {"type": "string"},
|
|
219
|
+
"severity": {"type": "string"},
|
|
220
|
+
"category": {"type": "string"},
|
|
221
|
+
"description": {"type": "string"},
|
|
222
|
+
"evidence": {"type": "string"},
|
|
223
|
+
"location": {"type": "string"},
|
|
224
|
+
"remediation": {"type": "string"},
|
|
225
|
+
"cwe_id": {"type": "string"}
|
|
226
|
+
},
|
|
227
|
+
"required": ["title", "severity", "category", "description", "evidence", "location", "remediation"]
|
|
228
|
+
})
|
|
229
|
+
|
|
230
|
+
return tools
|
|
231
|
+
|
|
232
|
+
async def run(self, initial_message: Optional[str] = None) -> AgentResult:
|
|
233
|
+
"""
|
|
234
|
+
Run security testing.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
initial_message: Optional additional instructions
|
|
238
|
+
|
|
239
|
+
Returns:
|
|
240
|
+
AgentResult with findings
|
|
241
|
+
"""
|
|
242
|
+
message = f"""Perform comprehensive security testing on: {self.target}
|
|
243
|
+
|
|
244
|
+
Test Types: {', '.join(self.test_types)}
|
|
245
|
+
|
|
246
|
+
{f'Authentication available: {list(self.credentials.keys())}' if self.credentials else 'No authentication provided'}
|
|
247
|
+
|
|
248
|
+
Begin testing now. Be thorough and systematic.
|
|
249
|
+
|
|
250
|
+
{initial_message or ''}"""
|
|
251
|
+
|
|
252
|
+
return await super().run(message)
|
|
253
|
+
|
|
254
|
+
async def run_full_assessment(self) -> Dict[str, AgentResult]:
|
|
255
|
+
"""
|
|
256
|
+
Run a full security assessment using specialized agents.
|
|
257
|
+
|
|
258
|
+
This coordinates multiple specialized agents for comprehensive testing.
|
|
259
|
+
|
|
260
|
+
Returns:
|
|
261
|
+
Dictionary of results from each agent type
|
|
262
|
+
"""
|
|
263
|
+
results = {}
|
|
264
|
+
|
|
265
|
+
# Run tests in parallel where possible
|
|
266
|
+
tasks = []
|
|
267
|
+
|
|
268
|
+
if "web" in self.test_types:
|
|
269
|
+
from aipt_v2.skills.agents.web_pentest import WebPentestAgent
|
|
270
|
+
web_agent = WebPentestAgent(target=self.target, config=self.config)
|
|
271
|
+
tasks.append(("web", web_agent.run()))
|
|
272
|
+
|
|
273
|
+
if "api" in self.test_types:
|
|
274
|
+
from aipt_v2.skills.agents.api_tester import APITestAgent
|
|
275
|
+
api_agent = APITestAgent(base_url=self.target, config=self.config)
|
|
276
|
+
tasks.append(("api", api_agent.run()))
|
|
277
|
+
|
|
278
|
+
if "code" in self.test_types:
|
|
279
|
+
from aipt_v2.skills.agents.code_review import CodeReviewAgent
|
|
280
|
+
code_agent = CodeReviewAgent(target_path=self.target, config=self.config)
|
|
281
|
+
tasks.append(("code", code_agent.run()))
|
|
282
|
+
|
|
283
|
+
# Execute all agents
|
|
284
|
+
for name, task in tasks:
|
|
285
|
+
try:
|
|
286
|
+
result = await task
|
|
287
|
+
results[name] = result
|
|
288
|
+
logger.info(f"{name} testing complete", findings=len(result.findings))
|
|
289
|
+
except Exception as e:
|
|
290
|
+
logger.error(f"{name} testing failed", error=str(e))
|
|
291
|
+
results[name] = AgentResult(success=False, errors=[str(e)])
|
|
292
|
+
|
|
293
|
+
return results
|
|
294
|
+
|
|
295
|
+
def combine_results(self, results: Dict[str, AgentResult]) -> AgentResult:
|
|
296
|
+
"""
|
|
297
|
+
Combine results from multiple agents into a single result.
|
|
298
|
+
|
|
299
|
+
Args:
|
|
300
|
+
results: Dictionary of results from run_full_assessment
|
|
301
|
+
|
|
302
|
+
Returns:
|
|
303
|
+
Combined AgentResult
|
|
304
|
+
"""
|
|
305
|
+
all_findings = []
|
|
306
|
+
all_errors = []
|
|
307
|
+
total_time = 0
|
|
308
|
+
total_steps = 0
|
|
309
|
+
total_tokens = 0
|
|
310
|
+
|
|
311
|
+
for name, result in results.items():
|
|
312
|
+
all_findings.extend(result.findings)
|
|
313
|
+
all_errors.extend([f"[{name}] {e}" for e in result.errors])
|
|
314
|
+
total_time += result.execution_time
|
|
315
|
+
total_steps += result.total_steps
|
|
316
|
+
total_tokens += result.tokens_used
|
|
317
|
+
|
|
318
|
+
# Sort findings by severity
|
|
319
|
+
severity_order = {
|
|
320
|
+
Severity.CRITICAL: 0,
|
|
321
|
+
Severity.HIGH: 1,
|
|
322
|
+
Severity.MEDIUM: 2,
|
|
323
|
+
Severity.LOW: 3,
|
|
324
|
+
Severity.INFO: 4
|
|
325
|
+
}
|
|
326
|
+
all_findings.sort(key=lambda f: severity_order.get(f.severity, 5))
|
|
327
|
+
|
|
328
|
+
return AgentResult(
|
|
329
|
+
success=len(all_errors) == 0,
|
|
330
|
+
findings=all_findings,
|
|
331
|
+
errors=all_errors,
|
|
332
|
+
execution_time=total_time,
|
|
333
|
+
total_steps=total_steps,
|
|
334
|
+
tokens_used=total_tokens,
|
|
335
|
+
model_used=self.config.model
|
|
336
|
+
)
|