fix: auto-fix code issues (cron)
- 修复重复导入/字段 - 修复异常处理 - 修复PEP8格式问题 (816+ 处) - 添加缺失的导入 (json, re) - 统一SQL查询格式 - 修复赋值语句空格问题 修复文件: - db_manager.py (96处) - search_manager.py (77处) - ops_manager.py (66处) - developer_ecosystem_manager.py (68处) - growth_manager.py (60处) - enterprise_manager.py (61处) - tenant_manager.py (57处) - plugin_manager.py (48处) - subscription_manager.py (46处) - security_manager.py (29处) - workflow_manager.py (32处) - localization_manager.py (31处) - api_key_manager.py (20处) - ai_manager.py (23处) - performance_manager.py (24处) - neo4j_manager.py (25处) - collaboration_manager.py (33处) - test_phase8_task8.py (16处) - test_phase8_task6.py (4处) - knowledge_reasoner.py (添加import json) - llm_client.py (添加import json)
This commit is contained in:
@@ -409,16 +409,16 @@ class SecurityManager:
|
||||
params = []
|
||||
|
||||
if user_id:
|
||||
query += " AND user_id = ?"
|
||||
query += " AND user_id = ?"
|
||||
params.append(user_id)
|
||||
if resource_type:
|
||||
query += " AND resource_type = ?"
|
||||
query += " AND resource_type = ?"
|
||||
params.append(resource_type)
|
||||
if resource_id:
|
||||
query += " AND resource_id = ?"
|
||||
query += " AND resource_id = ?"
|
||||
params.append(resource_id)
|
||||
if action_type:
|
||||
query += " AND action_type = ?"
|
||||
query += " AND action_type = ?"
|
||||
params.append(action_type)
|
||||
if start_time:
|
||||
query += " AND created_at >= ?"
|
||||
@@ -427,7 +427,7 @@ class SecurityManager:
|
||||
query += " AND created_at <= ?"
|
||||
params.append(end_time)
|
||||
if success is not None:
|
||||
query += " AND success = ?"
|
||||
query += " AND success = ?"
|
||||
params.append(int(success))
|
||||
|
||||
query += " ORDER BY created_at DESC LIMIT ? OFFSET ?"
|
||||
@@ -546,16 +546,16 @@ class SecurityManager:
|
||||
cursor = conn.cursor()
|
||||
|
||||
# 检查是否已存在配置
|
||||
cursor.execute("SELECT id FROM encryption_configs WHERE project_id = ?", (project_id,))
|
||||
cursor.execute("SELECT id FROM encryption_configs WHERE project_id = ?", (project_id,))
|
||||
existing = cursor.fetchone()
|
||||
|
||||
if existing:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE encryption_configs
|
||||
SET is_enabled = 1, encryption_type = ?, key_derivation = ?,
|
||||
master_key_hash = ?, salt = ?, updated_at = ?
|
||||
WHERE project_id = ?
|
||||
SET is_enabled = 1, encryption_type = ?, key_derivation = ?,
|
||||
master_key_hash = ?, salt = ?, updated_at = ?
|
||||
WHERE project_id = ?
|
||||
""",
|
||||
(
|
||||
config.encryption_type,
|
||||
@@ -613,8 +613,8 @@ class SecurityManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE encryption_configs
|
||||
SET is_enabled = 0, updated_at = ?
|
||||
WHERE project_id = ?
|
||||
SET is_enabled = 0, updated_at = ?
|
||||
WHERE project_id = ?
|
||||
""",
|
||||
(datetime.now().isoformat(), project_id),
|
||||
)
|
||||
@@ -640,7 +640,7 @@ class SecurityManager:
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute(
|
||||
"SELECT master_key_hash, salt FROM encryption_configs WHERE project_id = ?",
|
||||
"SELECT master_key_hash, salt FROM encryption_configs WHERE project_id = ?",
|
||||
(project_id,),
|
||||
)
|
||||
row = cursor.fetchone()
|
||||
@@ -660,7 +660,7 @@ class SecurityManager:
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("SELECT * FROM encryption_configs WHERE project_id = ?", (project_id,))
|
||||
cursor.execute("SELECT * FROM encryption_configs WHERE project_id = ?", (project_id,))
|
||||
row = cursor.fetchone()
|
||||
conn.close()
|
||||
|
||||
@@ -777,11 +777,11 @@ class SecurityManager:
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = "SELECT * FROM masking_rules WHERE project_id = ?"
|
||||
query = "SELECT * FROM masking_rules WHERE project_id = ?"
|
||||
params = [project_id]
|
||||
|
||||
if active_only:
|
||||
query += " AND is_active = 1"
|
||||
query += " AND is_active = 1"
|
||||
|
||||
query += " ORDER BY priority DESC"
|
||||
|
||||
@@ -828,7 +828,7 @@ class SecurityManager:
|
||||
conn.close()
|
||||
return None
|
||||
|
||||
set_clauses.append("updated_at = ?")
|
||||
set_clauses.append("updated_at = ?")
|
||||
params.append(datetime.now().isoformat())
|
||||
params.append(rule_id)
|
||||
|
||||
@@ -836,7 +836,7 @@ class SecurityManager:
|
||||
f"""
|
||||
UPDATE masking_rules
|
||||
SET {", ".join(set_clauses)}
|
||||
WHERE id = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
params,
|
||||
)
|
||||
@@ -847,7 +847,7 @@ class SecurityManager:
|
||||
# 获取更新后的规则
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("SELECT * FROM masking_rules WHERE id = ?", (rule_id,))
|
||||
cursor.execute("SELECT * FROM masking_rules WHERE id = ?", (rule_id,))
|
||||
row = cursor.fetchone()
|
||||
conn.close()
|
||||
|
||||
@@ -873,7 +873,7 @@ class SecurityManager:
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute("DELETE FROM masking_rules WHERE id = ?", (rule_id,))
|
||||
cursor.execute("DELETE FROM masking_rules WHERE id = ?", (rule_id,))
|
||||
|
||||
success = cursor.rowcount > 0
|
||||
conn.commit()
|
||||
@@ -988,11 +988,11 @@ class SecurityManager:
|
||||
conn = sqlite3.connect(self.db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
query = "SELECT * FROM data_access_policies WHERE project_id = ?"
|
||||
query = "SELECT * FROM data_access_policies WHERE project_id = ?"
|
||||
params = [project_id]
|
||||
|
||||
if active_only:
|
||||
query += " AND is_active = 1"
|
||||
query += " AND is_active = 1"
|
||||
|
||||
cursor.execute(query, params)
|
||||
rows = cursor.fetchall()
|
||||
@@ -1028,7 +1028,7 @@ class SecurityManager:
|
||||
cursor = conn.cursor()
|
||||
|
||||
cursor.execute(
|
||||
"SELECT * FROM data_access_policies WHERE id = ? AND is_active = 1", (policy_id,)
|
||||
"SELECT * FROM data_access_policies WHERE id = ? AND is_active = 1", (policy_id,)
|
||||
)
|
||||
row = cursor.fetchone()
|
||||
conn.close()
|
||||
@@ -1092,7 +1092,7 @@ class SecurityManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
SELECT * FROM access_requests
|
||||
WHERE policy_id = ? AND user_id = ? AND status = 'approved'
|
||||
WHERE policy_id = ? AND user_id = ? AND status = 'approved'
|
||||
AND (expires_at IS NULL OR expires_at > ?)
|
||||
""",
|
||||
(policy_id, user_id, datetime.now().isoformat()),
|
||||
@@ -1175,8 +1175,8 @@ class SecurityManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE access_requests
|
||||
SET status = 'approved', approved_by = ?, approved_at = ?, expires_at = ?
|
||||
WHERE id = ?
|
||||
SET status = 'approved', approved_by = ?, approved_at = ?, expires_at = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(approved_by, approved_at, expires_at, request_id),
|
||||
)
|
||||
@@ -1184,7 +1184,7 @@ class SecurityManager:
|
||||
conn.commit()
|
||||
|
||||
# 获取更新后的请求
|
||||
cursor.execute("SELECT * FROM access_requests WHERE id = ?", (request_id,))
|
||||
cursor.execute("SELECT * FROM access_requests WHERE id = ?", (request_id,))
|
||||
row = cursor.fetchone()
|
||||
conn.close()
|
||||
|
||||
@@ -1211,15 +1211,15 @@ class SecurityManager:
|
||||
cursor.execute(
|
||||
"""
|
||||
UPDATE access_requests
|
||||
SET status = 'rejected', approved_by = ?
|
||||
WHERE id = ?
|
||||
SET status = 'rejected', approved_by = ?
|
||||
WHERE id = ?
|
||||
""",
|
||||
(rejected_by, request_id),
|
||||
)
|
||||
|
||||
conn.commit()
|
||||
|
||||
cursor.execute("SELECT * FROM access_requests WHERE id = ?", (request_id,))
|
||||
cursor.execute("SELECT * FROM access_requests WHERE id = ?", (request_id,))
|
||||
row = cursor.fetchone()
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user