sonarcloud security hotspots - smart-village-solutions/sva-studio GitHub Wiki
Dieses Projekt enthält ein kleines CLI, um Security Hotspots und normale Issues aus SonarCloud direkt abzurufen und zu pflegen, ohne die Weboberfläche manuell durchklicken zu müssen.
Das Skript liegt unter scripts/ci/sonar-hotspots.ts und nutzt die SonarCloud-API-Endpunkte für:
- Hotspots auflisten
- Details zu einem Hotspot anzeigen
- Hotspots als geprüft markieren
- mehrere Hotspots gesammelt als geprüft markieren
- Issues auflisten
- Details zu einem Issue anzeigen
- Issue-Transitions ausführen
- Kommentare an Issues anhängen
- Ein gültiges SonarCloud-Token mit Zugriff auf das Projekt
- Eine der Umgebungsvariablen
SONAR_TOKENoderSONARQUBE_TOKEN
Standardmäßig arbeitet das Skript mit dem Projekt smart-village-app_sva-studio.
Das Skript toleriert außerdem ein führendes --, damit Aufrufe über pnpm <script> -- ... funktionieren.
Alle offenen Hotspots anzeigen:
tsx scripts/ci/sonar-hotspots.ts listNach Branch filtern:
tsx scripts/ci/sonar-hotspots.ts list --branch mainAuf einen Dateibereich eingrenzen:
tsx scripts/ci/sonar-hotspots.ts list --file-path-includes apps/sva-studio-react/src/componentsDetails zu einem Hotspot anzeigen:
tsx scripts/ci/sonar-hotspots.ts show --hotspot AXxxxxHotspot als geprüft markieren:
tsx scripts/ci/sonar-hotspots.ts review \
--hotspot AXxxxx \
--resolution SAFE \
--comment "Kein Risiko im konkreten Kontext, da Inhalt vor dem DOM-Sink sanitisiert wird."JSON-Ausgabe erzwingen:
tsx scripts/ci/sonar-hotspots.ts list --jsonCSV-Ausgabe für Tabellen oder jq-freie Weiterverarbeitung:
tsx scripts/ci/sonar-hotspots.ts list --csvMehrere Hotspots gesammelt markieren:
tsx scripts/ci/sonar-hotspots.ts bulk-review \
--hotspot AX111 \
--hotspot AX222 \
--resolution SAFE \
--comment "Gleiche Schutzmaßnahme und gleiche technische Begründung."Offene Issues abrufen:
tsx scripts/ci/sonar-hotspots.ts issues:listIssues nach Typ und Status eingrenzen:
tsx scripts/ci/sonar-hotspots.ts issues:list --statuses OPEN,CONFIRMED --types BUG,VULNERABILITYIssue-Details anzeigen:
tsx scripts/ci/sonar-hotspots.ts issues:show --issue AXxxxxIssue-Status ändern:
tsx scripts/ci/sonar-hotspots.ts issues:transition --issue AXxxxx --transition accept --comment "Akzeptiert im konkreten Kontext"Kommentar an ein Issue hängen:
tsx scripts/ci/sonar-hotspots.ts issues:comment --issue AXxxxx --comment "Fix ist im aktuellen Branch umgesetzt."- Hotspots mit
listoder Issues mitissues:listabrufen. - Kandidaten mit
showoderissues:showim Detail prüfen. - Code und Tests anpassen.
- Hotspots mit
reviewoderbulk-reviewmarkieren. - Für normale Issues anschließend einen neuen Sonar-Scan abwarten oder bei berechtigter Ausnahme
issues:transitionbzw.issues:commentnutzen.
- SonarCloud verlangt für Hotspot- und Issue-Abfragen in der Praxis Authentifizierung, auch wenn ein Projekt öffentlich sichtbar ist.
- Die verwendeten Hotspot-Endpunkte sind in SonarCloud weniger stabil dokumentiert als andere APIs. Bei Änderungen an der Plattform muss das Skript gegebenenfalls angepasst werden.