Commit 21e904e0 authored by Andres Anaya Amariels's avatar Andres Anaya Amariels 🚀
Browse files

fix: enhance Go and trufflehog installation in staging pipeline

parent b1582932
Loading
Loading
Loading
Loading
+33 −6
Original line number Diff line number Diff line
@@ -33,18 +33,45 @@ staging_secrets_in_repo:
  stage: staging_secrets_in_repo
  script:
    - |
      # Install Go locally if not installed
      if ! command -v go >/dev/null 2>&1; then
        echo "Installing Go locally..."
        GO_VERSION=1.22.6   # stable version
        INSTALL_DIR=$HOME/go-local

        mkdir -p $INSTALL_DIR
        curl -LO https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz
        tar -C $INSTALL_DIR -xzf go${GO_VERSION}.linux-amd64.tar.gz
        rm go${GO_VERSION}.linux-amd64.tar.gz

        # Add Go to PATH
        export PATH=$INSTALL_DIR/go/bin:$PATH
        echo "export PATH=$INSTALL_DIR/go/bin:\$PATH" >> ~/.bashrc

        echo "Go installed: $(go version)"
      else
        echo "Go already installed: $(go version)"
      fi

      if ! command -v trufflehog >/dev/null 2>&1; then
        echo "Installing trufflehog from source..."
        git clone https://github.com/trufflesecurity/trufflehog.git
        cd trufflehog
        go install

        cd .. && rm -rf trufflehog
        
        # Ensure Go bin path is available
        export PATH=$(go env GOPATH)/bin:$PATH
        echo 'export PATH=$(go env GOPATH)/bin:$PATH' >> ~/.bashrc
        
        echo "trufflehog installed successfully: $(trufflehog --version)"
      else
        echo "trufflehog already installed: $(trufflehog --version)"
      fi

      # cd ../
      trufflehog . --exclude_paths cicd/exclusions --max_depth=5
      trufflehog filesystem $CI_PROJECT_DIR --exclude_paths "$CI_PROJECT_DIR/cicd/exclusions" --fail

  <<: *staging_common

# define the process to do linting code: ruff
@@ -110,10 +137,10 @@ staging_local_install:
    - staging_semgrep_sast
  stage: staging_local_install
  script:
   - echo "# 1. Hacer un Dockerfile que haga una construya una image con la versión de código del sdk de esta rama usando este procedimiento:"
   - echo "# https://labs.etsi.org/rep/ocf/sdk/-/blob/main/doc/sdk_developers.md"
   - echo "# 2. Si se construye bien, que se hagan los tests unitarios"
   - echo "# 3. job finalizado"
    - |
      echo "------- Executing SDK Tests -------"
      bash ci_cd_test/test_sdk.sh
      
  <<: *staging_common