Improve QA output format for better readability

Changes to output format:
- Clear PASS/FAIL status at top (✓ PASSED, ⚠ WARNINGS, ✗ FAILED)
- Show ALL critical issues (no truncation)
- HIGH issues: Show top 20 instead of 15
- MEDIUM/LOW: Group by file with counts (not individual issues)
- Compact category breakdown (top 10 only)
- Concise action summary (removed verbose next steps)
- Single-line completion status

Benefits:
- Immediately see pass/fail status
- Critical issues never truncated
- Less noise from minor issues
- File-grouped view shows problem areas
- Faster to scan and understand
- More structured for AI parsing

Output is now optimized for both human and AI readability.
This commit is contained in:
cschantz
2026-01-08 23:02:51 -05:00
parent 021e3229e0
commit 97b91ba5f6
+54 -106
View File
@@ -3279,34 +3279,23 @@ echo "════════════════════════
# Display colored summary to terminal
echo -e "${BOLD}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD} QA SCAN RESULTS${NC}"
if [ "$crit" -gt 0 ]; then
echo -e "${RED}${BOLD} ✗ QA SCAN FAILED${NC}"
echo -e "${RED}${BOLD} $crit CRITICAL ISSUES FOUND${NC}"
elif [ "$high" -gt 0 ]; then
echo -e "${YELLOW}${BOLD} ⚠ QA SCAN: WARNINGS${NC}"
echo -e "${YELLOW}${BOLD} $high HIGH ISSUES FOUND${NC}"
elif [ "$total" -gt 0 ]; then
echo -e "${BLUE}${BOLD} ✓ QA SCAN: PASSED${NC}"
echo -e "${BLUE}${BOLD} $total minor issues found${NC}"
else
echo -e "${GREEN}${BOLD} ✓ QA SCAN: PERFECT${NC}"
echo -e "${GREEN}${BOLD} NO ISSUES FOUND${NC}"
fi
echo -e "${BOLD}═══════════════════════════════════════════════════════════════${NC}"
echo ""
echo -e "${BOLD}Total Issues:${NC} $total"
if [ "$crit" -gt 0 ]; then
echo -e " ${RED}${BOLD}CRITICAL:${NC} ${RED}$crit${NC} ${DIM}(must fix immediately)${NC}"
else
echo -e " ${DIM}CRITICAL: 0${NC}"
fi
if [ "$high" -gt 0 ]; then
echo -e " ${YELLOW}HIGH:${NC} ${YELLOW}$high${NC} ${DIM}(fix soon)${NC}"
else
echo -e " ${DIM}HIGH: 0${NC}"
fi
if [ "$med" -gt 0 ]; then
echo -e " ${BLUE}MEDIUM:${NC} ${BLUE}$med${NC} ${DIM}(review when possible)${NC}"
else
echo -e " ${DIM}MEDIUM: 0${NC}"
fi
if [ "$low" -gt 0 ]; then
echo -e " ${CYAN}LOW:${NC} ${CYAN}$low${NC} ${DIM}(minor issues)${NC}"
else
echo -e " ${DIM}LOW: 0${NC}"
fi
echo ""
echo -e "${DIM}Files Scanned: $(find "$TOOLKIT_PATH" -name "*.sh" 2>/dev/null | wc -l)${NC}"
echo -e "${DIM}Scan Duration: ${DURATION}s${NC}"
echo -e "${DIM}Full Report: $REPORT${NC}"
echo -e "${BOLD}SUMMARY:${NC} $total issues | CRITICAL: $crit | HIGH: $high | MEDIUM: $med | LOW: $low"
echo -e "${DIM}Files: $(find "$TOOLKIT_PATH" -name "*.sh" 2>/dev/null | wc -l) | Duration: ${DURATION}s | Report: $REPORT${NC}"
echo -e "${BOLD}═══════════════════════════════════════════════════════════════${NC}"
# Summary mode: just show counts and exit
@@ -3327,125 +3316,84 @@ if $SUMMARY_MODE; then
exit $total
fi
echo ""
echo -e "${BOLD}DETAILED BREAKDOWN BY SEVERITY:${NC}"
echo ""
# Group and display by severity with colors
# CRITICAL issues: Show ALL (no truncation)
if [ "$crit" -gt 0 ]; then
echo -e "${RED}${BOLD}CRITICAL ISSUES ($crit):${NC}"
echo -e "${RED}${BOLD}CRITICAL ISSUES ($crit) - MUST FIX:${NC}"
grep "^CRITICAL|" "$REPORT" | while IFS='|' read -r sev file line issue; do
# Simplify file path (relative to toolkit)
rel_file="${file#$TOOLKIT_PATH/}"
printf " ${RED}${NC} %s:%s ${DIM}-${NC} %s\n" "$rel_file" "$line" "$issue"
printf " ${RED}${NC} %s:%s - %s\n" "$rel_file" "$line" "$issue"
done
echo ""
fi
# HIGH issues: Show top 20, group by file
if [ "$high" -gt 0 ]; then
echo -e "${YELLOW}HIGH ISSUES ($high):${NC}"
grep "^HIGH|" "$REPORT" | head -15 | while IFS='|' read -r sev file line issue; do
echo -e "${YELLOW}${BOLD}HIGH ISSUES ($high) - FIX SOON:${NC}"
grep "^HIGH|" "$REPORT" | head -20 | while IFS='|' read -r sev file line issue; do
rel_file="${file#$TOOLKIT_PATH/}"
printf " ${YELLOW}${NC} %s:%s ${DIM}-${NC} %s\n" "$rel_file" "$line" "$issue"
printf " ${YELLOW}${NC} %s:%s - %s\n" "$rel_file" "$line" "$issue"
done
if [ "$high" -gt 15 ]; then
echo -e " ${DIM}... and $((high - 15)) more (see $REPORT)${NC}"
if [ "$high" -gt 20 ]; then
echo -e " ${DIM}... +$((high - 20)) more (run: grep '^HIGH' $REPORT)${NC}"
fi
echo ""
fi
if [ "$med" -gt 0 ]; then
echo -e "${BLUE}MEDIUM ISSUES ($med):${NC}"
grep "^MEDIUM|" "$REPORT" | head -10 | while IFS='|' read -r sev file line issue; do
rel_file="${file#$TOOLKIT_PATH/}"
printf " ${BLUE}${NC} %s:%s ${DIM}-${NC} %s\n" "$rel_file" "$line" "$issue"
# MEDIUM/LOW: Just show file counts
if [ "$med" -gt 0 ] || [ "$low" -gt 0 ]; then
echo -e "${BOLD}MEDIUM ($med) & LOW ($low) ISSUES BY FILE:${NC}"
{
grep "^MEDIUM|" "$REPORT" 2>/dev/null | cut -d'|' -f2
grep "^LOW|" "$REPORT" 2>/dev/null | cut -d'|' -f2
} | sed "s|$TOOLKIT_PATH/||" | sort | uniq -c | sort -rn | head -15 | while read count file; do
printf " ${DIM}%3d issues${NC} - %s\n" "$count" "$file"
done
if [ "$med" -gt 10 ]; then
echo -e " ${DIM}... and $((med - 10)) more (see $REPORT)${NC}"
fi
echo -e " ${DIM}(Run: grep '^MEDIUM\\|^LOW' $REPORT | less)${NC}"
echo ""
fi
if [ "$low" -gt 0 ]; then
echo -e "${CYAN}LOW ISSUES ($low):${NC}"
grep "^LOW|" "$REPORT" | head -5 | while IFS='|' read -r sev file line issue; do
rel_file="${file#$TOOLKIT_PATH/}"
printf " ${CYAN}${NC} %s:%s ${DIM}-${NC} %s\n" "$rel_file" "$line" "$issue"
done
if [ "$low" -gt 5 ]; then
echo -e " ${DIM}... and $((low - 5)) more (see $REPORT)${NC}"
fi
echo ""
fi
echo -e "${BOLD}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD}TOP ISSUES BY CATEGORY:${NC}"
echo -e "${BOLD}═══════════════════════════════════════════════════════════════${NC}"
# Create array of category counts
# Top issue categories (compact view)
if [ "$total" -gt 0 ]; then
echo -e "${BOLD}TOP 10 ISSUE CATEGORIES:${NC}"
declare -A cat_counts
for tag in SQL-INJ CMD-INJ PANEL-CALL FILE-OP SECRET-LEAK RACE SOURCE RETURN NULL DEP TEMP SUBSHELL PIPE WORDSPLIT ARITH TEST REDIR TRAP ARRAY HEREDOC IF-MASK NUMCMP BG-JOB LOCALE PROC-SUB PRINTF REGEX BASHISM ESCAPE SLEEP-RACE IFS SUBSHELL-VAR TRAP-RACE PERF-LOOP PERF-CACHE PERF-READ RECURSION FD-LEAK ZOMBIE DISK-SPACE NET-TIMEOUT LOG-ROTATE CPU-LOOP HARDCODED-PATH MISSING-LIB USERDATA-ACCESS API-CHECK NO-CASE DB-PATTERN NO-USER-MGR NO-STANDALONE; do
count=$(grep -c "\[$tag\]" "$REPORT" 2>/dev/null || echo 0)
count=$(echo "$count" | head -1 | tr -d '\n\r')
if [ "$count" -gt 0 ]; then
cat_counts[$tag]=$count
fi
# Sanitize: ensure it's a single integer
count=$(echo "$count" | head -1 | tr -d '\n\r' | grep -o '^[0-9]*$' || echo 0)
[ "$count" -gt 0 ] 2>/dev/null && cat_counts[$tag]=$count
done
# Sort and display (show top 15)
if [ ${#cat_counts[@]} -gt 0 ]; then
for tag in "${!cat_counts[@]}"; do
echo "${cat_counts[$tag]} $tag"
done | sort -rn | head -15 | while read count tag; do
# Color code based on severity keywords
if [[ "$tag" =~ (SQL-INJ|CMD-INJ|SECRET) ]]; then
printf " ${RED}%-20s${NC} %s\n" "$tag" "${CYAN}$count issues${NC}"
elif [[ "$tag" =~ (FILE-OP|RACE|PANEL) ]]; then
printf " ${YELLOW}%-20s${NC} %s\n" "$tag" "${CYAN}$count issues${NC}"
else
printf " ${DIM}%-20s${NC} %s\n" "$tag" "${CYAN}$count issues${NC}"
fi
done | sort -rn | head -10 | while read count tag; do
printf " %-18s %3d issues\n" "$tag" "$count"
done
total_cats=${#cat_counts[@]}
if [ "$total_cats" -gt 15 ]; then
echo -e " ${DIM}... and $((total_cats - 15)) more categories (see $REPORT)${NC}"
fi
else
echo -e " ${GREEN}No issues found!${NC}"
fi
echo ""
fi
# Cleanup
rm -f "$TEMP_COUNTS"
# Concise action summary
echo -e "${BOLD}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${BOLD}NEXT STEPS:${NC}"
echo -e "${BOLD}═══════════════════════════════════════════════════════════════${NC}"
echo ""
if [ "$total" -eq 0 ]; then
echo -e " ${GREEN}${NC} Code quality looks good!"
echo -e " ${DIM}No issues found in this scan${NC}"
elif [ "$crit" -gt 0 ]; then
echo -e " ${RED}!${NC} Fix ${RED}CRITICAL${NC} issues immediately"
echo -e " ${DIM}Use: grep '^CRITICAL' $REPORT${NC}"
if [ "$crit" -gt 0 ]; then
echo -e "${RED}ACTION REQUIRED:${NC} Fix $crit CRITICAL issues immediately"
echo -e "${DIM}View: grep '^CRITICAL' $REPORT${NC}"
elif [ "$high" -gt 0 ]; then
echo -e " ${YELLOW}!${NC} Review ${YELLOW}HIGH${NC} priority issues soon"
echo -e " ${DIM}Use: grep '^HIGH' $REPORT${NC}"
echo -e "${YELLOW}RECOMMENDED:${NC} Review $high HIGH priority issues soon"
echo -e "${DIM}View: grep '^HIGH' $REPORT${NC}"
elif [ "$total" -gt 0 ]; then
echo -e "${BLUE}OPTIONAL:${NC} Review $total minor issues when convenient"
echo -e "${DIM}View: less $REPORT${NC}"
else
echo -e " ${BLUE}${NC} Review and fix issues when possible"
echo -e "${GREEN}ALL CLEAR:${NC} No issues found!"
fi
echo ""
echo -e "${DIM}Full report: $REPORT${NC}"
echo ""
echo -e "${BOLD}Useful Commands:${NC}"
echo -e " ${CYAN}$0 --quick${NC} ${DIM}# Fast scan (CRITICAL + HIGH only)${NC}"
echo -e " ${CYAN}$0 --security${NC} ${DIM}# Security issues only${NC}"
echo -e " ${CYAN}$0 --category SQL-INJ${NC} ${DIM}# Filter by category${NC}"
echo -e " ${CYAN}$0 --summary${NC} ${DIM}# Show counts only${NC}"
echo -e " ${CYAN}grep '^CRITICAL' $REPORT${NC} ${DIM}# View all critical issues${NC}"
echo ""
echo -e "${DIM}Scan completed in ${DURATION}s | Exit code: $total${NC}"
echo -e "${BOLD}═══════════════════════════════════════════════════════════════${NC}"
echo -e "${DIM}Completed in ${DURATION}s | Full report: $REPORT | Exit code: $total${NC}"
echo ""
exit $total