VM Test V2

Descripción general

Se puede realizar una prueba externamente autenticando una cuenta de StrikeOne Admin desde su aplicación CI/CD preferida.

Ejecución de test remoto

Para ejecutar una prueba, necesitará tener un token de autorización. Los usuarios pueden generar Tokens API desde el menú Integraciones en la configuración de StrikeOne.

Intrucciones de instalación

    docker pull strike1/execute-vm-test:latest

Intrucciones de uso

    docker run --rm -it strikeone/execute_vm_test python execute_test.py

Comandos

    -ut, --usertoken  User token de StrikeOne
    -tn, --testname Nombre de test
    -an, --assetname Nombre de activo
    -tt, --typetest Tipo de test (sast/dast)
    -t,  --tool Herramienta para ejecutar escaneo
    -d, --domain Dominio para escaneo y asignación de vulnerabilidades

Comandos opcionales para escaneo SAST

    -url, --urlproject Url de repositorio
    -pn, --projectname Nombre de repositorio
    -pb, --projectbranch Nombre de rama a analizar
    -qg, --qualitygate Retornar quality gate desde SonarQube ? (True)
    -surl, --sonarurl Url de la instancia de SonarQube
    -stoken, --sonartoken SonarQube User Token
    -se, --sonarexclusions Exclusiones de SonarQube

TIPs

  • Cuando el comando --typetest = sast, debes ingresar --urlproject --projectname --projectbranch
  • Cuando el comando --qualitygate = True, debes ingresar --sonarurl --sonartoken\
  • Si el Activo no existe, este se creará automáticamente
  • Si el Dominio no existe, este se creará automáticamente
  • Si desea excluir más de un archivo y/o directorio, debe separarlos con una coma. (Ejemplo: src/,tests/)

Herramientas disponibles

SAST

  • GitLeaks (gitleaks), escaneo de secretos
  • Horusec (horusec), escaneo sast
  • OWASP Dependency-Check (dep_check), escaneo dependencias/librerias
  • SonarQube (sonarqube), escaneo sast

DAST

  • Nuclei (nuclei)
  • OWASP ZAP (owasp_zap)
  • OpenVAS (openvas) note: OpenVAS puede tomar más de 1 hora en terminar el escaneo

Ejemplo escaneo SAST con GitHub Actions

    name: CI
    on:
      push:
        branches: [ "main" ]

    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4

          - name: Pull docker StrikeOne
            run: docker pull strike1/execute-vm-test:latest

          - name: Execute Sonar Test
            run: |
              export REPO_NAME=${GITHUB_REPOSITORY#*/}
              echo "$REPO_NAME"
              export SONAR_TEST=$(docker run --rm strike1/execute-vm-test:latest python execute_test.py -ut ${{secrets.SO_TOKEN}} -tn test_name -an "$REPO_NAME" -tt sast -t sonarqube -d https://google.com -url https://${{secrets.GH_TOKEN}}@github.com/user/repo.git -pn "$REPO_NAME" -pb main)
              echo "$SONAR_TEST"
              if echo "$SONAR_TEST" | grep -iq "Error"; then
                echo "[SH] Error al ejecutar test..."
                exit 1
              fi

Ejemplo escaneo DAST con GitHub Actions

    name: CI
    on:
      push:
        branches: [ "main" ]

    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
          - uses: actions/checkout@v4

          - name: Pull docker StrikeOne
            run: docker pull strike1/execute-vm-test:latest

          - name: Execute OWASP ZAP Test
            run: |
              export REPO_NAME=${GITHUB_REPOSITORY#*/}
              echo "$REPO_NAME"
              export OWASP_TEST=$(docker run --rm strike1/execute-vm-test:latest python execute_test.py -ut ${{secrets.SO_TOKEN}} -tn test_name -an "$REPO_NAME" -tt dast -t owasp_zap -d https://google.com)
              echo "$OWASP_TEST"
              if echo "$OWASP_TEST" | grep -iq "Error"; then
                echo "[SH] Error al ejecutar test..."
                exit 1
              fi

Ejemplo escaneo SAST con Azure Pipelines

# Nombre del pipeline
name: CI-$(Build.BuildId)

# Disparadores
trigger:
  branches:
    include:
      - main

# Especifica el agente
pool:
  vmImage: 'ubuntu-latest'

# Variables (puedes ajustar según sea necesario)
variables:
  REPO_NAME: $(Build.Repository.Name) # Obtiene el nombre del repositorio automáticamente

# Pasos
steps:
  # Pull de la imagen Docker
  - script: |
      echo "Pulling Docker image..."
      docker pull strike1/execute-vm-test:latest
    displayName: 'Pull Docker StrikeOne'

  # Ejecutar el test de Sonar dentro de Docker
  - script: |
      echo "Executing Sonar Test..."
      export SONAR_TEST=$(docker run --rm strike1/execute-vm-test:latest python execute_test.py -ut $(SO_TOKEN) -tn test_name -an "$(REPO_NAME)" -tt sast -t sonarqube -d https://google.com -url https://$(GH_TOKEN)@github.com/user/repo.git -pn "$(REPO_NAME)" -pb main)
      echo "$SONAR_TEST"
      if echo "$SONAR_TEST" | grep -iq "Error"; then
        echo "[SH] Error al ejecutar test..."
        exit 1
      fi
    displayName: 'Execute Sonar Test'

Ejemplo escaneo DAST con Azure Pipelines

# Nombre del pipeline
name: CI-$(Build.BuildId)

# Disparadores
trigger:
  branches:
    include:
      - main

# Especifica el agente
pool:
  vmImage: 'ubuntu-latest'

# Variables
variables:
  REPO_NAME: $(Build.Repository.Name) # Nombre del repositorio automáticamente extraído

# Pasos
steps:

  # Pull de la imagen Docker
  - script: |
      echo "Pulling Docker image..."
      docker pull strike1/execute-vm-test:latest
    displayName: 'Pull Docker StrikeOne'

  # Ejecutar el test OWASP ZAP dentro de Docker
  - script: |
      echo "Executing OWASP ZAP Test..."
      export OWASP_TEST=$(docker run --rm strike1/execute-vm-test:latest python execute_test.py -ut $(SO_TOKEN) -tn test_name -an "$(REPO_NAME)" -tt dast -t owasp_zap -d https://google.com)
      echo "$OWASP_TEST"
      if echo "$OWASP_TEST" | grep -iq "Error"; then
        echo "[SH] Error al ejecutar test..."
        exit 1
      fi
    displayName: 'Execute OWASP ZAP Test'
Last Updated: