From cdf063a35d4b0843b8f763d987fb03af59213fd5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 16 Aug 2024 12:44:28 -0400 Subject: [PATCH] fix(version): update version flag logic (#4771) Co-authored-by: Sergio Garcia <38561120+sergargar@users.noreply.github.com> --- prowler/config/config.py | 3 ++- tests/config/config_test.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/prowler/config/config.py b/prowler/config/config.py index 3597dbc875..b40e293ab0 100644 --- a/prowler/config/config.py +++ b/prowler/config/config.py @@ -5,6 +5,7 @@ from os import getcwd import requests import yaml +from packaging import version from prowler.lib.logger import logger @@ -86,7 +87,7 @@ def check_current_version(): "https://api.github.com/repos/prowler-cloud/prowler/tags", timeout=1 ) latest_version = release_response.json()[0]["name"] - if latest_version != prowler_version: + if version.parse(latest_version) > version.parse(prowler_version): return f"{prowler_version_string} (latest is {latest_version}, upgrade for the latest features)" else: return ( diff --git a/tests/config/config_test.py b/tests/config/config_test.py index 23e05d1e83..daab109694 100644 --- a/tests/config/config_test.py +++ b/tests/config/config_test.py @@ -15,6 +15,7 @@ from prowler.providers.aws.aws_provider import get_aws_available_regions MOCK_PROWLER_VERSION = "3.3.0" MOCK_OLD_PROWLER_VERSION = "0.0.0" +MOCK_PROWLER_MASTER_VERSION = "3.4.0" def mock_prowler_get_latest_release(_, **kwargs): @@ -326,6 +327,18 @@ class Test_Config: == f"Prowler {MOCK_OLD_PROWLER_VERSION} (latest is {MOCK_PROWLER_VERSION}, upgrade for the latest features)" ) + @mock.patch( + "prowler.config.config.requests.get", new=mock_prowler_get_latest_release + ) + @mock.patch( + "prowler.config.config.prowler_version", new=MOCK_PROWLER_MASTER_VERSION + ) + def test_check_current_version_with_master_version(self): + assert ( + check_current_version() + == f"Prowler {MOCK_PROWLER_MASTER_VERSION} (You are running the latest version, yay!)" + ) + def test_get_available_compliance_frameworks(self): compliance_frameworks = [ "cisa_aws",