Output-Formate
codeguard analyze --output <format> unterstützt vier Formate.
console (Default)
Menschenlesbarer Konsolen-Output mit ANSI-Farben auf TTYs.
src/Domain/PricingEngine.cs:42
[warn] DateTime-Direct-Usage
Direct call to DateTime.UtcNow.
Inject TimeProvider via constructor and call GetUtcNow()
Farben werden in Pipes automatisch deaktiviert. Manuelles Abschalten mit
--no-color.
json
Strukturierte JSON-Datei mit Metadaten und einem Findings-Array.
codeguard analyze MySolution.sln --output json --output-file findings.json
Gut für Skript-Verarbeitung und eigene Auswertungen.
sarif
SARIF v2.1, Standard für statische Analyse-Tools, von GitHub Code Scanning, GitLab SAST und vielen IDEs direkt konsumierbar.
codeguard analyze MySolution.sln --output sarif --output-file codeguard.sarif
Beispiel-Upload zu GitHub Code Scanning:
- name: Analyze
run: codeguard analyze MySolution.sln --output sarif --output-file codeguard.sarif
- name: Upload SARIF
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: codeguard.sarif
github-annotations
GitHub-Annotation-Format. Die GitHub Actions Runner verstehen das direkt und rendern Findings als Inline-Kommentare auf der PR-Diff-Zeile.
codeguard analyze MySolution.sln --output github-annotations
Output sieht so aus:
::warning file=src/Domain/PricingEngine.cs,line=42::DateTime-Direct-Usage: Direct call to DateTime.UtcNow
::error file=src/Web/Controllers/ProductsController.cs,line=88::Async-Method-Without-CancellationToken: ...
Mit --workspace-root strippt ihr ein Pfad-Prefix, falls die Solution in
einem Unterverzeichnis des Workspaces liegt.
Die offizielle GitHub Action setzt dieses Format intern als Default.
Welches Format wann
| Szenario | Format |
|---|---|
| Lokal in der Konsole | console |
| GitHub Actions PR-Annotations | github-annotations |
| GitHub Code Scanning Security-Tab | sarif |
| GitLab SAST | sarif |
| Eigenes Dashboard oder Skript | json |
| Archivieren als CI-Artifact | json oder sarif |