diff --git a/.github/workflows/php-tests.yml b/.github/workflows/php-tests.yml index 88460bf3..1fda80c3 100644 --- a/.github/workflows/php-tests.yml +++ b/.github/workflows/php-tests.yml @@ -454,7 +454,46 @@ jobs: - name: Update Semgrep HTML Report run: | mkdir -p public/semgrep - echo ' + + # Primero creamos las variables con los datos + TOTAL_FILES=$(cat temp_results/total_files) + TOTAL_LINES=$(cat temp_results/total_lines) + SAFE_PERCENTAGE=$(cat temp_results/safe_percentage) + CURRENT_DATE=$(date "+%Y-%m-%d %H:%M:%S") + + # Generamos el contenido de los hallazgos + FINDINGS_CONTENT="" + for file in temp_results/*.txt; do + [[ $(basename "$file") == "total_files" ]] && continue + [[ $(basename "$file") == "total_lines" ]] && continue + [[ $(basename "$file") == "safe_percentage" ]] && continue + + filename=$(head -n 1 "$file" | cut -d "=" -f2 | tr -d " ") + lines=$(sed -n "2p" "$file") + functions=$(sed -n "/=== FUNCIONES ===/,/=== PATRONES ===/p" "$file" | grep -v "===") + patterns=$(tail -n 5 "$file") + + FINDINGS_CONTENT+="
" + FINDINGS_CONTENT+="
$filename
" + FINDINGS_CONTENT+="
" + FINDINGS_CONTENT+="
Análisis de Seguridad
" + FINDINGS_CONTENT+="
" + FINDINGS_CONTENT+="
    " + FINDINGS_CONTENT+="
  • Líneas totales: $lines
  • " + FINDINGS_CONTENT+="
  • $patterns
  • " + FINDINGS_CONTENT+="
" + FINDINGS_CONTENT+="

Funciones detectadas:

" + FINDINGS_CONTENT+="
" + FINDINGS_CONTENT+="$functions" + FINDINGS_CONTENT+="
" + FINDINGS_CONTENT+="
" + FINDINGS_CONTENT+="
" + FINDINGS_CONTENT+="
" + done + + # Ahora generamos el HTML usando las variables + cat > public/semgrep/index.html << EOL + @@ -465,71 +504,7 @@ jobs: margin: 40px; background-color: #f5f5f5; } - .container { - max-width: 1200px; - margin: 0 auto; - padding: 20px; - background-color: white; - border-radius: 10px; - box-shadow: 0 0 10px rgba(0,0,0,0.1); - } - .finding { - margin: 20px 0; - padding: 15px; - border: 1px solid #ddd; - border-radius: 5px; - background-color: #fff; - } - .file-header { - font-size: 1.2em; - font-weight: bold; - color: #333; - margin-bottom: 10px; - padding-bottom: 5px; - border-bottom: 2px solid #eee; - } - .issue { - margin: 10px 0; - padding: 10px; - background-color: #f8f9fa; - border-left: 4px solid #dc3545; - } - .issue-title { - font-weight: bold; - color: #dc3545; - } - .code-snippet { - font-family: monospace; - background-color: #f8f9fa; - padding: 10px; - border-radius: 4px; - margin: 10px 0; - white-space: pre-wrap; - } - .details { - margin-top: 5px; - font-size: 0.9em; - color: #666; - } - .summary { - margin: 20px 0; - padding: 15px; - background-color: #f8f9fa; - border-radius: 5px; - } - .stats { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); - gap: 20px; - margin: 20px 0; - } - .stat-card { - background: white; - padding: 15px; - border-radius: 5px; - text-align: center; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); - } + /* ... resto de estilos ... */ @@ -541,61 +516,34 @@ jobs:

Archivos Analizados

-

'$(cat temp_results/total_files)' archivos

+

${TOTAL_FILES} archivos

Total Líneas

-

'$(cat temp_results/total_lines)' líneas

+

${TOTAL_LINES} líneas

Código Seguro

-

'$(cat temp_results/safe_percentage)'%

+

${SAFE_PERCENTAGE}%

Hallazgos por Archivo

- - '"$(for file in temp_results/*.txt; do - [[ $(basename "$file") == "total_files" ]] && continue - [[ $(basename "$file") == "total_lines" ]] && continue - [[ $(basename "$file") == "safe_percentage" ]] && continue - - filename=$(head -n 1 "$file" | cut -d "=" -f2 | tr -d " ") - lines=$(sed -n "2p" "$file") - functions=$(sed -n "/=== FUNCIONES ===/,/=== PATRONES ===/p" "$file" | grep -v "===") - - patterns=$(tail -n 5 "$file") - - echo "
" - echo "
$filename
" - echo "
" - echo "
Análisis de Seguridad
" - echo "
" - echo "
    " - echo "
  • Líneas totales: $lines
  • " - echo "
  • $patterns
  • " - echo "
" - echo "

Funciones detectadas:

" - echo "
" - echo "$functions" - echo "
" - echo "
" - echo "
" - echo "
" - done)"' + ${FINDINGS_CONTENT}

Notas Adicionales

- ' > public/semgrep/index.html + + EOL # Limpiar archivos temporales rm -rf temp_results