diff --git a/Dockerfile b/Dockerfile index 65ffbe8..90c5bae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +1,72 @@ FROM python:3-alpine LABEL org.opencontainers.image.authors="socket.dev" + +# Language version arguments with defaults +ARG GO_VERSION=system +ARG JAVA_VERSION=17 +ARG DOTNET_VERSION=8 + +# CLI and SDK arguments ARG CLI_VERSION ARG SDK_VERSION ARG PIP_INDEX_URL=https://pypi.org/simple ARG PIP_EXTRA_INDEX_URL=https://pypi.org/simple ARG USE_LOCAL_INSTALL=false -RUN apk update \ - && apk add --no-cache git nodejs npm yarn curl \ - && npm install @coana-tech/cli -g +# Install base packages first +RUN apk update && apk add --no-cache \ + git nodejs npm yarn curl wget \ + ruby ruby-dev build-base + +# Install Go with version control +RUN if [ "$GO_VERSION" = "system" ]; then \ + apk add --no-cache go; \ + else \ + cd /tmp && \ + ARCH=$(uname -m) && \ + case $ARCH in \ + x86_64) GOARCH=amd64 ;; \ + aarch64) GOARCH=arm64 ;; \ + *) echo "Unsupported architecture: $ARCH" && exit 1 ;; \ + esac && \ + wget https://golang.org/dl/go${GO_VERSION}.linux-${GOARCH}.tar.gz && \ + tar -C /usr/local -xzf go${GO_VERSION}.linux-${GOARCH}.tar.gz && \ + rm go${GO_VERSION}.linux-${GOARCH}.tar.gz; \ + fi + +# Install Java with version control +RUN if [ "$JAVA_VERSION" = "8" ]; then \ + apk add --no-cache openjdk8-jdk; \ + elif [ "$JAVA_VERSION" = "11" ]; then \ + apk add --no-cache openjdk11-jdk; \ + elif [ "$JAVA_VERSION" = "17" ]; then \ + apk add --no-cache openjdk17-jdk; \ + elif [ "$JAVA_VERSION" = "21" ]; then \ + apk add --no-cache openjdk21-jdk; \ + else \ + echo "Unsupported Java version: $JAVA_VERSION. Supported: 8, 11, 17, 21" && exit 1; \ + fi + +# Install .NET with version control +RUN if [ "$DOTNET_VERSION" = "6" ]; then \ + apk add --no-cache dotnet6-sdk; \ + elif [ "$DOTNET_VERSION" = "8" ]; then \ + apk add --no-cache dotnet8-sdk; \ + else \ + echo "Unsupported .NET version: $DOTNET_VERSION. Supported: 6, 8" && exit 1; \ + fi + +# Install additional tools +RUN npm install @coana-tech/cli -g && \ + gem install bundler && \ + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y && \ + . ~/.cargo/env && \ + rustup component add rustfmt clippy + +# Set environment paths +ENV PATH="/usr/local/go/bin:/root/.cargo/bin:${PATH}" +ENV GOROOT="/usr/local/go" +ENV GOPATH="/go" # Install uv COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv @@ -38,4 +96,7 @@ RUN if [ "$USE_LOCAL_INSTALL" = "true" ]; then \ pip install --upgrade socketdev; \ fi -# ENTRYPOINT ["socketcli"] \ No newline at end of file +# Create workspace directory with proper permissions +RUN mkdir -p /go/src && chmod -R 777 /go + +ENTRYPOINT ["socketcli"] \ No newline at end of file diff --git a/README.md b/README.md index 29444ab..1bab6d4 100644 --- a/README.md +++ b/README.md @@ -171,6 +171,8 @@ If you don't want to provide the Socket API Token every time then you can use th | --reach-version | False | latest | Version of @coana-tech/cli to use for analysis | | --reach-analysis-timeout | False | 1200 | Timeout in seconds for the reachability analysis (default: 1200 seconds / 20 minutes) | | --reach-analysis-memory-limit | False | 4096 | Memory limit in MB for the reachability analysis (default: 4096 MB / 4 GB) | +| --reach-concurrency | False | | Control parallel analysis execution (must be >= 1) | +| --reach-additional-params | False | | Pass custom parameters to the coana CLI tool | | --reach-ecosystems | False | | Comma-separated list of ecosystems to analyze (e.g., "npm,pypi"). If not specified, all supported ecosystems are analyzed | | --reach-exclude-paths | False | | Comma-separated list of file paths or patterns to exclude from reachability analysis | | --reach-min-severity | False | | Minimum severity level for reporting reachability results (low, medium, high, critical) | diff --git a/pyproject.toml b/pyproject.toml index ec50d9a..5c9f5c3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "socketsecurity" -version = "2.2.27" +version = "2.2.32" requires-python = ">= 3.10" license = {"file" = "LICENSE"} dependencies = [ @@ -16,7 +16,7 @@ dependencies = [ 'GitPython', 'packaging', 'python-dotenv', - 'socketdev>=3.0.17,<4.0.0', + 'socketdev>=3.0.19,<4.0.0', "bs4>=0.0.2", ] readme = "README.md" diff --git a/scripts/build_container_flexible.sh b/scripts/build_container_flexible.sh new file mode 100644 index 0000000..4ecbc7a --- /dev/null +++ b/scripts/build_container_flexible.sh @@ -0,0 +1,161 @@ +#!/bin/sh +VERSION=$(grep -o "__version__.*" socketsecurity/__init__.py | awk '{print $3}' | tr -d "'") +ENABLE_PYPI_BUILD=$1 +STABLE_VERSION=$2 +GO_VERSION=${GO_VERSION:-"1.21"} +JAVA_VERSION=${JAVA_VERSION:-"17"} +DOTNET_VERSION=${DOTNET_VERSION:-"8"} + +verify_package() { + local version=$1 + local pip_index=$2 + echo "Verifying package availability..." + + for i in $(seq 1 30); do + if pip install --index-url $pip_index socketsecurity==$version; then + echo "Package $version is now available and installable" + pip uninstall -y socketsecurity + return 0 + fi + echo "Attempt $i: Package not yet installable, waiting 20s... ($i/30)" + sleep 20 + done + + echo "Package verification failed after 30 attempts" + return 1 +} + +# Function to build Docker image with language versions +build_docker_image() { + local cli_version=$1 + local tag=$2 + local pip_index=${3:-"https://pypi.org/simple"} + local pip_extra_index=${4:-"https://pypi.org/simple"} + local use_local=${5:-"false"} + local dockerfile=${6:-"Dockerfile"} + + echo "Building with Go $GO_VERSION, Java $JAVA_VERSION, .NET $DOTNET_VERSION" + + local build_args="--build-arg CLI_VERSION=$cli_version" + build_args="$build_args --build-arg GO_VERSION=$GO_VERSION" + build_args="$build_args --build-arg JAVA_VERSION=$JAVA_VERSION" + build_args="$build_args --build-arg DOTNET_VERSION=$DOTNET_VERSION" + build_args="$build_args --build-arg PIP_INDEX_URL=$pip_index" + build_args="$build_args --build-arg PIP_EXTRA_INDEX_URL=$pip_extra_index" + build_args="$build_args --build-arg USE_LOCAL_INSTALL=$use_local" + + docker build --no-cache $build_args --platform linux/amd64,linux/arm64 -t $tag -f $dockerfile . +} + +echo "Socket CLI version: $VERSION" +echo "Language versions: Go $GO_VERSION, Java $JAVA_VERSION, .NET $DOTNET_VERSION" + +if [ -z $ENABLE_PYPI_BUILD ] || [ -z $STABLE_VERSION ]; then + echo "$0 pypi-build=