-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_phase2.py
More file actions
151 lines (117 loc) · 3.89 KB
/
test_phase2.py
File metadata and controls
151 lines (117 loc) · 3.89 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
"""
VScanX Phase 2 Feature Test
Tests all new features
"""
import sys
import pytest
def test_imports():
"""Test that all modules can be imported"""
print("=" * 60)
print("TESTING IMPORTS")
print("=" * 60)
try:
from core.config import SCAN_PROFILES, VERSION
print(f"✓ Config imported (Version: {VERSION})")
print(f" Available profiles: {', '.join(SCAN_PROFILES.keys())}")
except Exception as e:
pytest.fail(f"Config import failed: {e}")
try:
print("✓ Export formats module imported")
except Exception as e:
pytest.fail(f"Export module failed: {e}")
try:
print("✓ SQL Injection detector imported")
except Exception as e:
pytest.fail(f"SQLi detector failed: {e}")
try:
print("✓ Directory enumerator imported")
except Exception as e:
pytest.fail(f"Directory enumerator failed: {e}")
try:
print("✓ Header analyzer imported")
except Exception as e:
pytest.fail(f"Header analyzer failed: {e}")
try:
print("✓ Enhanced orchestrator imported")
except Exception as e:
pytest.fail(f"Orchestrator failed: {e}")
print("\n✓ All imports successful!\n")
def test_profiles():
"""Test scan profiles"""
print("=" * 60)
print("TESTING SCAN PROFILES")
print("=" * 60)
from core.config import SCAN_PROFILES
for name, config in SCAN_PROFILES.items():
print(f"\n{name.upper()}:")
print(f" Port range: {config['port_range']}")
print(f" Threads: {config['max_threads']}")
print(f" Delay: {config['delay']}s")
print("\n✓ Profiles configured correctly!\n")
def test_export():
"""Test export functionality"""
print("=" * 60)
print("TESTING EXPORT FORMATS")
print("=" * 60)
from reporting.export_formats import ExportHandler
# Create test data
test_results = {
"target": "http://test.com",
"scan_type": "web",
"timestamp": "2025-12-12T16:00:00",
"duration": 10.5,
"modules": [
{
"module": "Test Module",
"findings": [
{
"severity": "HIGH",
"finding": "Test vulnerability",
"details": "This is a test",
}
],
}
],
}
test_summary = {
"total_findings": 1,
"by_severity": {"CRITICAL": 0, "HIGH": 1, "MEDIUM": 0, "LOW": 0, "INFO": 0},
}
exporter = ExportHandler()
try:
json_path = exporter.export_json(test_results, "test_export")
print(f"✓ JSON export: {json_path}")
except Exception as e:
print(f"✗ JSON export failed: {e}")
try:
csv_path = exporter.export_csv(test_results, "test_export")
print(f"✓ CSV export: {csv_path}")
except Exception as e:
print(f"✗ CSV export failed: {e}")
try:
txt_path = exporter.export_txt(test_results, test_summary, "test_export")
print(f"✓ TXT export: {txt_path}")
except Exception as e:
print(f"✗ TXT export failed: {e}")
print("\n✓ Export formats working!\n")
def main():
"""Run all tests"""
print("\n" + "=" * 60)
print("VScanX Phase 2 Feature Test")
print("=" * 60 + "\n")
if not test_imports():
print("\n✗ Import tests failed! Fix errors before proceeding.\n")
sys.exit(1)
test_profiles()
test_export()
print("=" * 60)
print("✓ ALL TESTS PASSED!")
print("=" * 60)
print("\nPhase 2 features are ready!")
print("\nNext steps:")
print("1. Test with: python vscanx.py --list-profiles")
print("2. Run quick scan: python vscanx.py -t http://127.0.0.1:8080 --profile quick")
print("3. Full scan: python vscanx.py -t http://127.0.0.1:8080 --profile full -v")
print()
if __name__ == "__main__":
main()