--- name: semgrep-security description: Security Scanner mit Semgrep. WICHTIG - Dieser Skill wird automatisch bei JEDER Code-Implementierung aktiviert. Scannt neuen und geaenderten Code auf Sicherheitsluecken, Vulnerabilities und Best Practice Verstoesse. Aktiviert bei Begriffen wie "implementieren", "code schreiben", "feature erstellen", "komponente bauen", "funktion erstellen", "api route", "fertig", "done", "commit", "security", "scan", "vulnerabilities", "sicherheit". --- # Semgrep Security Scanner Dieser Skill scannt automatisch Code auf Sicherheitsprobleme nach jeder Implementierung. ## WICHTIG: Automatische Ausfuehrung Nach JEDER Code-Implementierung fuehre folgende Schritte aus: 1. **Semgrep installieren** (falls nicht vorhanden) 2. **Geaenderte Dateien scannen** 3. **Probleme fixen oder reporten** ## Scripts ### Installation pruefen und durchfuehren ```bash bash install-semgrep.sh ``` ### Scan durchfuehren ```bash # Alle Dateien scannen bash scan.sh # Nur bestimmte Dateien scannen bash scan.sh app/api/users/route.ts components/UserForm.tsx ``` ### Autofix anwenden ```bash bash autofix.sh ``` ## Workflow nach Implementierung ### 1. Installation sicherstellen ```bash # Pruefen ob semgrep installiert ist which semgrep || bash install-semgrep.sh ``` ### 2. Geaenderte Dateien ermitteln ```bash # Untracked und modified files git status --porcelain | grep -E '^\?\?|^ M|^M' | cut -c4- ``` ### 3. Security Scan ausfuehren ```bash # Mit Auto-Config (empfohlen) semgrep --config=auto --json . # Fuer TypeScript/React spezifisch semgrep --config=p/typescript --config=p/react --json . # OWASP Top 10 semgrep --config=p/owasp-top-ten --json . ``` ### 4. Ergebnisse analysieren und fixen ```bash # Mit Autofix semgrep --config=auto --autofix . # Nur Report ohne Fix semgrep --config=auto --sarif -o results.sarif . ``` ## Haeufige Security Issues und Fixes ### SQL Injection ```typescript // SCHLECHT const query = `SELECT * FROM users WHERE id = ${userId}`; // GUT const { data } = await supabase.from('users').select('*').eq('id', userId); ``` ### XSS (Cross-Site Scripting) ```typescript // SCHLECHT
// GUT