55 lines
1.0 KiB
Bash
Executable File
55 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
# Fuehrt Semgrep Autofix durch
|
|
|
|
set -e
|
|
|
|
# Farben
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
NC='\033[0m'
|
|
|
|
# Pruefen ob Semgrep installiert ist
|
|
if ! command -v semgrep &> /dev/null; then
|
|
echo -e "${YELLOW}Semgrep nicht gefunden. Installiere...${NC}"
|
|
bash "$(dirname "$0")/install-semgrep.sh"
|
|
fi
|
|
|
|
# Argumente
|
|
if [ $# -gt 0 ]; then
|
|
SCAN_TARGET="$@"
|
|
else
|
|
SCAN_TARGET="."
|
|
fi
|
|
|
|
echo "Starte Semgrep Autofix..."
|
|
echo "========================="
|
|
echo ""
|
|
|
|
# Autofix durchfuehren
|
|
# Nur Rules mit Autofix-Support
|
|
semgrep \
|
|
--config=auto \
|
|
--autofix \
|
|
--dryrun \
|
|
$SCAN_TARGET 2>&1 | head -50
|
|
|
|
echo ""
|
|
read -p "Fixes anwenden? (y/n) " -n 1 -r
|
|
echo ""
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
echo "Wende Fixes an..."
|
|
semgrep \
|
|
--config=auto \
|
|
--autofix \
|
|
$SCAN_TARGET
|
|
|
|
echo ""
|
|
echo -e "${GREEN}Fixes angewendet!${NC}"
|
|
echo ""
|
|
echo "Bitte pruefen Sie die Aenderungen:"
|
|
echo " git diff"
|
|
else
|
|
echo "Autofix abgebrochen."
|
|
fi
|