Skip to content

Commit 06a937a

Browse files
committed
fix(backend): Properly comment out all log_enhanced_ssh_event calls and fix Black formatting
- ssh_settings.py: Comment out all 4 instances of undefined log_enhanced_ssh_event - Lines 142-173: Policy update audit logging - Lines 235-255: Known host added audit logging - Lines 305-324: Known host removed audit logging - Lines 363-384: Connectivity test audit logging - compliance_rules_api.py: Add missing blank line before function (line 947) All instances now properly commented with FIXME notes and pass statements. Resolves Black formatter indentation errors and syntax errors.
1 parent 95d448f commit 06a937a

2 files changed

Lines changed: 92 additions & 83 deletions

File tree

backend/app/api/v1/endpoints/compliance_rules_api.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,7 @@ async def get_platform_statistics_from_files() -> Dict[str, Any]:
944944
"source": "mongodb_empty",
945945
}
946946

947+
947948
async def get_framework_statistics_from_files() -> Dict[str, Any]:
948949
"""
949950
DEPRECATED: Return empty framework statistics when MongoDB is empty.

backend/app/routes/ssh_settings.py

Lines changed: 91 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -140,35 +140,37 @@ async def set_ssh_policy(
140140
)
141141

142142
# Enhanced audit logging with dual system support
143-
logger.info(f"SSH policy update: About to call enhanced audit logging")
144-
logger.info(f"Current user: {current_user}")
145-
logger.info(f"Policy request: {policy_request.policy}")
146-
try:
147-
# await log_enhanced_ssh_event(
148-
db=db,
149-
action="POLICY_UPDATED",
150-
policy_data={
151-
"policy": policy_request.policy,
152-
"trusted_networks": policy_request.trusted_networks or [],
153-
"trusted_networks_count": len(policy_request.trusted_networks or []),
154-
"change_reason": "Administrator policy update",
155-
},
156-
user_id=current_user.get("id"),
157-
username=current_user.get("username"),
158-
ip_address="172.20.0.1",
159-
new_values={
160-
"policy": policy_request.policy,
161-
"trusted_networks": policy_request.trusted_networks,
162-
},
163-
)
164-
logger.info(f"Enhanced audit logging completed successfully")
165-
except Exception as audit_error:
166-
logger.warning(f"Enhanced audit logging failed for SSH policy update: {audit_error}")
167-
logger.warning(f"Error details: {type(audit_error)} - {str(audit_error)}")
168-
import traceback
169-
170-
logger.warning(f"Traceback: {traceback.format_exc()}")
171-
# Continue with operation - don't fail SSH updates due to audit issues
143+
# FIXME: Disabled - log_enhanced_ssh_event function not yet implemented
144+
# logger.info(f"SSH policy update: About to call enhanced audit logging")
145+
# logger.info(f"Current user: {current_user}")
146+
# logger.info(f"Policy request: {policy_request.policy}")
147+
# try:
148+
# await log_enhanced_ssh_event(
149+
# db=db,
150+
# action="POLICY_UPDATED",
151+
# policy_data={
152+
# "policy": policy_request.policy,
153+
# "trusted_networks": policy_request.trusted_networks or [],
154+
# "trusted_networks_count": len(policy_request.trusted_networks or []),
155+
# "change_reason": "Administrator policy update",
156+
# },
157+
# user_id=current_user.get("id"),
158+
# username=current_user.get("username"),
159+
# ip_address="172.20.0.1",
160+
# new_values={
161+
# "policy": policy_request.policy,
162+
# "trusted_networks": policy_request.trusted_networks,
163+
# },
164+
# )
165+
# logger.info(f"Enhanced audit logging completed successfully")
166+
# except Exception as audit_error:
167+
# logger.warning(f"Enhanced audit logging failed for SSH policy update: {audit_error}")
168+
# logger.warning(f"Error details: {type(audit_error)} - {str(audit_error)}")
169+
# import traceback
170+
#
171+
# logger.warning(f"Traceback: {traceback.format_exc()}")
172+
# # Continue with operation - don't fail SSH updates due to audit issues
173+
pass
172174

173175
# Return updated configuration
174176
return await get_ssh_policy(db=db, current_user=current_user)
@@ -231,24 +233,26 @@ async def add_known_host(
231233
)
232234

233235
# Enhanced audit logging
234-
try:
235-
# await log_enhanced_ssh_event(
236-
db=db,
237-
action="KNOWN_HOST_ADDED",
238-
policy_data={
239-
"hostname": host_request.hostname,
240-
"ip_address": host_request.ip_address,
241-
"key_type": host_request.key_type,
242-
"action": "add_known_host",
243-
},
244-
user_id=current_user.get("id"),
245-
username=current_user.get("username"),
246-
ip_address="172.20.0.1",
247-
)
248-
except Exception as audit_error:
249-
logger.warning(
250-
f"Enhanced audit logging failed for SSH known host addition: {audit_error}"
251-
)
236+
# FIXME: Disabled - log_enhanced_ssh_event function not yet implemented
237+
# try:
238+
# await log_enhanced_ssh_event(
239+
# db=db,
240+
# action="KNOWN_HOST_ADDED",
241+
# policy_data={
242+
# "hostname": host_request.hostname,
243+
# "ip_address": host_request.ip_address,
244+
# "key_type": host_request.key_type,
245+
# "action": "add_known_host",
246+
# },
247+
# user_id=current_user.get("id"),
248+
# username=current_user.get("username"),
249+
# ip_address="172.20.0.1",
250+
# )
251+
# except Exception as audit_error:
252+
# logger.warning(
253+
# f"Enhanced audit logging failed for SSH known host addition: {audit_error}"
254+
# )
255+
pass
252256

253257
# Return the added host
254258
hosts = service.get_known_hosts(host_request.hostname)
@@ -299,23 +303,25 @@ async def remove_known_host(
299303
)
300304

301305
# Enhanced audit logging
302-
try:
303-
# await log_enhanced_ssh_event(
304-
db=db,
305-
action="KNOWN_HOST_REMOVED",
306-
policy_data={
307-
"hostname": hostname,
308-
"key_type": key_type or "all_key_types",
309-
"action": "remove_known_host",
310-
},
311-
user_id=current_user.get("id"),
312-
username=current_user.get("username"),
313-
ip_address="172.20.0.1",
314-
)
315-
except Exception as audit_error:
316-
logger.warning(
317-
f"Enhanced audit logging failed for SSH known host removal: {audit_error}"
318-
)
306+
# FIXME: Disabled - log_enhanced_ssh_event function not yet implemented
307+
# try:
308+
# await log_enhanced_ssh_event(
309+
# db=db,
310+
# action="KNOWN_HOST_REMOVED",
311+
# policy_data={
312+
# "hostname": hostname,
313+
# "key_type": key_type or "all_key_types",
314+
# "action": "remove_known_host",
315+
# },
316+
# user_id=current_user.get("id"),
317+
# username=current_user.get("username"),
318+
# ip_address="172.20.0.1",
319+
# )
320+
# except Exception as audit_error:
321+
# logger.warning(
322+
# f"Enhanced audit logging failed for SSH known host removal: {audit_error}"
323+
# )
324+
pass
319325

320326
return {"message": f"Known host {hostname} removed successfully"}
321327

@@ -355,25 +361,27 @@ async def test_ssh_connectivity(
355361
)
356362

357363
# Enhanced audit logging
358-
try:
359-
# await log_enhanced_ssh_event(
360-
db=db,
361-
action="CONNECTIVITY_TEST",
362-
policy_data={
363-
"host_id": host_id,
364-
"target_ip": host.ip_address,
365-
"test_result": "SUCCESS" if is_connected else "FAILED",
366-
"error_message": error_msg,
367-
"current_policy": "default_policy",
368-
},
369-
user_id=current_user.get("id"),
370-
username=current_user.get("username"),
371-
ip_address="172.20.0.1",
372-
)
373-
except Exception as audit_error:
374-
logger.warning(
375-
f"Enhanced audit logging failed for SSH connectivity test: {audit_error}"
376-
)
364+
# FIXME: Disabled - log_enhanced_ssh_event function not yet implemented
365+
# try:
366+
# await log_enhanced_ssh_event(
367+
# db=db,
368+
# action="CONNECTIVITY_TEST",
369+
# policy_data={
370+
# "host_id": host_id,
371+
# "target_ip": host.ip_address,
372+
# "test_result": "SUCCESS" if is_connected else "FAILED",
373+
# "error_message": error_msg,
374+
# "current_policy": "default_policy",
375+
# },
376+
# user_id=current_user.get("id"),
377+
# username=current_user.get("username"),
378+
# ip_address="172.20.0.1",
379+
# )
380+
# except Exception as audit_error:
381+
# logger.warning(
382+
# f"Enhanced audit logging failed for SSH connectivity test: {audit_error}"
383+
# )
384+
pass
377385

378386
return {
379387
"host_id": host_id,

0 commit comments

Comments
 (0)