Skip to content

Output-Formate

console, json, sarif und github-annotations.

codecharter 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.

codecharter 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.

codecharter analyze MySolution.sln --output sarif --output-file codecharter.sarif

Beispiel-Upload zu GitHub Code Scanning:

- name: Analyze
  run: codecharter analyze MySolution.sln --output sarif --output-file codecharter.sarif

- name: Upload SARIF
  uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: codecharter.sarif

github-annotations

GitHub-Annotation-Format. Die GitHub Actions Runner verstehen das direkt und rendern Findings als Inline-Kommentare auf der PR-Diff-Zeile.

codecharter 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.

Mehrere Outputs in einem Lauf

--output ist wiederholbar und akzeptiert ein optionales Ziel als format:path. So erzeugt eine einzige Analyse mehrere Formate gleichzeitig, ohne zweiten Lauf:

codecharter analyze MySolution.sln \
  --output github-annotations \
  --output json:codecharter.json \
  --output sarif:codecharter.sarif

Regeln:

  • stdout-Formate (console, github-annotations) nehmen keinen Pfad und schreiben nach stdout; höchstens ein stdout-Format pro Lauf.
  • Datei-Formate (json, sarif) brauchen einen Pfad, wenn sie kombiniert werden.
  • Die Einzel-Output-Form bleibt unverändert: --output <format> (nach stdout) und --output <format> --output-file <path> funktionieren weiter. --output-file gilt nur für die Einzel-Output-Form und lässt sich nicht mit der format:path-Syntax mischen.

Genau das nutzt die offizielle GitHub Action, um Inline- Annotations zu rendern und gleichzeitig das JSON für den PR-Kommentar und die findings-*-Outputs (und optional SARIF) zu erzeugen — alles aus einer Analyse.

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