-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_system.py
More file actions
154 lines (119 loc) · 4.45 KB
/
Copy pathtest_system.py
File metadata and controls
154 lines (119 loc) · 4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/usr/bin/env python3
"""
Simple test script to verify the AI-Powered Penetration Testing Agent
"""
import sys
import os
from pathlib import Path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
def test_imports():
"""Test that all modules can be imported"""
print("Testing module imports...")
try:
from core.agent import PentestAgent
print("✓ PentestAgent imported successfully")
except ImportError as e:
print(f"✗ Failed to import PentestAgent: {e}")
return False
try:
from modules.reconnaissance.recon_engine import ReconnaissanceEngine
print("✓ ReconnaissanceEngine imported successfully")
except ImportError as e:
print(f"✗ Failed to import ReconnaissanceEngine: {e}")
return False
try:
from ai.rl_agent.rl_agent import RLAgent
print("✓ RLAgent imported successfully")
except ImportError as e:
print(f"✗ Failed to import RLAgent: {e}")
return False
try:
from config.safety_manager import SafetyManager
print("✓ SafetyManager imported successfully")
except ImportError as e:
print(f"✗ Failed to import SafetyManager: {e}")
return False
return True
def test_configuration():
"""Test configuration loading"""
print("\nTesting configuration...")
try:
import yaml
with open("config/config.yaml", "r") as f:
config = yaml.safe_load(f)
required_sections = ["safety", "ai", "scope", "reconnaissance"]
for section in required_sections:
if section in config:
print(f"✓ Configuration section '{section}' found")
else:
print(f"✗ Configuration section '{section}' missing")
return False
return True
except Exception as e:
print(f"✗ Configuration test failed: {e}")
return False
def test_directory_structure():
"""Test that required directories exist"""
print("\nTesting directory structure...")
required_dirs = ["core", "modules", "ai", "config", "reporting"]
for directory in required_dirs:
if os.path.exists(directory):
print(f"✓ Directory '{directory}' exists")
else:
print(f"✗ Directory '{directory}' missing")
return False
return True
def test_basic_functionality():
"""Test basic functionality without external dependencies"""
print("\nTesting basic functionality...")
try:
import yaml
with open("config/config.yaml", "r") as f:
config = yaml.safe_load(f)
from config.safety_manager import SafetyManager
safety_manager = SafetyManager(config)
summary = safety_manager.get_safety_summary()
if isinstance(summary, dict):
print("✓ Safety manager working correctly")
else:
print("✗ Safety manager not working correctly")
return False
return True
except Exception as e:
print(f"✗ Basic functionality test failed: {e}")
return False
def main():
"""Main test function"""
print("=" * 60)
print("AI-Powered Penetration Testing Agent - System Test")
print("=" * 60)
tests = [
("Module Imports", test_imports),
("Directory Structure", test_directory_structure),
("Configuration", test_configuration),
("Basic Functionality", test_basic_functionality),
]
passed = 0
total = len(tests)
for test_name, test_func in tests:
print(f"\n{test_name}:")
if test_func():
passed += 1
else:
print(f"✗ {test_name} failed")
print("\n" + "=" * 60)
print(f"Test Results: {passed}/{total} tests passed")
if passed == total:
print("✓ All tests passed! System is ready to use.")
print("\nNext steps:")
print("1. Run: python install.py to install dependencies")
print("2. Run: python example_usage.py to see the system in action")
else:
print("✗ Some tests failed. Please check the errors above.")
print("\nTroubleshooting:")
print("1. Make sure all files are in the correct locations")
print("2. Check that Python 3.8+ is installed")
print("3. Run: python install.py to install dependencies")
print("=" * 60)
if __name__ == "__main__":
main()