Skip to content

Commit

Permalink
Merge branch 'white/staging' into white/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Nadares committed Feb 9, 2024
2 parents 1485b10 + 9d30723 commit b2677a0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
4 changes: 4 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
New features in the latest update
=====================================

5.1.1 [Feb 9th, 2024]:
---
* [FIX] Improve of host view performance.

5.1.0 [Feb 8th, 2024]:
---
* [ADD] Performance improved in `assets` views making several vulnerabilities stats statics in asset's model. #7634
Expand Down
2 changes: 1 addition & 1 deletion faraday/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
See the file 'doc/LICENSE' for the license information
"""

__version__ = '5.1.0'
__version__ = '5.1.1'
__license_version__ = __version__
5 changes: 3 additions & 2 deletions faraday/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,11 @@ def move_references(all_workspaces, workspace_name):


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


cli.add_command(show_urls)
Expand Down
25 changes: 17 additions & 8 deletions faraday/server/commands/sync_hosts_stats.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
from faraday.server.models import db, Host
from faraday.server.config import faraday_server
from faraday.server.tasks import calc_vulnerability_stats
from tqdm import tqdm
from colorama import Fore


def _sync_hosts_stats():
print("Syncing hosts stats ...")
def _sync_hosts_stats(async_mode=False):
print(f"[{Fore.GREEN}*{Fore.RESET}] Syncing hosts stats ...")
hosts_id = db.session.query(Host.id).all()
if hosts_id:
print(f"Found {len(hosts_id)} hosts ...")
print("This may take a while ...")
print(f"[{Fore.GREEN}*{Fore.RESET}] Found {len(hosts_id)} hosts ...")
print(f"[{Fore.YELLOW}!{Fore.RESET}] This may take a while ...")
from faraday.server.tasks import update_host_stats # pylint: disable=import-outside-toplevel
_hosts_id = [host_id[0] for host_id in hosts_id]
if faraday_server.celery_enabled:
print("Processing updates in background ...")
update_host_stats.delay(_hosts_id, [])
if async_mode:
print(f"[{Fore.GREEN}*{Fore.RESET}] Updating asynchronously")
if faraday_server.celery_enabled:
print(f"[{Fore.GREEN}*{Fore.RESET}] Processing updates in background ...")
update_host_stats.delay(_hosts_id, [])
else:
update_host_stats(_hosts_id, [])
else:
update_host_stats(_hosts_id, [])
print(F"[{Fore.GREEN}*{Fore.RESET}] Updating synchronously")
for host_id in tqdm(_hosts_id, colour="blue"):
calc_vulnerability_stats(host_id)

0 comments on commit b2677a0

Please sign in to comment.