veko doc
Self-Contained API Reference • Gradual Types • Capabilities • Wasm Sandbox

sec/sarif

lib/sec/sarif.vk

lib/sec/sarif.vk Pure-Veko SARIF 2.1.0, JSON, and terminal security finding emitter, secret redactor, fingerprint baseline filter, and NIST 800-53 / SSDF compliance summary. Zero top-level mutable heap globals; zero capabilities required.

Finding struct
signature
Finding = struct { rule_id str, title str, severity enum = ..., cwe str = ..., owasp str = ..., nist_controls block[str] = ..., ssdf_practices block[str] = ..., file str = ..., line i64 = ..., col i64 = ..., snippet str = ..., message str = ..., remediation str = ..., fingerprint str = ... }

Structured security finding with CWE, OWASP, NIST SP 800-53, and NIST SSDF metadata.

signature
severity-rank = fn [sev enum] i64

Returns numeric severity rank: .low -> 1, .medium -> 2, .high -> 3, .critical -> 4, else 0.

signature
parse-severity = fn [s str] enum

Parses a case-insensitive severity name ('low'|'medium'|'high'|'critical') into an enum symbol; returns err on invalid input.

signature
severity-name = fn [sev enum] str

Converts a severity enum symbol into its canonical lowercase name ('low'|'medium'|'high'|'critical'|'unknown').

signature
sarif-level = fn [sev enum] str

Maps a severity enum symbol to its SARIF 2.1.0 level ('error'|'warning'|'note').

signature
redact-secrets = fn [s str] str

Scrubs Bearer <tok>, sk_live_<tok>, AKIA<tok>, and -----BEGIN ... PRIVATE KEY----- blocks to <REDACTED>.

signature
compute-fingerprint = fn [rule_id str, file str, snippet str] str

Computes a stable SHA-256 hex fingerprint over rule_id + ':' + file + ':' + snippet.trim.

signature
make-finding = fn [f Finding] Finding

Normalizes a Finding: redacts snippet and message and populates fingerprint if empty.

signature
compliance-summary = fn [findings block[Finding]] map

Computes severity counts and NIST 800-53 / SSDF control tallies across findings.

signature
to-sarif = fn [tool_name str, tool_version str, findings block[Finding]] str

Serializes findings as a SARIF 2.1.0 JSON document with deduplicated rules, compliance tags, and fingerprints.

signature
to-json = fn [tool_name str, tool_version str, findings block[Finding]] str

Serializes findings and compliance-summary into a structured JSON report.

signature
to-text = fn [tool_name str, findings block[Finding]] str

Formats a concise human-readable terminal report ordered by descending severity with compliance totals.

signature
load-baseline-fingerprints = fn [raw str] map

Extracts suppressed finding fingerprints into { <fp> = true } from a SARIF 2.1.0 or to-json JSON baseline.

signature
apply-baseline = fn [findings block[Finding], baseline_fps map] block[Finding]

Filters out findings whose stored or computed fingerprint is present in baseline_fps.

signature
exceeds-threshold? = fn [findings block[Finding], min_sev enum] bool

Returns true if any finding in findings has (severity-rank f.severity) >= (severity-rank min_sev).