larxius commited on
Commit
cadcc58
·
verified ·
1 Parent(s): 7bf7a57

Update backend_structured/routes.py

Browse files
Files changed (1) hide show
  1. backend_structured/routes.py +13 -5
backend_structured/routes.py CHANGED
@@ -1779,13 +1779,17 @@ def fetch_scan_logs(current_user, scan_id):
1779
  def get_scans_history(current_user):
1780
  try:
1781
 
1782
- limit_val = request.args.get('limit', 50, type=int)
1783
  org_id_param = request.args.get('org_id')
 
 
1784
  if org_id_param and current_user.role in ['super_admin', 'admin', 'support_engineer']:
1785
  scans_query = Scan.query.filter_by(org_id=org_id_param)
1786
- elif current_user.org_id:
 
 
1787
  scans_query = Scan.query.filter_by(org_id=current_user.org_id)
1788
- elif current_user.role in ['super_admin', 'support_engineer'] or request.args.get('global') == 'true':
1789
  scans_query = Scan.query
1790
  else:
1791
  scans_query = Scan.query.filter_by(user_id=current_user.id)
@@ -2119,11 +2123,15 @@ vuln_bp = Blueprint('vulnerabilities', __name__)
2119
  def get_vulnerabilities_summary(current_user):
2120
  try:
2121
  org_id_param = request.args.get('org_id')
 
 
2122
  if org_id_param and current_user.role in ['super_admin', 'admin', 'support_engineer']:
2123
  scan_filter = (Scan.org_id == org_id_param,)
2124
- elif current_user.org_id:
 
 
2125
  scan_filter = (Scan.org_id == current_user.org_id,)
2126
- elif current_user.role in ['super_admin', 'support_engineer'] or request.args.get('global') == 'true':
2127
  scan_filter = (Scan.id.isnot(None),)
2128
  else:
2129
  scan_filter = (Scan.user_id == current_user.id,)
 
1779
  def get_scans_history(current_user):
1780
  try:
1781
 
1782
+ limit_val = request.args.get('limit', 500, type=int)
1783
  org_id_param = request.args.get('org_id')
1784
+ is_global = request.args.get('global') == 'true'
1785
+
1786
  if org_id_param and current_user.role in ['super_admin', 'admin', 'support_engineer']:
1787
  scans_query = Scan.query.filter_by(org_id=org_id_param)
1788
+ elif is_global and current_user.role in ['super_admin', 'admin', 'support_engineer']:
1789
+ scans_query = Scan.query
1790
+ elif current_user.org_id and current_user.role not in ['super_admin', 'support_engineer']:
1791
  scans_query = Scan.query.filter_by(org_id=current_user.org_id)
1792
+ elif current_user.role in ['super_admin', 'support_engineer']:
1793
  scans_query = Scan.query
1794
  else:
1795
  scans_query = Scan.query.filter_by(user_id=current_user.id)
 
2123
  def get_vulnerabilities_summary(current_user):
2124
  try:
2125
  org_id_param = request.args.get('org_id')
2126
+ is_global = request.args.get('global') == 'true'
2127
+
2128
  if org_id_param and current_user.role in ['super_admin', 'admin', 'support_engineer']:
2129
  scan_filter = (Scan.org_id == org_id_param,)
2130
+ elif is_global and current_user.role in ['super_admin', 'admin', 'support_engineer']:
2131
+ scan_filter = (Scan.id.isnot(None),)
2132
+ elif current_user.org_id and current_user.role not in ['super_admin', 'support_engineer']:
2133
  scan_filter = (Scan.org_id == current_user.org_id,)
2134
+ elif current_user.role in ['super_admin', 'support_engineer']:
2135
  scan_filter = (Scan.id.isnot(None),)
2136
  else:
2137
  scan_filter = (Scan.user_id == current_user.id,)