GitHub

sarif.cr

A Crystal library for working with SARIF (Static Analysis Results Interchange Format), the OASIS standard for representing static analysis tool output in a structured JSON format.

Implements the full SARIF 2.1.0 specification with 50+ object types, fluent builder API, parsing, and validation.

Overview

sarif.cr provides a complete, type-safe Crystal implementation of the SARIF 2.1.0 schema. It enables Crystal applications to generate, parse, and validate SARIF documents -- the standard interchange format used by tools like ESLint, Semgrep, CodeQL, and many others.

Features

Installation

Add the dependency to your shard.yml:

dependencies:
  sarif:
    github: hahwul/sarif

Then run:

shards install

Quick Example

require "sarif"

log = Sarif::Builder.build do |b|
  b.run("MyLinter", "1.0.0") do |r|
    r.rule("LINT001", name: "UnusedVar",
           short_description: "Unused variable detected")
    r.result("Variable 'x' is never used",
             rule_id: "LINT001",
             level: Sarif::Level::Warning,
             uri: "src/main.cr",
             start_line: 10)
  end
end

puts log.to_pretty_json