### Create New ReportingDescriptor Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Initializes a new ReportingDescriptor. Use this to start building a report descriptor from scratch. ```go func NewReportingDescriptor() *ReportingDescriptor ``` -------------------------------- ### Example SARIF Report Structure Source: https://pkg.go.dev/github.com/owenrumney/go-sarif This is a complete example of a SARIF report, demonstrating the expected structure for static analysis results. It includes details about the tool, artifacts, and findings. ```json { "version": "2.1.0", "$schema": "https://json.schemastore.org/sarif-2.1.0-rtm.5.json", "runs": [ { "tool": { "driver": { "name": "ESLint", "informationUri": "https://eslint.org", "rules": [ { "id": "no-unused-vars", "shortDescription": { "text": "disallow unused variables" }, "helpUri": "https://eslint.org/docs/rules/no-unused-vars", "properties": { "category": "Variables" } } ] } }, "artifacts": [ { "location": { "uri": "file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js" } } ], "results": [ { "level": "error", "message": { "text": "'x' is assigned a value but never used." }, "locations": [ { "physicalLocation": { "artifactLocation": { "uri": "file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js", "index": 0 }, "region": { "startLine": 1, "startColumn": 5 } } } ], "ruleId": "no-unused-vars", "ruleIndex": 0 } ] } ] } ``` -------------------------------- ### Set Start Time UTC for Invocation Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Use WithStartTimeUtc to add a StartTimeUtc to the Invocation. ```go func (s *Invocation) WithStartTimeUtc(startTimeUtc string) *Invocation ``` -------------------------------- ### Create New Address Object Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Creates and returns a new, empty Address object. Use this as a starting point before populating its fields. ```go func NewAddress() *Address ``` -------------------------------- ### RunAutomationDetails Configuration Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Methods for configuring RunAutomationDetails, such as adding CorrelationGuID, Description, GuID, ID, and Properties. ```APIDOC ## RunAutomationDetails Configuration ### Description Methods for configuring RunAutomationDetails. ### Methods #### WithCorrelationGuID Adds a CorrelationGuID to the RunAutomationDetails. - **Method**: N/A (Method on a struct) - **Parameters**: - `correlationGuid` (string) - The correlation GUID to add. #### WithDescription Adds a Description to the RunAutomationDetails. - **Method**: N/A (Method on a struct) - **Parameters**: - `description` (*Message) - The description message to add. #### WithGuID Adds a GuID to the RunAutomationDetails. - **Method**: N/A (Method on a struct) - **Parameters**: - `guid` (string) - The GUID to add. #### WithID Adds an ID to the RunAutomationDetails. - **Method**: N/A (Method on a struct) - **Parameters**: - `id` (string) - The ID to add. #### WithProperties Adds Properties to the RunAutomationDetails. - **Method**: N/A (Method on a struct) - **Parameters**: - `properties` (*PropertyBag) - The property bag to add. ``` -------------------------------- ### Set Start Line for Region Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Sets the starting line number of a Region. Essential for pinpointing code locations. ```go func (s *Region) WithStartLine(startLine int) *Region ``` -------------------------------- ### Create New Location Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Creates a new, empty Location object. Use this as a starting point before populating its fields. ```go func NewLocation() *Location ``` -------------------------------- ### Set Baseline GUID for a SARIF Run Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Use WithBaselineGuID to set the BaselineGuID for the Run. ```go func (b *Run) WithBaselineGuID(baselineGuid string) *Run ``` -------------------------------- ### Set Process Start Failure Message for Invocation Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Use WithProcessStartFailureMessage to add a ProcessStartFailureMessage to the Invocation. ```go func (p *Invocation) WithProcessStartFailureMessage(processStartFailureMessage string) *Invocation ``` -------------------------------- ### WithGuid Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Adds a Guid to the ExternalProperties. ```go func (g *ExternalProperties) WithGuid(guid *Guid) *ExternalProperties ``` -------------------------------- ### SARIF Object Builders Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif The go-sarif library uses a builder pattern to construct various SARIF components. Below are examples of the available types and their initialization methods. ```APIDOC ## SARIF Object Initialization ### Description This library provides constructor functions for various SARIF entities. Each entity supports fluent 'With' methods to set specific properties. ### Available Constructors - **NewAddress()** - Returns a new Address object - **NewArtifact()** - Returns a new Artifact object - **NewArtifactChange()** - Returns a new ArtifactChange object - **NewArtifactContent()** - Returns a new ArtifactContent object - **NewArtifactLocation()** - Returns a new ArtifactLocation object - **NewSimpleArtifactLocation(uri string)** - Returns a new ArtifactLocation initialized with a URI - **NewAttachment()** - Returns a new Attachment object - **NewCodeFlow()** - Returns a new CodeFlow object - **NewConfigurationOverride()** - Returns a new ConfigurationOverride object - **NewConversion()** - Returns a new Conversion object ``` -------------------------------- ### Create a New V210 SARIF Report Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report Use this function to instantiate a new SARIF report object compatible with version 2.10.0. No specific setup is required beyond importing the necessary package. ```go func NewV210Report() *v210.Report ``` -------------------------------- ### Create a New V22 SARIF Report Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report Use this function to instantiate a new SARIF report object compatible with version 2.2.0. No specific setup is required beyond importing the necessary package. ```go func NewV22Report() *v22.Report ``` -------------------------------- ### Add Guid to ToolComponentReference Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Use this method to add a Guid to the ToolComponentReference. It returns the ToolComponentReference itself for chaining. ```go func (g *ToolComponentReference) WithGuid(guid *Guid) *ToolComponentReference ``` -------------------------------- ### Manage Tool Components Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Methods for creating and configuring a Tool instance. ```go func NewTool() *Tool ``` ```go func (e *Tool) AddExtension(extension *ToolComponent) *Tool ``` ```go func (d *Tool) WithDriver(driver *ToolComponent) *Tool ``` ```go func (e *Tool) WithExtensions(extensions []*ToolComponent) *Tool ``` ```go func (p *Tool) WithProperties(properties *PropertyBag) *Tool ``` -------------------------------- ### Initialize VersionControlDetails Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Creates a new instance of VersionControlDetails. ```go func NewVersionControlDetails() *VersionControlDetails ``` -------------------------------- ### Add Guid to ReportingDescriptorReference Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Use WithGuid to add a Guid to the ReportingDescriptorReference. This method returns the updated ReportingDescriptorReference. ```go func (g *ReportingDescriptorReference) WithGuid(guid *Guid) *ReportingDescriptorReference ``` -------------------------------- ### Create a new Run Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Initializes a new Run instance with a tool name and information URI. ```go func NewRunWithInformationURI(toolName, informationURI string) *Run ``` -------------------------------- ### Add Guid to ReportingDescriptor Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Use WithGuid to add a Guid to the ReportingDescriptor. This method returns the updated ReportingDescriptor. ```go func (g *ReportingDescriptor) WithGuid(guid *Guid) *ReportingDescriptor ``` -------------------------------- ### Create New Exception Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Initializes a new Exception instance. ```go func NewException() *Exception ``` -------------------------------- ### Set Start Column for Region Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Sets the starting column of a Region. Useful for precise code location. ```go func (s *Region) WithStartColumn(startColumn int) *Region ``` -------------------------------- ### Manage WebResponse Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Methods to instantiate and configure a WebResponse object. ```go func NewWebResponse() *WebResponse ``` ```go func (h *WebResponse) AddHeader(key, header string) *WebResponse ``` -------------------------------- ### Add Guid to Suppression Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Method to add a Guid to an existing Suppression object. Returns the modified Suppression pointer for chaining. ```go func (g *Suppression) WithGuid(guid *Guid) *Suppression ``` -------------------------------- ### Create new RunAutomationDetails Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Constructor function for initializing a new RunAutomationDetails instance. ```go func NewRunAutomationDetails() *RunAutomationDetails ``` -------------------------------- ### Add Deprecated GUID to ReportingDescriptor Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Appends a GUID that was used to identify this report in previous versions. Useful for maintaining backward compatibility. ```go func (d *ReportingDescriptor) AddDeprecatedGuid(deprecatedGuid string) *ReportingDescriptor ``` -------------------------------- ### Create a new SARIF report in Go Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3 Demonstrates initializing a report, adding a run with rules, and defining results with physical locations. Ensure the appropriate report version package is imported. ```go import ( "github.com/owenrumney/go-sarif/v3/pkg/report" "github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif" ) ... // create the basic report shell rep := report.NewV22Report() // create a run run := sarif.NewRunWithInformationURI("my tool", "https://mytool.com") // create a failed Rule run.AddRule("rule#1"). WithDescription("This rule is a really important one"). WithHelpURI("https://mytool.com/rules/rule1"). WithMarkdownHelp("# Try not to make this mistake") // add the location an artifact run.AddDistinctArtifact("file:///Users/me/code/myCode/terraform/main.tf") // crete a result for the rule run.CreateResultForRule("rule#1"). WithLevel("high"). WithMessage(sarif.NewTextMessage("This rule was breached in the file")). AddLocation( sarif.NewLocationWithPhysicalLocation( sarif.NewPhysicalLocation(). WithArtifactLocation( sarif.NewSimpleArtifactLocation("file:///Users/me/code/myCode/terraform/main.tf") ).WithRegion( // set the line numbers of the issue sarif.NewSimpleRegion(1, 4) ), ), ) // add the run to the report rep.AddRun(run) // validate the report if err := rep.Validate(); err != nil { println(err) } ``` -------------------------------- ### Manage WebRequest Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Methods to instantiate and configure a WebRequest object. ```go func NewWebRequest() *WebRequest ``` ```go func (h *WebRequest) AddHeader(key, header string) *WebRequest ``` ```go func (p *WebRequest) AddParameter(key, parameter string) *WebRequest ``` ```go func (b *WebRequest) WithBody(body *ArtifactContent) *WebRequest ``` ```go func (h *WebRequest) WithHeaders(headers map[string]string) *WebRequest ``` ```go func (i *WebRequest) WithIndex(index int) *WebRequest ``` ```go func (m *WebRequest) WithMethod(method string) *WebRequest ``` ```go func (p *WebRequest) WithParameters(parameters map[string]string) *WebRequest ``` ```go func (p *WebRequest) WithProperties(properties *PropertyBag) *WebRequest ``` ```go func (p *WebRequest) WithProtocol(protocol string) *WebRequest ``` ```go func (t *WebRequest) WithTarget(target string) *WebRequest ``` ```go func (v *WebRequest) WithVersion(version string) *WebRequest ``` -------------------------------- ### Set Last Detection Run GUID for ResultProvenance Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Use WithLastDetectionRunGuID to set the GUID of the run where the result was last detected. This method returns the ResultProvenance pointer for chaining. ```go func (l *ResultProvenance) WithLastDetectionRunGuID(lastDetectionRunGuid string) *ResultProvenance ``` -------------------------------- ### Set First Detection Run GUID for ResultProvenance Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Use WithFirstDetectionRunGuID to set the GUID of the run where the result was first detected. This method returns the ResultProvenance pointer for chaining. ```go func (f *ResultProvenance) WithFirstDetectionRunGuID(firstDetectionRunGuid string) *ResultProvenance ``` -------------------------------- ### Address builder methods Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Methods for initializing and configuring an Address object. ```go func NewAddress() *Address ``` ```go func (a *Address) WithAbsoluteAddress(absoluteAddress int) *Address ``` ```go func (f *Address) WithFullyQualifiedName(fullyQualifiedName string) *Address ``` ```go func (i *Address) WithIndex(index int) *Address ``` ```go func (k *Address) WithKind(kind string) *Address ``` ```go func (l *Address) WithLength(length int) *Address ``` ```go func (n *Address) WithName(name string) *Address ``` ```go func (o *Address) WithOffsetFromParent(offsetFromParent int) *Address ``` ```go func (p *Address) WithParentIndex(parentIndex int) *Address ``` ```go func (p *Address) WithProperties(properties *PropertyBag) *Address ``` ```go func (r *Address) WithRelativeAddress(relativeAddress int) *Address ``` -------------------------------- ### Initialize Region Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Functions to create new Region instances. ```go func NewRegion() *Region ``` ```go func NewSimpleRegion(startLine, endLine int) *Region ``` -------------------------------- ### NewWebResponse Constructor - Go Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Creates a new instance of WebResponse. Use this to initialize a WebResponse object. ```go func NewWebResponse() *WebResponse ``` -------------------------------- ### WithGuid method for Result Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Adds a Guid to the Result. ```go func (g *Result) WithGuid(guid *Guid) *Result ``` -------------------------------- ### Configure Run properties Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Methods to set various properties on a Run instance. ```go func (a *Run) WithAddresses(addresses []*Address) *Run ``` ```go func (a *Run) WithArtifacts(artifacts []*Artifact) *Run ``` ```go func (a *Run) WithAutomationDetails(automationDetails *RunAutomationDetails) *Run ``` ```go func (b *Run) WithBaselineGuID(baselineGuid string) *Run ``` ```go func (c *Run) WithColumnKind(columnKind string) *Run ``` ```go func (c *Run) WithConversion(conversion *Conversion) *Run ``` -------------------------------- ### ToolComponent Initialization and Configuration Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Methods for creating a new ToolComponent instance and configuring its various attributes. ```APIDOC ## NewToolComponent ### Description Creates a new instance of a ToolComponent. ### Method Constructor ## AddContent ### Description Adds a single content string to the ToolComponent. ### Parameters - **content** (string) - Required - The content to add. ## AddRule ### Description Adds a single rule (ReportingDescriptor) to the ToolComponent. ### Parameters - **rule** (*ReportingDescriptor) - Required - The rule to add. ## WithFullName ### Description Sets the full name of the ToolComponent. ### Parameters - **fullName** (string) - Required - The full name of the component. ## WithGuid ### Description Sets the GUID for the ToolComponent. ### Parameters - **guid** (*Guid) - Required - The GUID object. ``` -------------------------------- ### Set Response Files for Invocation Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Use WithResponseFiles to add ResponseFiles to the Invocation. ```go func (r *Invocation) WithResponseFiles(responseFiles []*ArtifactLocation) *Invocation ``` -------------------------------- ### Configure RunAutomationDetails Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Methods to set various fields on a RunAutomationDetails object. ```go func (c *RunAutomationDetails) WithCorrelationGuID(correlationGuid string) *RunAutomationDetails ``` ```go func (d *RunAutomationDetails) WithDescription(description *Message) *RunAutomationDetails ``` ```go func (g *RunAutomationDetails) WithGuID(guid string) *RunAutomationDetails ``` ```go func (i *RunAutomationDetails) WithID(id string) *RunAutomationDetails ``` ```go func (p *RunAutomationDetails) WithProperties(properties *PropertyBag) *RunAutomationDetails ``` -------------------------------- ### Configure ExternalPropertyFileReference fields Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Builder methods for setting the GUID, item count, location, and properties of an ExternalPropertyFileReference. ```go func (g *ExternalPropertyFileReference) WithGuID(guid string) *ExternalPropertyFileReference ``` ```go func (i *ExternalPropertyFileReference) WithItemCount(itemCount int) *ExternalPropertyFileReference ``` ```go func (l *ExternalPropertyFileReference) WithLocation(location *ArtifactLocation) *ExternalPropertyFileReference ``` ```go func (p *ExternalPropertyFileReference) WithProperties(properties *PropertyBag) *ExternalPropertyFileReference ``` -------------------------------- ### Run Configuration Methods Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Methods for configuring the Run object by adding various components and properties. ```APIDOC ## WithDefaultEncoding /api/run ### Description Adds a default encoding to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **defaultEncoding** (string) - Required - The default encoding to set for the run. ### Request Example ```json { "defaultEncoding": "UTF-8" } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithDefaultSourceLanguage /api/run ### Description Adds a default source language to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **defaultSourceLanguage** (string) - Required - The default source language to set for the run. ### Request Example ```json { "defaultSourceLanguage": "en-US" } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithExternalPropertyFileReferences /api/run ### Description Adds external property file references to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **externalPropertyFileReferences** (*ExternalPropertyFileReferences) - Required - The external property file references to add. ### Request Example ```json { "externalPropertyFileReferences": { ... } } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithGraphs /api/run ### Description Adds graphs to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **graphs** ([]*Graph) - Required - The graphs to add. ### Request Example ```json { "graphs": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithInvocations /api/run ### Description Adds invocations to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **invocations** ([]*Invocation) - Required - The invocations to add. ### Request Example ```json { "invocations": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithLanguage /api/run ### Description Adds language information to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **language** (*Language) - Required - The language object to add. ### Request Example ```json { "language": { ... } } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithLogicalLocations /api/run ### Description Adds logical locations to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **logicalLocations** ([]*LogicalLocation) - Required - The logical locations to add. ### Request Example ```json { "logicalLocations": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithNewlineSequences /api/run ### Description Adds newline sequences to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **newlineSequences** ([]string) - Required - The newline sequences to add. ### Request Example ```json { "newlineSequences": [ "\n", "\r\n" ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithOriginalUriBaseIds /api/run (v3.1.2+) ### Description Adds original URI base IDs to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **originalUriBaseIds** (map[string]ArtifactLocation) - Required - The map of original URI base IDs to add. ### Request Example ```json { "originalUriBaseIds": { "MY_ROOT": { ... } } } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithPolicies /api/run ### Description Adds tool policies to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **policies** ([]*ToolComponent) - Required - The tool components representing policies to add. ### Request Example ```json { "policies": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithProperties /api/run ### Description Adds properties to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **properties** (*PropertyBag) - Required - The property bag to add. ### Request Example ```json { "properties": { ... } } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithRedactionTokens /api/run ### Description Adds redaction tokens to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **redactionTokens** ([]string) - Required - The redaction tokens to add. ### Request Example ```json { "redactionTokens": [ "token1", "token2" ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithResults /api/run ### Description Adds results to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **results** ([]*Result) - Required - The results to add. ### Request Example ```json { "results": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithRunAggregates /api/run ### Description Adds run aggregates to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **runAggregates** ([]*RunAutomationDetails) - Required - The run automation details to add. ### Request Example ```json { "runAggregates": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithSpecialLocations /api/run ### Description Adds special locations to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **specialLocations** (*SpecialLocations) - Required - The special locations object to add. ### Request Example ```json { "specialLocations": { ... } } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithTaxonomies /api/run ### Description Adds tool taxonomies to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **taxonomies** ([]*ToolComponent) - Required - The tool components representing taxonomies to add. ### Request Example ```json { "taxonomies": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithThreadFlowLocations /api/run ### Description Adds thread flow locations to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **threadFlowLocations** ([]*ThreadFlowLocation) - Required - The thread flow locations to add. ### Request Example ```json { "threadFlowLocations": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithTool /api/run ### Description Adds tool information to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **tool** (*Tool) - Required - The tool object to add. ### Request Example ```json { "tool": { ... } } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithTranslations /api/run ### Description Adds tool translations to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **translations** ([]*ToolComponent) - Required - The tool components representing translations to add. ### Request Example ```json { "translations": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithVersionControlProvenance /api/run ### Description Adds version control provenance to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **versionControlProvenance** ([]*VersionControlDetails) - Required - The version control details to add. ### Request Example ```json { "versionControlProvenance": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithWebRequests /api/run ### Description Adds web requests to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **webRequests** ([]*WebRequest) - Required - The web requests to add. ### Request Example ```json { "webRequests": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` ```APIDOC ## WithWebResponses /api/run ### Description Adds web responses to the Run object. ### Method POST ### Endpoint /api/run ### Parameters #### Request Body - **webResponses** ([]*WebResponse) - Required - The web responses to add. ### Request Example ```json { "webResponses": [ { ... }, { ... } ] } ``` ### Response #### Success Response (200) - **Run** (*Run) - The updated Run object. #### Response Example ```json { "run": { ... } } ``` ``` -------------------------------- ### Add components to a Run Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Methods to add individual components to a Run instance. ```go func (a *Run) AddAddresse(addresse *Address) *Run ``` ```go func (a *Run) AddArtifact(artifact *Artifact) *Run ``` ```go func (run *Run) AddDistinctArtifact(uri string) *Artifact ``` ```go func (g *Run) AddGraph(graph *Graph) *Run ``` ```go func (i *Run) AddInvocation(invocation *Invocation) *Run ``` ```go func (l *Run) AddLogicalLocation(logicalLocation *LogicalLocation) *Run ``` ```go func (n *Run) AddNewlineSequence(newlineSequence string) *Run ``` ```go func (o *Run) AddOriginalUriBaseId(key string, originalUriBaseId ArtifactLocation) *Run ``` ```go func (p *Run) AddPolicie(policie *ToolComponent) *Run ``` ```go func (r *Run) AddRedactionToken(redactionToken string) *Run ``` ```go func (r *Run) AddResult(result *Result) *Run ``` ```go func (run *Run) AddRule(ruleID string) *ReportingDescriptor ``` ```go func (r *Run) AddRunAggregate(runAggregate *RunAutomationDetails) *Run ``` ```go func (t *Run) AddTaxonomie(taxonomie *ToolComponent) *Run ``` ```go func (t *Run) AddThreadFlowLocation(threadFlowLocation *ThreadFlowLocation) *Run ``` ```go func (t *Run) AddTranslation(translation *ToolComponent) *Run ``` ```go func (v *Run) AddVersionControlProvenance(versionControlProvenance *VersionControlDetails) *Run ``` ```go func (w *Run) AddWebRequest(webRequest *WebRequest) *Run ``` ```go func (w *Run) AddWebResponse(webResponse *WebResponse) *Run ``` -------------------------------- ### Suppression Type Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Defines a suppression that is relevant to a result, including its GUID, justification, kind, location, properties, and status. ```APIDOC ## Suppression Type ### Description A suppression that is relevant to a result. ### Fields - **Guid** (*Guid) - A stable, unique identifier for the suppression in the form of a GUID. - **Justification** (*string) - A string representing the justification for the suppression. - **Kind** (*string) - A string that indicates where the suppression is persisted. - **Location** (*Location) - Identifies the location associated with the suppression. - **Properties** (*PropertyBag) - Key/value pairs that provide additional information about the suppression. - **Status** (*string) - A string that indicates the review status of the suppression. ### Constructor ```go func NewSuppression() *Suppression ``` Creates a new Suppression object. ### Methods - **WithGuid(guid *Guid) *Suppression**: Adds a GUID to the Suppression. - **WithJustification(justification string) *Suppression**: Adds a justification to the Suppression. - **WithKind(kind string) *Suppression**: Adds a kind to the Suppression. - **WithLocation(location *Location) *Suppression**: Adds a location to the Suppression. - **WithProperties(properties *PropertyBag) *Suppression**: Adds properties to the Suppression. - **WithStatus(status string) *Suppression**: Adds a status to the Suppression. ``` -------------------------------- ### Create New ToolComponentReference Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Creates a new, empty ToolComponentReference. Use its With methods to populate fields. ```go func NewToolComponentReference() *ToolComponentReference ``` -------------------------------- ### ExternalPropertyFileReference Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Represents a reference to an external property file, allowing configuration of its GUID, item count, location, and properties. ```APIDOC ## ExternalPropertyFileReference ### Description Represents a reference to an external property file. ### Methods - `NewExternalPropertyFileReference()`: Constructor for `ExternalPropertyFileReference`. - `WithGuID(guid string)`: Sets the GUID for the external property file reference. - `WithItemCount(itemCount int)`: Sets the item count for the external property file reference. - `WithLocation(location *ArtifactLocation)`: Sets the artifact location for the external property file reference. - `WithProperties(properties *PropertyBag)`: Sets the property bag for the external property file reference. ``` -------------------------------- ### Run Construction Methods Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Methods for initializing a new Run object. ```APIDOC ## NewRun ### Description Creates a new Run object. ## NewRunWithInformationURI ### Description Creates a new Run and returns a pointer to it. ### Parameters #### Request Body - **toolName** (string) - Required - **informationURI** (string) - Required ``` -------------------------------- ### Create New LocationRelationship Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Creates a new, empty LocationRelationship object. Use this as a starting point before populating its fields. ```go func NewLocationRelationship() *LocationRelationship ``` -------------------------------- ### WebRequest.WithMethod - Go Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Sets the HTTP method for the WebRequest. Use to specify the request type (e.g., GET, POST). ```go func (m *WebRequest) WithMethod(method string) *WebRequest ``` -------------------------------- ### Configure Run properties Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Methods to add various components and metadata to a Run object. ```go func (d *Run) WithDefaultEncoding(defaultEncoding string) *Run ``` ```go func (d *Run) WithDefaultSourceLanguage(defaultSourceLanguage string) *Run ``` ```go func (e *Run) WithExternalPropertyFileReferences(externalPropertyFileReferences *ExternalPropertyFileReferences) *Run ``` ```go func (g *Run) WithGraphs(graphs []*Graph) *Run ``` ```go func (i *Run) WithInvocations(invocations []*Invocation) *Run ``` ```go func (l *Run) WithLanguage(language string) *Run ``` ```go func (l *Run) WithLogicalLocations(logicalLocations []*LogicalLocation) *Run ``` ```go func (n *Run) WithNewlineSequences(newlineSequences []string) *Run ``` ```go func (o *Run) WithOriginalUriBaseIds(originalUriBaseIds map[string]ArtifactLocation) *Run ``` ```go func (p *Run) WithPolicies(policies []*ToolComponent) *Run ``` ```go func (p *Run) WithProperties(properties *PropertyBag) *Run ``` ```go func (r *Run) WithRedactionTokens(redactionTokens []string) *Run ``` ```go func (r *Run) WithResults(results []*Result) *Run ``` ```go func (r *Run) WithRunAggregates(runAggregates []*RunAutomationDetails) *Run ``` ```go func (s *Run) WithSpecialLocations(specialLocations *SpecialLocations) *Run ``` ```go func (t *Run) WithTaxonomies(taxonomies []*ToolComponent) *Run ``` ```go func (t *Run) WithThreadFlowLocations(threadFlowLocations []*ThreadFlowLocation) *Run ``` ```go func (t *Run) WithTool(tool *Tool) *Run ``` ```go func (t *Run) WithTranslations(translations []*ToolComponent) *Run ``` ```go func (v *Run) WithVersionControlProvenance(versionControlProvenance []*VersionControlDetails) *Run ``` ```go func (w *Run) WithWebRequests(webRequests []*WebRequest) *Run ``` ```go func (w *Run) WithWebResponses(webResponses []*WebResponse) *Run ``` -------------------------------- ### Create a Result for a Rule in a SARIF Run Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Use CreateResultForRule to get an existing Result for a ruleID or create a new one. ```go func (run *Run) CreateResultForRule(ruleID string) *Result ``` -------------------------------- ### NewWebRequest Constructor - Go Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Creates a new instance of WebRequest. Use this to initialize a WebRequest object. ```go func NewWebRequest() *WebRequest ``` -------------------------------- ### ReportingDescriptorReference Struct Definition Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Defines a reference to a reporting descriptor, including its GUID, ID, index, properties, and associated tool component. ```go type ReportingDescriptorReference struct { // A guid that uniquely identifies the descriptor. Guid *Guid `json:"guid,omitempty"` // The id of the descriptor. ID *string `json:"id,omitempty"` // The index into an array of descriptors in toolComponent.ruleDescriptors, toolComponent.notificationDescriptors, or toolComponent.taxonomyDescriptors, depending on context. Index int `json:"index"` // Key/value pairs that provide additional information about the reporting descriptor reference. Properties *PropertyBag `json:"properties,omitempty"` // A reference used to locate the toolComponent associated with the descriptor. ToolComponent *ToolComponentReference `json:"toolComponent,omitempty"` } ``` -------------------------------- ### WebRequest.WithParameters - Go Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Sets all parameters for the WebRequest. Use this to provide a complete map of parameters. ```go func (p *WebRequest) WithParameters(parameters map[string]string) *WebRequest ``` -------------------------------- ### Define ExternalPropertyFileReference struct Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Represents a reference to an external property file, including its GUID, item count, location, and additional properties. ```go type ExternalPropertyFileReference struct { // A stable, unique identifier for the external property file in the form of a GUID. GuID *string `json:"guid,omitempty"` // A non-negative integer specifying the number of items contained in the external property file. ItemCount int `json:"itemCount"` // The location of the external property file. Location *ArtifactLocation `json:"location,omitempty"` // Key/value pairs that provide additional information about the external property file. Properties *PropertyBag `json:"properties,omitempty"` } ``` -------------------------------- ### Create New ReportingConfiguration Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Creates and returns a new, empty ReportingConfiguration object. ```go func NewReportingConfiguration() *ReportingConfiguration ``` -------------------------------- ### Create New ResultProvenance Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Use NewResultProvenance to create a new, empty ResultProvenance object. This is the starting point for building provenance data. ```go func NewResultProvenance() *ResultProvenance ``` -------------------------------- ### Initialize TranslationMetadata Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Creates a new instance of TranslationMetadata. ```go func NewTranslationMetadata() *TranslationMetadata ``` -------------------------------- ### Example SARIF report structure Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3 A sample JSON representation of a SARIF 2.1.0 report containing a tool driver, rules, and a result. ```json { "version": "2.1.0", "$schema": "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json", "runs": [ { "tool": { "driver": { "name": "ESLint", "informationUri": "https://eslint.org", "language": "en-US", "rules": [ { "id": "no-unused-vars", "shortDescription": { "text": "disallow unused variables" }, "helpUri": "https://eslint.org/docs/rules/no-unused-vars", "properties": { "category": "Variables" } } ] } }, "language": "en-US", "newlineSequences": ["\r\n", "\n"], "artifacts": [ { "location": { "uri": "file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js" } } ], "results": [ { "level": "error", "message": { "text": "'x' is assigned a value but never used." }, "locations": [ { "physicalLocation": { "artifactLocation": { "uri": "file:///C:/dev/sarif/sarif-tutorials/samples/Introduction/simple-example.js", "index": 0 }, "region": { "startLine": 1, "startColumn": 5 } } } ], "ruleId": "no-unused-vars", "ruleIndex": 0 } ] } ] } ``` -------------------------------- ### NewRunAutomationDetails Constructor Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Constructor for creating a new RunAutomationDetails object. ```APIDOC ## NewRunAutomationDetails ### Description Creates a new RunAutomationDetails object. ### Method POST ### Endpoint /api/run/automationDetails ### Response #### Success Response (200) - **RunAutomationDetails** (*RunAutomationDetails) - A new, empty RunAutomationDetails object. #### Response Example ```json { "runAutomationDetails": { ... } } ``` ``` -------------------------------- ### Configure Replacement properties Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Fluent builder methods for setting properties on a Replacement instance. ```go func (d *Replacement) WithDeletedRegion(deletedRegion *Region) *Replacement ``` ```go func (i *Replacement) WithInsertedContent(insertedContent *ArtifactContent) *Replacement ``` ```go func (p *Replacement) WithProperties(properties *PropertyBag) *Replacement ``` -------------------------------- ### Create New Invocation Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Use NewInvocation to create a new, empty Invocation object. This is the starting point for configuring an analysis tool run. ```go func NewInvocation() *Invocation ``` -------------------------------- ### Configure VersionControlDetails Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Fluent methods to set repository URI, revision ID, and revision tag on a VersionControlDetails object. ```go func (r *VersionControlDetails) WithRepositoryURI(repositoryUri string) *VersionControlDetails ``` ```go func (r *VersionControlDetails) WithRevisionID(revisionId string) *VersionControlDetails ``` ```go func (r *VersionControlDetails) WithRevisionTag(revisionTag string) *VersionControlDetails ``` -------------------------------- ### Define SARIF Report Structure Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Defines the structure for a SARIF report, including schema version, runs, external properties, GUID, and custom properties. ```go type Report struct { // The URI of the JSON schema corresponding to the version. Schema string `json:"$schema"` // The SARIF format version of this log file. Version string `json:"version"` // The set of runs contained in this log file. Runs []*Run `json:"runs,omitempty"` // References to external property files that should be inlined with the content of a root log file. InlineExternalProperties []*ExternalProperties `json:"inlineExternalProperties,omitempty"` // A stable, unique identifier for the report in the form of a GUID. Guid Guid `json:"guid"` // Key/value pairs that provide additional information about the report. Properties *PropertyBag `json:"properties,omitempty"` } ``` -------------------------------- ### WebRequest.WithHeaders - Go Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Sets all headers for the WebRequest. Use this to provide a complete map of headers. ```go func (h *WebRequest) WithHeaders(headers map[string]string) *WebRequest ``` -------------------------------- ### Set Absolute Address for Address Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Adds or updates the AbsoluteAddress field for an Address object. This represents the address as a byte offset from the start of the addressable region. ```go func (a *Address) WithAbsoluteAddress(absoluteAddress int) *Address ``` -------------------------------- ### Get Rule Index in a SARIF Run Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v22/sarif Use GetRuleIndex to retrieve the index of a rule with the given ID. Returns -1 if the rule does not exist. Added in v3.2.0. ```go func (run *Run) GetRuleIndex(ruleID string) int ``` -------------------------------- ### Set Account for Invocation Source: https://pkg.go.dev/github.com/owenrumney/go-sarif/v3/pkg/report/v210/sarif Use WithAccount to add an Account to the Invocation. ```go func (a *Invocation) WithAccount(account string) *Invocation ```