Skip to main content

SAST + SBOM (CycloneDX/SPDX) + CVE Scanning (OSV/Safety/NVD) - Análisis de seguridad empresarial completo

Project description

SemBicho CLI

🔒 Static Application Security Testing + SBOM + CVE Tracking + Code Quality Analysis Tool

Herramienta completa de línea de comandos para análisis estático de seguridad, gestión de dependencias y calidad de código.

✨ Características

  • 🔐 Security Scanning: SAST para 12+ lenguajes
  • 📦 SBOM Generation: Software Bill of Materials (CycloneDX, SPDX, Syft JSON) - AUTOMÁTICO en cada scan
  • 🔍 CVE Scanning: Detección automática de vulnerabilidades conocidas con Grype
  • 📝 Code Linting: Análisis de estilo y formato (Python, JavaScript/TypeScript)
  • 🔢 Complexity Analysis: Métricas de complejidad ciclomática y cognitiva
  • 📊 Quality Reports: Reportes unificados con scoring y grading
  • 🔄 CI/CD Integration: GitHub Actions, GitLab CI, Jenkins
  • 🏢 Enterprise Backend: Integración automática con backend SemBicho
  • 📈 Multi-format Output: JSON, HTML, Console, Summary

�🚀 Instalación

Desde PyPI (Recomendado)

# Instalación básica (solo seguridad)
pip install sembicho-cli

# Con herramientas de calidad (recomendado)
pip install sembicho-cli[quality]

# Instalación completa
pip install sembicho-cli[all]

Desde el código fuente

cd sembicho-cli
pip install -e .[all]

Con Docker

docker build -t sembicho-cli .
docker run --rm -v $(pwd):/workspace sembicho-cli scan --path /workspace

🔧 Herramientas Adicionales

Para aprovechar todas las características:

SBOM + CVE Scanning (Requerido para generación automática)

# Instalar Syft (SBOM Generator)
curl -sSfL https://raw.githubusercontent.com/anchore/syft/main/install.sh | sh -s -- -b /usr/local/bin

# Instalar Grype (CVE Scanner)
curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /usr/local/bin

# Verificar instalación
syft version
grype version

Code Quality Tools

# Python
pip install radon flake8 black pylint

# JavaScript/TypeScript
npm install -g eslint prettier escomplex

📖 Uso

🔐 Security Scanning (con SBOM Automático)

NOTA: A partir de v2.0, SBOM + CVE scanning se genera AUTOMÁTICAMENTE en cada escaneo (inspirado en Conviso AppSec Platform).

# Escaneo completo: SAST + SBOM + CVE (AUTOMÁTICO)
sembicho scan --path . --token TU_TOKEN --api-url https://sembichobackend.onrender.com

# Con reporte JSON
sembicho scan --path ./mi-proyecto --output security.json --format json --token TU_TOKEN

# Con reporte HTML
sembicho scan --path ./mi-proyecto --output security.html --format html --token TU_TOKEN

# Modo CI/CD (SBOM incluido automáticamente)
sembicho scan --path . --ci-mode --fail-on critical,high --token TU_TOKEN

# Deshabilitar SBOM (NO recomendado)
sembicho scan --path . --skip-sbom --token TU_TOKEN

# Cambiar formato SBOM (default: CycloneDX)
sembicho scan --path . --sbom-format spdx-json --token TU_TOKEN

Qué hace automáticamente:

  1. ✅ Análisis SAST del código fuente
  2. ✅ Generación SBOM de dependencias
  3. ✅ Escaneo CVE con Grype
  4. ✅ Envío a backend (reportes + SBOM + CVEs)
  5. ✅ Visualización en dashboard

📝 Code Linting

# Linting de código Python
sembicho lint --path ./backend --language python

# Linting de código JavaScript
sembicho lint --path ./frontend/src --language javascript

# Con reporte JSON
sembicho lint --path ./src --output linting-report.json --format json

🔢 Complexity Analysis

# Análisis de complejidad
sembicho complexity --path ./src --language python

# Con umbral personalizado
sembicho complexity --path ./src --threshold 15

# Guardar reporte
sembicho complexity --path ./src --output complexity.json --format json

📊 Complete Quality Analysis

# Análisis completo de calidad (linting + complexity + more)
sembicho quality --path .

# Con grado mínimo para CI/CD
sembicho quality --path . --fail-on-grade B+

# Reporte completo JSON
sembicho quality --path . --output quality-report.json --format json

Integración con Backend

# Enviar resultados al backend
sembicho scan --path . --api-url http://localhost:8000/api/results --token abc123

# Con configuración
sembicho config --init
# Editar .sembicho.json con tu configuración
sembicho scan --path .

Filtros y opciones avanzadas

# Filtrar por severidad
sembicho scan --path . --severity high

# Modo verbose
sembicho scan --path . --verbose

# Herramientas específicas
sembicho scan --path . --tools bandit,semgrep

# Fallar en CI con vulnerabilidades críticas
sembicho scan --path . --ci-mode --fail-on critical

🛠️ Herramientas Integradas

  • Bandit: Análisis de seguridad para Python
  • ESLint: Análisis de JavaScript/TypeScript
  • Semgrep: Análisis multi-lenguaje con reglas OWASP

