Class: Formatter::Sarif

Inherits:
Object
  • Object
show all
Defined in:
lib/formatter/sarif.rb

Instance Method Summary collapse

Instance Method Details

#format(repo:, workflow_count:, findings:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/formatter/sarif.rb', line 6

def format(repo:, workflow_count:, findings:)
    sarif = {
        "$schema" => "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/main/sarif-2.1/schema/sarif-schema-2.1.0.json",
        "version" => "2.1.0",
        "runs" => [{
            "tool" => {
                "driver" => {
                    "name" => "sentinel",
                    "informationUri" => "https://sentinel.copilotkit.dev",
                    "version" => Sentinel::VERSION,
                    "rules" => build_rules(findings)
                }
            },
            "results" => findings.sort.map { |f| build_result(f) }
        }]
    }
    JSON.pretty_generate(sarif)
end