diff --git a/Dockerfile b/Dockerfile index 040036d..92186f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,8 @@ ARG PIP_INDEX_URL=https://pypi.org/simple ARG PIP_EXTRA_INDEX_URL=https://pypi.org/simple RUN apk update \ - && apk add --no-cache git nodejs npm yarn + && apk add --no-cache git nodejs npm yarn \ + && npm install @coana-tech/cli -g # Install CLI with retries for TestPyPI propagation (10 attempts, 30s each = 5 minutes total) RUN for i in $(seq 1 10); do \ diff --git a/pyproject.toml b/pyproject.toml index f326d59..511f0ff 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "socketsecurity" -version = "2.2.18" +version = "2.2.22" requires-python = ">= 3.10" license = {"file" = "LICENSE"} dependencies = [ @@ -16,7 +16,7 @@ dependencies = [ 'GitPython', 'packaging', 'python-dotenv', - 'socketdev>=3.0.6,<4.0.0', + 'socketdev>=3.0.16,<4.0.0', "bs4>=0.0.2", ] readme = "README.md" diff --git a/socketsecurity/__init__.py b/socketsecurity/__init__.py index a61cd78..bec9daa 100644 --- a/socketsecurity/__init__.py +++ b/socketsecurity/__init__.py @@ -1,3 +1,3 @@ __author__ = 'socket.dev' -__version__ = '2.2.18' +__version__ = '2.2.22' USER_AGENT = f'SocketPythonCLI/{__version__}' diff --git a/socketsecurity/core/git_interface.py b/socketsecurity/core/git_interface.py index 84eec25..d750284 100644 --- a/socketsecurity/core/git_interface.py +++ b/socketsecurity/core/git_interface.py @@ -97,8 +97,7 @@ def __init__(self, path: str): else: # Try to get branch name from git properties try: - self.branch = self.head.reference - urllib.parse.unquote(str(self.branch)) + self.branch = urllib.parse.unquote(str(self.head.reference)) log.debug(f"Branch detected from git reference: {self.branch}") except Exception as error: log.debug(f"Failed to get branch from git reference: {error}") diff --git a/socketsecurity/core/tools/reachability.py b/socketsecurity/core/tools/reachability.py index 064b699..7d3048e 100644 --- a/socketsecurity/core/tools/reachability.py +++ b/socketsecurity/core/tools/reachability.py @@ -17,10 +17,10 @@ def __init__(self, sdk: socketdev, api_token: str): def _ensure_coana_cli_installed(self, version: Optional[str] = None) -> str: """ - Check if @coana-tech/cli is installed, and install it if not present. + Check if @coana-tech/cli is installed, and install/update it if needed. Args: - version: Specific version to install (e.g., '1.2.3') + version: Specific version to install (e.g., '1.2.3'). If None, updates to latest. Returns: str: The package specifier to use with npx @@ -28,27 +28,31 @@ def _ensure_coana_cli_installed(self, version: Optional[str] = None) -> str: # Determine the package specifier package_spec = f"@coana-tech/cli@{version}" if version else "@coana-tech/cli" - # Check if the package is already available - try: - check_cmd = ["npm", "list", "-g", "@coana-tech/cli", "--depth=0"] - result = subprocess.run( - check_cmd, - capture_output=True, - text=True, - timeout=10 - ) - - # If npm list succeeds and mentions the package, it's installed - if result.returncode == 0 and "@coana-tech/cli" in result.stdout: - log.debug(f"@coana-tech/cli is already installed globally") - return package_spec + # If a specific version is requested, check if it's already installed + if version: + try: + check_cmd = ["npm", "list", "-g", "@coana-tech/cli", "--depth=0"] + result = subprocess.run( + check_cmd, + capture_output=True, + text=True, + timeout=10 + ) - except Exception as e: - log.debug(f"Could not check for existing @coana-tech/cli installation: {e}") - - # Package not found or check failed - install it - log.info("Downloading reachability analysis plugin (@coana-tech/cli)...") - log.info("This may take a moment on first run...") + # If npm list succeeds and mentions the specific version, it's installed + if result.returncode == 0 and f"@coana-tech/cli@{version}" in result.stdout: + log.debug(f"@coana-tech/cli@{version} is already installed globally") + return package_spec + + except Exception as e: + log.debug(f"Could not check for existing @coana-tech/cli installation: {e}") + + # Install or update the package + if version: + log.info(f"Installing reachability analysis plugin (@coana-tech/cli@{version})...") + else: + log.info("Updating reachability analysis plugin (@coana-tech/cli) to latest version...") + log.info("This may take a moment...") try: install_cmd = ["npm", "install", "-g", package_spec] diff --git a/uv.lock b/uv.lock index ad16f82..0dac6d3 100644 --- a/uv.lock +++ b/uv.lock @@ -1052,20 +1052,20 @@ wheels = [ [[package]] name = "socketdev" -version = "3.0.14" +version = "3.0.16" source = { registry = "https://pypi.org/simple" } dependencies = [ { name = "requests" }, { name = "typing-extensions" }, ] -sdist = { url = "https://files.pythonhosted.org/packages/71/e8/362072e5a8b94aa550d91ec0d7ef9ee63120284ceaedc9c8e1889a32abcf/socketdev-3.0.14.tar.gz", hash = "sha256:bcd1c548ac93f91ecc504f8a42be0ad59e457baa9ab17d02fcd2ccd9f10ace5e", size = 131919, upload-time = "2025-10-17T01:53:04.019Z" } +sdist = { url = "https://files.pythonhosted.org/packages/02/0d/6da0e0c34b97eef3a926d55470fa4bda2fcbbc42cc9e26ac51a34c6f117d/socketdev-3.0.16.tar.gz", hash = "sha256:5145300945e4e8d2d7f71db9c55cb44cc1449874f9d6416cc1d6ec129c64d638", size = 132505, upload-time = "2025-11-07T03:24:16.231Z" } wheels = [ - { url = "https://files.pythonhosted.org/packages/80/ac/aa54c296ecfff89d32974396517eb67bec17737cb863ef1f41bfe1ef83f1/socketdev-3.0.14-py3-none-any.whl", hash = "sha256:189d3e717f774b402eee55d933ddc13e41b52fc9e6410ab4362d5198ff57c723", size = 57338, upload-time = "2025-10-17T01:53:02.356Z" }, + { url = "https://files.pythonhosted.org/packages/a3/91/8486b2a62ba71d62a8f4f2f9ad22c61fcaabb461c5f269bbe0734eae76f9/socketdev-3.0.16-py3-none-any.whl", hash = "sha256:f5e413f5f2f8c0c938d5654da7f0a157c0be02a25e14d94af62c252e9fb3b502", size = 58567, upload-time = "2025-11-07T03:24:14.965Z" }, ] [[package]] name = "socketsecurity" -version = "2.2.15" +version = "2.2.18" source = { editable = "." } dependencies = [ { name = "bs4" }, @@ -1111,7 +1111,7 @@ requires-dist = [ { name = "python-dotenv" }, { name = "requests" }, { name = "ruff", marker = "extra == 'dev'", specifier = ">=0.3.0" }, - { name = "socketdev", specifier = ">=3.0.6,<4.0.0" }, + { name = "socketdev", specifier = ">=3.0.16,<4.0.0" }, { name = "twine", marker = "extra == 'dev'" }, { name = "uv", marker = "extra == 'dev'", specifier = ">=0.1.0" }, ]