-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_phase_c_settings.py
More file actions
171 lines (156 loc) · 5.77 KB
/
create_phase_c_settings.py
File metadata and controls
171 lines (156 loc) · 5.77 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
from app.utils.time import utcnow
#!/usr/bin/env python3
"""
Simple script to create Phase C settings for bank-grade compliance
This adds the new security and compliance settings to the system_settings table
"""
import sqlite3
import json
from datetime import datetime
def create_phase_c_settings():
"""Add Phase C settings to the system_settings table"""
db_path = "icc_rules.db"
# Connect to the database
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
try:
# Phase C Settings to add
phase_c_settings = [
# Security Settings
{
"section": "security",
"key": "enforce_key_rotation_days",
"value": "90",
"data_type": "integer",
"description": "Number of days after which API keys must be rotated",
"is_sensitive": False
},
{
"section": "security",
"key": "ip_whitelist_enabled",
"value": "false",
"data_type": "boolean",
"description": "Enable IP address whitelisting for API access",
"is_sensitive": False
},
{
"section": "security",
"key": "allowed_ips",
"value": json.dumps([]),
"data_type": "json",
"description": "List of allowed IP addresses/CIDR ranges",
"is_sensitive": False
},
{
"section": "security",
"key": "tenant_isolation",
"value": "true",
"data_type": "boolean",
"description": "Enforce strict tenant data isolation",
"is_sensitive": False
},
# Compliance Settings
{
"section": "compliance",
"key": "backup_frequency",
"value": "daily",
"data_type": "string",
"description": "Frequency of automated backups (daily/weekly/monthly)",
"is_sensitive": False
},
{
"section": "compliance",
"key": "logging_retention_days",
"value": "365",
"data_type": "integer",
"description": "Number of days to retain audit logs",
"is_sensitive": False
},
{
"section": "compliance",
"key": "last_backup_at",
"value": "",
"data_type": "string",
"description": "Timestamp of last successful backup",
"is_sensitive": False
},
# Notifications Settings
{
"section": "notifications",
"key": "alert_emails",
"value": json.dumps(["admin@example.com"]),
"data_type": "json",
"description": "List of email addresses for system alerts",
"is_sensitive": False
},
{
"section": "notifications",
"key": "compliance_alerts_enabled",
"value": "true",
"data_type": "boolean",
"description": "Send alerts for compliance events",
"is_sensitive": False
},
# General Settings Updates
{
"section": "general",
"key": "environment",
"value": "production",
"data_type": "string",
"description": "Current environment (development/staging/production)",
"is_sensitive": False
}
]
# Insert settings (ignore if already exists)
import uuid
for setting in phase_c_settings:
cursor.execute("""
INSERT OR IGNORE INTO system_settings
(id, section, key, value, data_type, description, is_sensitive, created_at, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
""", (
str(uuid.uuid4()),
setting["section"],
setting["key"],
setting["value"],
setting["data_type"],
setting["description"],
setting["is_sensitive"],
utcnow().isoformat(),
utcnow().isoformat()
))
conn.commit()
print("Successfully created Phase C settings")
# Verify the settings were created
cursor.execute("SELECT COUNT(*) FROM system_settings WHERE section IN ('security', 'compliance')")
count = cursor.fetchone()[0]
print(f"Phase C settings count: {count}")
# Show all settings by section
cursor.execute("""
SELECT section, key, value, description
FROM system_settings
ORDER BY section, key
""")
settings_by_section = {}
for row in cursor.fetchall():
section, key, value, description = row
if section not in settings_by_section:
settings_by_section[section] = []
settings_by_section[section].append({
"key": key,
"value": value,
"description": description
})
print("\nAll System Settings by Section:")
for section, settings in settings_by_section.items():
print(f"\n[{section.upper()}]")
for setting in settings:
print(f" {setting['key']}: {setting['value']}")
print(f" Description: {setting['description']}")
except Exception as e:
print(f"Error creating Phase C settings: {e}")
conn.rollback()
finally:
conn.close()
if __name__ == "__main__":
create_phase_c_settings()