📊 Formatos de Salida

JSON

sembicho scan --path . --format json --output results.json

Estructura del JSON:

{
  "project_name": "mi-proyecto",
  "scan_date": "2024-01-15T10:30:00Z",
  "language": "python",
  "total_vulnerabilities": 5,
  "severity_counts": {
    "critical": 1,
    "high": 2,
    "medium": 2,
    "low": 0
  },
  "tools_used": ["bandit", "semgrep"],
  "vulnerabilities": [
    {
      "file": "app/auth.py",
      "line": 25,
      "rule_id": "B101",
      "severity": "high",
      "message": "Hardcoded password detected",
      "cwe": "CWE-798",
      "tool": "bandit"
    }
  ]
}

HTML

sembicho scan --path . --format html --output report.html

Genera un reporte HTML completo con:

  • Resumen ejecutivo con métricas
  • Lista detallada de vulnerabilidades
  • Filtros por severidad
  • Información de herramientas utilizadas

Console

sembicho scan --path .

Salida de consola con colores y formato legible.

⚙️ Configuración

Crear configuración inicial

sembicho config --init

Esto crea un archivo .sembicho.json:

{
  "api_url": "http://localhost:8000/api/results",
  "token": "",
  "default_format": "console",
  "fail_on": ["critical", "high"],
  "tools": ["bandit", "eslint", "semgrep"],
  "exclude_patterns": [
    "*.min.js",
    "node_modules/*",
    ".git/*",
    "__pycache__/*"
  ]
}

Ver configuración actual

sembicho config --show

🔧 Integración CI/CD

GitHub Actions

- name: Security Scan
  run: |
    pip install -r sembicho-cli/requirements.txt
    python sembicho-cli/main.py scan --path . --ci-mode --fail-on critical,high

GitLab CI

security_scan:
  script:
    - cd sembicho-cli
    - pip install -r requirements.txt
    - python main.py scan --path .. --ci-mode --fail-on critical,high

Jenkins

stage('Security Scan') {
    steps {
        sh '''
            cd sembicho-cli
            pip install -r requirements.txt
            python main.py scan --path .. --ci-mode --fail-on critical,high
        '''
    }
}

🐳 Docker

Dockerfile incluido

El proyecto incluye un Dockerfile optimizado para análisis de seguridad.

# Construir imagen
docker build -t sembicho-cli .

# Ejecutar escaneo
docker run --rm -v $(pwd):/workspace sembicho-cli scan --path /workspace

# Con configuración personalizada
docker run --rm -v $(pwd):/workspace -v $(pwd)/.sembicho.json:/app/.sembicho.json sembicho-cli scan --path /workspace

📝 Códigos de Salida

  • 0: Escaneo exitoso sin errores críticos
  • 1: Error en argumentos o ejecución
  • 1: Vulnerabilidades encontradas (cuando se usa --fail-on)

🔍 Lenguajes Soportados

  • Python (.py) - Bandit, Semgrep
  • JavaScript/TypeScript (.js, .ts, .jsx, .tsx) - ESLint, Semgrep
  • Java (.java) - Semgrep
  • PHP (.php) - Semgrep
  • Go (.go) - Semgrep
  • C/C++ (.c, .cpp) - Semgrep
  • Ruby (.rb) - Semgrep
  • C# (.cs) - Semgrep

🤝 Contribución

  1. Fork el proyecto
  2. Crea una rama para tu feature (git checkout -b feature/nueva-funcionalidad)
  3. Commit tus cambios (git commit -am 'Agregar nueva funcionalidad')
  4. Push a la rama (git push origin feature/nueva-funcionalidad)
  5. Abre un Pull Request

📄 Licencia

MIT License - ver LICENSE para detalles.

🆘 Soporte

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sembicho_cli-2.6.5.tar.gz (97.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sembicho_cli-2.6.5-py3-none-any.whl (87.5 kB view details)

Uploaded Python 3

File details

Details for the file sembicho_cli-2.6.5.tar.gz.

File metadata

  • Download URL: sembicho_cli-2.6.5.tar.gz
  • Upload date:
  • Size: 97.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for sembicho_cli-2.6.5.tar.gz
Algorithm Hash digest
SHA256 898d266d93becf8f2d912187667cf73144c3cda75d0c92e33efc8440e534fc6d
MD5 92f97e6115f78acbb3b88b0d64e607c0
BLAKE2b-256 1bfb29b86ade798e4d7f371a70dfb82317bb7993ac01916e9795e0ea2f62e6d9

See more details on using hashes here.

File details

Details for the file sembicho_cli-2.6.5-py3-none-any.whl.

File metadata

  • Download URL: sembicho_cli-2.6.5-py3-none-any.whl
  • Upload date:
  • Size: 87.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for sembicho_cli-2.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 08c8d54e5c735db7a89cfdceb960a60837f4ce8ef90114c63cd340895f016b26
MD5 74b37b78043243558207090c6d37e0d4
BLAKE2b-256 3165a7877c7472f16aa7df4f3357bc375cb1be7ac7057c781bdf3b0517f6aeb6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page