-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_enhanced_features.py
More file actions
175 lines (141 loc) · 5.14 KB
/
setup_enhanced_features.py
File metadata and controls
175 lines (141 loc) · 5.14 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
"""
Setup script for RedTeam Enhanced Features
Run this script to verify your installation and set up initial configuration.
"""
import os
import sys
from pathlib import Path
def check_python_version():
"""Check if Python version is compatible."""
print("Checking Python version...")
version = sys.version_info
if version.major < 3 or (version.major == 3 and version.minor < 7):
print(f" [FAIL] Python {version.major}.{version.minor} is not supported.")
print(f" Please upgrade to Python 3.7 or higher.")
return False
print(f" [OK] Python {version.major}.{version.minor}.{version.micro}")
return True
def check_dependencies():
"""Check if required dependencies are installed."""
print("\nChecking dependencies...")
required = [
'streamlit', 'requests', 'pytest', 'langchain',
'langchain_openai', 'langchain_google_genai',
'plotly', 'pandas', 'jinja2'
]
optional = ['weasyprint', 'presidio_analyzer', 'spacy']
missing_required = []
missing_optional = []
for package in required:
try:
__import__(package)
print(f" [OK] {package}")
except ImportError:
print(f" [MISSING] {package}")
missing_required.append(package)
print("\nChecking optional dependencies...")
for package in optional:
try:
__import__(package)
print(f" [OK] {package}")
except ImportError:
print(f" [OPTIONAL] {package} (not required)")
missing_optional.append(package)
return missing_required, missing_optional
def create_directories():
"""Create necessary directories."""
print("\nCreating directories...")
directories = ['data', 'exports', 'security', 'ui']
for directory in directories:
path = Path(directory)
if path.exists():
print(f" [EXISTS] {directory}/")
else:
path.mkdir(parents=True, exist_ok=True)
print(f" [CREATED] {directory}/")
def check_data_files():
"""Check if data files exist."""
print("\nChecking data files...")
files = {
'data/sample_attack_cases.json': 'Attack cases',
'data/results.jsonl': 'Results (will be created on first run)',
'data/score_report.json': 'Scores (will be created by scorer)',
}
for file_path, description in files.items():
path = Path(file_path)
if path.exists():
print(f" [OK] {file_path} - {description}")
else:
print(f" [MISSING] {file_path} - {description}")
def create_default_users():
"""Create default users file."""
print("\nSetting up access control...")
users_file = Path('data/users.json')
if users_file.exists():
print(f" [EXISTS] Users file already exists")
return
# Import and create default admin
try:
from security import get_access_control
ac = get_access_control()
print(f" [CREATED] Default admin user created")
print(f" [INFO] Username: admin")
print(f" [INFO] Role: ADMIN")
except Exception as e:
print(f" [WARN] Could not create default users: {e}")
def print_next_steps(missing_required):
"""Print next steps for the user."""
print("\n" + "="*60)
print("Setup Summary")
print("="*60)
if missing_required:
print("\n❌ Required dependencies missing!")
print("\nPlease install missing dependencies:")
print(f" pip install {' '.join(missing_required)}")
print("\nOr install all dependencies:")
print(" pip install -r requirements.txt")
else:
print("\n✅ All required dependencies installed!")
print("\n" + "="*60)
print("Next Steps")
print("="*60)
print("\n1. Generate attack cases (if not already done):")
print(" python -m attacks.generator")
print("\n2. Run attacks:")
print(" python -m runner.cli --model=mock --attacks-file=data/sample_attack_cases.json")
print("\n3. Score results:")
print(" python -m eval.scorer --results=data/results.jsonl --out=data/score_report.json")
print("\n4. Launch enhanced dashboard:")
print(" streamlit run ui/enhanced_app.py")
print("\n5. Test security features:")
print(" python test_new_features.py")
print("\n" + "="*60)
print("Documentation")
print("="*60)
print("\n- Quick Start: QUICKSTART.md")
print("- Full Documentation: FEATURES.md")
print("- Implementation Details: IMPLEMENTATION_SUMMARY.md")
print("\n" + "="*60)
print("Enjoy the enhanced RedTeam framework! 🎯")
print("="*60)
def main():
"""Main setup function."""
print("="*60)
print("RedTeam Enhanced Features - Setup")
print("="*60)
# Check Python version
if not check_python_version():
return
# Check dependencies
missing_required, missing_optional = check_dependencies()
# Create directories
create_directories()
# Check data files
check_data_files()
# Create default users
if not missing_required:
create_default_users()
# Print next steps
print_next_steps(missing_required)
if __name__ == "__main__":
main()