diff --git a/pkgs/development/python-modules/safety/default.nix b/pkgs/development/python-modules/safety/default.nix index 6c01e6d32e1e..7f74c2c828f8 100644 --- a/pkgs/development/python-modules/safety/default.nix +++ b/pkgs/development/python-modules/safety/default.nix @@ -3,9 +3,7 @@ buildPythonPackage, fetchFromGitHub, hatchling, - setuptools, click, - requests, packaging, dparse, ruamel-yaml, @@ -18,26 +16,26 @@ safety-schemas, typing-extensions, filelock, - psutil, httpx, tenacity, tomlkit, + truststore, git, pytestCheckHook, tomli, writableTmpDirAsHomeHook, }: -buildPythonPackage rec { +buildPythonPackage (finalAttrs: { pname = "safety"; - version = "3.7.0"; + version = "3.8.0"; pyproject = true; src = fetchFromGitHub { owner = "pyupio"; repo = "safety"; - tag = version; - hash = "sha256-BPLK/V7YQBCGopfRFAWdra8ve8Ww5KN1+oZKyoEPiFc="; + tag = finalAttrs.version; + hash = "sha256-/iLxcVku8ogVZyhQI0/U+m1RyECDYWxLix+S83HHrS4="; }; patches = [ @@ -47,16 +45,11 @@ buildPythonPackage rec { build-system = [ hatchling ]; pythonRelaxDeps = [ - "filelock" - "pydantic" - "psutil" "safety-schemas" ]; dependencies = [ - setuptools click - requests packaging dparse ruamel-yaml @@ -69,10 +62,10 @@ buildPythonPackage rec { safety-schemas typing-extensions filelock - psutil httpx tenacity tomlkit + truststore ]; nativeCheckInputs = [ @@ -82,28 +75,21 @@ buildPythonPackage rec { writableTmpDirAsHomeHook ]; - disabledTests = [ - # Disable tests depending on online services - "test_announcements_if_is_not_tty" - "test_check_live" - "test_debug_flag" - "test_get_packages_licenses_without_api_key" - "test_init_project" - "test_validate_with_basic_policy_file" + disabledTestPaths = [ + # Failed to initialize SafetyPlatformClient: [Errno -3] Temporary failure in name resolution + "tests/firewall/test_command.py" + "tests/test_cli.py" ]; - # ImportError: cannot import name 'get_command_for' from partially initialized module 'safety.cli_util' (most likely due to a circular import) - disabledTestPaths = [ "tests/alerts/test_utils.py" ]; - meta = { description = "Checks installed dependencies for known vulnerabilities"; mainProgram = "safety"; homepage = "https://github.com/pyupio/safety"; - changelog = "https://github.com/pyupio/safety/blob/${src.tag}/CHANGELOG.md"; + changelog = "https://github.com/pyupio/safety/blob/${finalAttrs.src.tag}/CHANGELOG.md"; license = lib.licenses.mit; maintainers = with lib.maintainers; [ thomasdesr dotlambda ]; }; -} +}) diff --git a/pkgs/development/python-modules/safety/disable-telemetry.patch b/pkgs/development/python-modules/safety/disable-telemetry.patch index 986962b20071..c42c4789f7cf 100644 --- a/pkgs/development/python-modules/safety/disable-telemetry.patch +++ b/pkgs/development/python-modules/safety/disable-telemetry.patch @@ -1,8 +1,8 @@ diff --git a/safety/cli.py b/safety/cli.py -index 4d1f0c5..db4d930 100644 +index 14ec46a..3297928 100644 --- a/safety/cli.py +++ b/safety/cli.py -@@ -228,7 +228,7 @@ def configure_logger(ctx, param, debug): +@@ -170,7 +170,7 @@ def configure_logger(ctx, param, debug): @proxy_options @click.option( "--disable-optional-telemetry", @@ -12,41 +12,81 @@ index 4d1f0c5..db4d930 100644 show_default=True, help=CLI_DISABLE_OPTIONAL_TELEMETRY_DATA_HELP, diff --git a/safety/safety.py b/safety/safety.py -index e41f5ae..7d29a50 100644 +index a86c167..ad7fc94 100644 --- a/safety/safety.py +++ b/safety/safety.py -@@ -143,7 +143,7 @@ def fetch_database_url( +@@ -228,7 +228,7 @@ def fetch_database_url( mirror: str, db_name: str, cached: int, - telemetry: bool = True, + telemetry: bool = False, ecosystem: Ecosystem = Ecosystem.PYTHON, - from_cache: bool = True + from_cache: bool = True, + is_open_mirror: bool = False, +@@ -368,7 +368,7 @@ def fetch_database( + full: bool = False, + db: Union[Optional[str], bool] = False, + cached: int = 0, +- telemetry: bool = True, ++ telemetry: bool = False, + ecosystem: Optional[Ecosystem] = None, + from_cache: bool = True, ) -> Dict[str, Any]: +@@ -696,7 +696,7 @@ def check( + proxy: Optional[Dict[str, Any]] = None, + include_ignored: bool = False, + is_env_scan: bool = True, +- telemetry: bool = True, ++ telemetry: bool = False, + params: Optional[Dict[str, Any]] = None, + project: Optional[str] = None, + ) -> tuple: +@@ -1686,7 +1686,7 @@ def get_licenses( + auth: "Auth", + db_mirror: Union[Optional[str], bool] = False, + cached: int = 0, +- telemetry: bool = True, ++ telemetry: bool = False, + ) -> Dict[str, Any]: + """ + Retrieves the licenses from the database. +@@ -1785,7 +1785,7 @@ def add_local_notifications( + + + def get_announcements( +- auth: "Auth", telemetry: bool = True, with_telemetry: Any = None ++ auth: "Auth", telemetry: bool = False, with_telemetry: Any = None + ) -> List[Dict[str, str]]: + """ + Retrieves announcements from the server. diff --git a/safety/scan/finder/handlers.py b/safety/scan/finder/handlers.py -index 80a3db6..61a10cc 100644 +index 5f8e734..1f55f73 100644 --- a/safety/scan/finder/handlers.py +++ b/safety/scan/finder/handlers.py -@@ -91,11 +91,11 @@ class PythonFileHandler(FileHandler): - - # Fetch both the full and partial Safety databases - fetch_database(session=session, full=False, db=db, cached=True, -- telemetry=True, ecosystem=Ecosystem.PYTHON, -+ telemetry=False, ecosystem=Ecosystem.PYTHON, - from_cache=False) - - fetch_database(session=session, full=True, db=db, cached=True, -- telemetry=True, ecosystem=Ecosystem.PYTHON, -+ telemetry=False, ecosystem=Ecosystem.PYTHON, - from_cache=False) - - +@@ -102,7 +102,7 @@ class PythonFileHandler(FileHandler): + full=False, + db=db, + cached=True, +- telemetry=True, ++ telemetry=False, + ecosystem=Ecosystem.PYTHON, + from_cache=False, + ) +@@ -112,7 +112,7 @@ class PythonFileHandler(FileHandler): + full=True, + db=db, + cached=True, +- telemetry=True, ++ telemetry=False, + ecosystem=Ecosystem.PYTHON, + from_cache=False, + ) diff --git a/safety/util.py b/safety/util.py -index 2a02236..5feef8d 100644 +index 89ad11d..ba9983d 100644 --- a/safety/util.py +++ b/safety/util.py -@@ -351,7 +351,7 @@ def filter_announcements( +@@ -319,7 +319,7 @@ def filter_announcements( def build_telemetry_data(