Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update backend_structured/routes.py
Browse files- backend_structured/routes.py +15 -7
backend_structured/routes.py
CHANGED
|
@@ -111,6 +111,16 @@ MAX_LOGIN_ATTEMPTS = 5
|
|
| 111 |
LOCKOUT_MINUTES = 15
|
| 112 |
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
def token_required(f):
|
| 115 |
@wraps(f)
|
| 116 |
def decorated(*args, **kwargs):
|
|
@@ -1101,7 +1111,7 @@ def get_global_stats(current_user):
|
|
| 1101 |
'user_email': user_email,
|
| 1102 |
'target_id': a.target_id,
|
| 1103 |
'target_name': target_name,
|
| 1104 |
-
'timestamp': a.created_at
|
| 1105 |
})
|
| 1106 |
|
| 1107 |
# Get all users for Members tab
|
|
@@ -1186,7 +1196,7 @@ def get_all_audit_logs(current_user):
|
|
| 1186 |
'user_email': user_email,
|
| 1187 |
'target_id': a.target_id,
|
| 1188 |
'target_name': target_name,
|
| 1189 |
-
'timestamp': a.created_at
|
| 1190 |
}
|
| 1191 |
|
| 1192 |
if search_query:
|
|
@@ -1547,7 +1557,7 @@ def create_scan(current_user):
|
|
| 1547 |
"target_url": new_scan.target_url,
|
| 1548 |
"scan_type": new_scan.scan_type,
|
| 1549 |
"status": new_scan.status,
|
| 1550 |
-
"started_at": new_scan.started_at
|
| 1551 |
},
|
| 1552 |
}
|
| 1553 |
),
|
|
@@ -1632,10 +1642,8 @@ def get_scans_history(current_user):
|
|
| 1632 |
"org_id": s.org_id,
|
| 1633 |
"org_name": org_map.get(s.org_id, "Unknown"),
|
| 1634 |
"security_score": effective_score,
|
| 1635 |
-
"started_at": s.started_at
|
| 1636 |
-
"completed_at": (
|
| 1637 |
-
s.completed_at.isoformat() + "Z"
|
| 1638 |
-
) if s.completed_at else None,
|
| 1639 |
"vulnerabilities_count": {
|
| 1640 |
"critical": counts["critical"],
|
| 1641 |
"high": counts["high"],
|
|
|
|
| 111 |
LOCKOUT_MINUTES = 15
|
| 112 |
|
| 113 |
|
| 114 |
+
def format_iso_timestamp(dt):
|
| 115 |
+
if not dt:
|
| 116 |
+
return None
|
| 117 |
+
if isinstance(dt, str):
|
| 118 |
+
return dt
|
| 119 |
+
if dt.tzinfo is not None:
|
| 120 |
+
return dt.isoformat()
|
| 121 |
+
return dt.isoformat() + 'Z'
|
| 122 |
+
|
| 123 |
+
|
| 124 |
def token_required(f):
|
| 125 |
@wraps(f)
|
| 126 |
def decorated(*args, **kwargs):
|
|
|
|
| 1111 |
'user_email': user_email,
|
| 1112 |
'target_id': a.target_id,
|
| 1113 |
'target_name': target_name,
|
| 1114 |
+
'timestamp': format_iso_timestamp(a.created_at)
|
| 1115 |
})
|
| 1116 |
|
| 1117 |
# Get all users for Members tab
|
|
|
|
| 1196 |
'user_email': user_email,
|
| 1197 |
'target_id': a.target_id,
|
| 1198 |
'target_name': target_name,
|
| 1199 |
+
'timestamp': format_iso_timestamp(a.created_at)
|
| 1200 |
}
|
| 1201 |
|
| 1202 |
if search_query:
|
|
|
|
| 1557 |
"target_url": new_scan.target_url,
|
| 1558 |
"scan_type": new_scan.scan_type,
|
| 1559 |
"status": new_scan.status,
|
| 1560 |
+
"started_at": format_iso_timestamp(new_scan.started_at),
|
| 1561 |
},
|
| 1562 |
}
|
| 1563 |
),
|
|
|
|
| 1642 |
"org_id": s.org_id,
|
| 1643 |
"org_name": org_map.get(s.org_id, "Unknown"),
|
| 1644 |
"security_score": effective_score,
|
| 1645 |
+
"started_at": format_iso_timestamp(s.started_at),
|
| 1646 |
+
"completed_at": format_iso_timestamp(s.completed_at),
|
|
|
|
|
|
|
| 1647 |
"vulnerabilities_count": {
|
| 1648 |
"critical": counts["critical"],
|
| 1649 |
"high": counts["high"],
|