Skip to content

Comando Scan

El comando scan es la funcionalidad principal de RootCause. Permite analizar código fuente en busca de problemas de seguridad y calidad usando reglas personalizadas.

Scan code for security vulnerabilities and quality issues

Usage: rootcause scan [OPTIONS] <PATH>

Arguments:
  <PATH>  Path to scan (file or directory)

Options:
      --rules <RULES>
          Path to rules directory or ruleset [default: /home/m3str3/.config/rootcause/rules]
      --semgrep-rules <SEMGREP_RULES>
          Path to Semgrep-compatible rules
      --format <FORMAT>
          Output format for scan results [default: text] [possible values: text, json, sarif]
      --fail-on <FAIL_ON>
          Exit with error code if findings of this severity or higher are found
      --threads <THREADS>
          Number of parallel threads to use for scanning [default: 16]
      --exclude <EXCLUDE>
          Exclude files matching these patterns (supports regex)
      --no-default-exclude
          Don't use default exclusion patterns
      --max-file-size <MAX_FILE_SIZE>
          Maximum file size to scan (in bytes) [default: 5242880]
      --timeout-file-ms <TIMEOUT_FILE_MS>
          Timeout per file in milliseconds
      --timeout-rule-ms <TIMEOUT_RULE_MS>
          Timeout per rule in milliseconds
      --metrics <METRICS>
          Write performance metrics to file
      --baseline <BASELINE>
          Path to baseline file for comparison
      --write-baseline <WRITE_BASELINE>
          Write baseline file with current findings
      --plugin <PLUGINS>
          Load plugins from specified paths
      --plugin-opt <PLUGIN_OPTS>
          Plugin options as key=value pairs
      --plugin-config <PLUGIN_CONFIG>
          Path to plugin configuration file
      --suppress-comment <SUPPRESS_COMMENT>
          Comment pattern to suppress findings [default: sast-ignore]
      --stream
          Enable streaming mode for large outputs
      --chunk-size <CHUNK_SIZE>
          Number of findings to process in each chunk [default: 100]
      --dump-taints
          Dump taint analysis data for debugging
      --debug
          Enable debug output
      --quiet
          Suppress non-essential output
      --apply-fixes
          Automatically apply suggested fixes
      --cache-dir <CACHE_DIR>
          Directory to store cache files
  -h, --help
          Print help

Códigos de salida

El comando scan utiliza códigos de salida estándar:

  • 0: Éxito, sin problemas encontrados o problemas por debajo del umbral --fail-on
  • 1: Error general (problemas de configuración, archivos no encontrados, etc.)
  • 2: Problemas encontrados por encima del umbral --fail-on

Opciones más utilizadas

Configuración básica

  • --rules <RULES>: Directorio de reglas (por defecto: ~/.config/rootcause/rules)
  • --format <FORMAT>: Formato de salida (text, json, sarif)
  • --threads <THREADS>: Número de hilos paralelos (por defecto: 16)

Control de calidad

  • --fail-on <SEVERITY>: Fallar si se encuentran problemas de esta severidad o superior
  • --exclude <PATTERNS>: Excluir archivos que coincidan con estos patrones (regex)
  • --no-default-exclude: No usar patrones de exclusión por defecto

Optimización

  • --max-file-size <BYTES>: Tamaño máximo de archivo a escanear (por defecto: 5MB)
  • --timeout-file-ms <MS>: Timeout por archivo en milisegundos
  • --timeout-rule-ms <MS>: Timeout por regla en milisegundos
  • --stream: Modo streaming para salidas grandes
  • --chunk-size <SIZE>: Procesar archivos en lotes (por defecto: 100)

Plugins

  • --plugin <PATH>: Cargar plugins desde rutas específicas
  • --plugin-opt <KEY=VALUE>: Opciones de plugins como pares clave=valor
  • --plugin-config <PATH>: Archivo de configuración de plugins

Modos especiales

  • --debug: Habilitar salida de depuración
  • --quiet: Suprimir salida no esencial
  • --apply-fixes: Aplicar automáticamente correcciones sugeridas
  • --dump-taints: Volcar datos de análisis de flujo para depuración

RootCause - Modular Static Analysis Engine