Skip to content

Commit b2677a0

Browse files
author
Diego Nadares
committed
Merge branch 'white/staging' into white/master
2 parents 1485b10 + 9d30723 commit b2677a0

4 files changed

Lines changed: 25 additions & 11 deletions

File tree

RELEASE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
New features in the latest update
22
=====================================
33

4+
5.1.1 [Feb 9th, 2024]:
5+
---
6+
* [FIX] Improve of host view performance.
7+
48
5.1.0 [Feb 8th, 2024]:
59
---
610
* [ADD] Performance improved in `assets` views making several vulnerabilities stats statics in asset's model. #7634

faraday/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
See the file 'doc/LICENSE' for the license information
55
"""
66

7-
__version__ = '5.1.0'
7+
__version__ = '5.1.1'
88
__license_version__ = __version__

faraday/manage.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,11 @@ def move_references(all_workspaces, workspace_name):
306306

307307

308308
@click.command(help="Synchronize vulnerability severity stats in asset")
309-
def sync_hosts_stats():
309+
@click.option('-a', '--async-mode', type=bool, help="Update stats asynchronously", default=False)
310+
def sync_hosts_stats(async_mode):
310311
app = create_app()
311312
with app.app_context():
312-
_sync_hosts_stats()
313+
_sync_hosts_stats(async_mode)
313314

314315

315316
cli.add_command(show_urls)
Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
from faraday.server.models import db, Host
22
from faraday.server.config import faraday_server
3+
from faraday.server.tasks import calc_vulnerability_stats
4+
from tqdm import tqdm
5+
from colorama import Fore
36

47

5-
def _sync_hosts_stats():
6-
print("Syncing hosts stats ...")
8+
def _sync_hosts_stats(async_mode=False):
9+
print(f"[{Fore.GREEN}*{Fore.RESET}] Syncing hosts stats ...")
710
hosts_id = db.session.query(Host.id).all()
811
if hosts_id:
9-
print(f"Found {len(hosts_id)} hosts ...")
10-
print("This may take a while ...")
12+
print(f"[{Fore.GREEN}*{Fore.RESET}] Found {len(hosts_id)} hosts ...")
13+
print(f"[{Fore.YELLOW}!{Fore.RESET}] This may take a while ...")
1114
from faraday.server.tasks import update_host_stats # pylint: disable=import-outside-toplevel
1215
_hosts_id = [host_id[0] for host_id in hosts_id]
13-
if faraday_server.celery_enabled:
14-
print("Processing updates in background ...")
15-
update_host_stats.delay(_hosts_id, [])
16+
if async_mode:
17+
print(f"[{Fore.GREEN}*{Fore.RESET}] Updating asynchronously")
18+
if faraday_server.celery_enabled:
19+
print(f"[{Fore.GREEN}*{Fore.RESET}] Processing updates in background ...")
20+
update_host_stats.delay(_hosts_id, [])
21+
else:
22+
update_host_stats(_hosts_id, [])
1623
else:
17-
update_host_stats(_hosts_id, [])
24+
print(F"[{Fore.GREEN}*{Fore.RESET}] Updating synchronously")
25+
for host_id in tqdm(_hosts_id, colour="blue"):
26+
calc_vulnerability_stats(host_id)

0 commit comments

Comments
 (0)