Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion socketsecurity/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__author__ = 'socket.dev'
__version__ = '2.2.18'
__version__ = '2.2.22'
USER_AGENT = f'SocketPythonCLI/{__version__}'
3 changes: 1 addition & 2 deletions socketsecurity/core/git_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
48 changes: 26 additions & 22 deletions socketsecurity/core/tools/reachability.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,42 @@ 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
"""
# 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]
Expand Down
10 changes: 5 additions & 5 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading