sarif

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CapitalizeFirst

func CapitalizeFirst(s string) string

func WriteFile

func WriteFile(report *Report, filename string) error

WriteFile writes the SARIF report to a file

Types

type ArtifactLocation

type ArtifactLocation struct {
	URI       string  `json:"uri"`
	URIBaseID *string `json:"uriBaseId,omitempty"`
}

ArtifactLocation specifies the location of an artifact

type CodeFlow

type CodeFlow struct {
	ThreadFlows []ThreadFlow `json:"threadFlows"`
}

CodeFlow represents a code flow in the analysis results

type DefaultConfiguration

type DefaultConfiguration struct {
	Level string `json:"level"`
}

type Driver

type Driver struct {
	Name         *string `json:"name"`
	Organization *string `json:"organization"`
	Version      *string `json:"version"`
	Rules        []*Rule `json:"rules,omitempty"`
}

Driver contains information about the tool's driver

type FullDescription

type FullDescription struct {
	Text string `json:"text"`
}

type Help

type Help struct {
	Text string `json:"text"`
}

type Location

type Location struct {
	PhysicalLocation *PhysicalLocation  `json:"physicalLocation"`
	LogicalLocations []*LogicalLocation `json:"logicalLocations,omitempty"`
	Message          *Message           `json:"message,omitempty"`
}

Location represents a location in source code

type LogicalLocation

type LogicalLocation struct {
	FullyQualifiedName *string `json:"fullyQualifiedName,omitempty"`
	DecoratedName      *string `json:"decoratedName,omitempty"`
}

LogicalLocation represents a logical location in the code, such as a function or class

type Message

type Message struct {
	Text string `json:"text"`
}

Message contains the text of a result message

type PhysicalLocation

type PhysicalLocation struct {
	ArtifactLocation *ArtifactLocation `json:"artifactLocation"`
	Region           *Region           `json:"region,omitempty"`
}

PhysicalLocation specifies the location of a result

type PrintableResult

type PrintableResult struct {
	RuleId    *string
	Message   *string
	Locations *string
	Level     *string
}

type Properties

type Properties struct {
	Tags []string `json:"tags"`
}

type Region

type Region struct {
	StartLine   int  `json:"startLine"`
	StartColumn *int `json:"startColumn,omitempty"`
	EndLine     *int `json:"endLine,omitempty"`
	EndColumn   *int `json:"endColumn,omitempty"`
}

Region represents a region of an artifact's content

type Report

type Report struct {
	Version *string `json:"version"`
	Schema  *string `json:"$schema"`
	Runs    []*Run  `json:"runs"`
}

Report represents a SARIF report

func Parse

func Parse(data []byte) (*Report, error)

Parse parses SARIF data using standard json package

func (*Report) PrintAll

func (report *Report) PrintAll()

func (*Report) PrintSummary

func (report *Report) PrintSummary()

PrintSummary prints a human-readable summary of the SARIF report

func (*Report) UpdateRuleId

func (report *Report) UpdateRuleId(absRulesPath, userRulesPath string)

func (*Report) UpdateURIInfo

func (report *Report) UpdateURIInfo(absProjectPath string)

UpdateURIInfo updates URI information in the SARIF report

type Result

type Result struct {
	Level     string      `json:"level"`
	Message   *Message    `json:"message,omitempty"`
	RuleId    string      `json:"ruleId"`
	Locations []*Location `json:"locations,omitempty"`
	CodeFlows []*CodeFlow `json:"codeFlows,omitempty"`
}

Result represents a single result produced by the tool

type Rule

type Rule struct {
	ID                   *string               `json:"id"`
	Name                 *string               `json:"name,omitempty"`
	DefaultConfiguration *DefaultConfiguration `json:"defaultConfiguration,omitempty"`
	FullDescription      *FullDescription      `json:"fullDescription,omitempty"`
	ShortDescription     *ShortDescription     `json:"shortDescription,omitempty"`
	Properties           *Properties           `json:"properties,omitempty"`
}

Rule represents a rule that was run

type Run

type Run struct {
	Tool               *Tool                       `json:"tool"`
	Results            []*Result                   `json:"results,omitempty"`
	OriginalUriBaseIds map[string]ArtifactLocation `json:"originalUriBaseIds,omitempty"`
}

Run represents a single run of a static analysis tool

type ShortDescription

type ShortDescription struct {
	Text string `json:"text"`
}

type Summary

type Summary struct {
	TotalFindings       int
	TotalRulesRun       int
	TotalRulesTriggered int
	FindingsByLevel     map[string]int
}

Summary represents a summary of SARIF findings

func GenerateSummary

func GenerateSummary(report *Report) Summary

GenerateSummary generates a summary of the SARIF report

type ThreadFlow

type ThreadFlow struct {
	Locations []ThreadFlowLocation `json:"locations"`
}

ThreadFlow represents a thread flow in the analysis results

type ThreadFlowLocation

type ThreadFlowLocation struct {
	Location       Location `json:"location"`
	ExecutionOrder int      `json:"executionOrder"`
	Index          int      `json:"index"`
	Kinds          []string `json:"kinds"`
}

ThreadFlowLocation represents a location in a thread flow

type Tool

type Tool struct {
	Driver *Driver `json:"driver"`
}

Tool contains information about the analysis tool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL