2022-02-23 10:30:19 +02:00
|
|
|
package format
|
|
|
|
|
2022-07-21 11:15:55 +02:00
|
|
|
const AUDIT_REQUIREMENT_GROUP_1_INDEX = 1
|
|
|
|
const AUDIT_REQUIREMENT_GROUP_2_INDEX = 2
|
|
|
|
const AUDIT_REQUIREMENT_GROUP_3_INDEX = 3
|
|
|
|
const AUDIT_REQUIREMENT_GROUP_1_DESC = "Audit All"
|
|
|
|
const AUDIT_REQUIREMENT_GROUP_2_DESC = "Spot Check"
|
|
|
|
const AUDIT_REQUIREMENT_GROUP_3_DESC = "Optional"
|
|
|
|
|
2022-02-23 10:30:19 +02:00
|
|
|
// SARIF format related JSON structs
|
|
|
|
type SARIF struct {
|
2022-03-22 15:47:19 +02:00
|
|
|
Schema string `json:"$schema" default:"https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json"`
|
2022-02-23 10:30:19 +02:00
|
|
|
Version string `json:"version" default:"2.1.0"`
|
|
|
|
Runs []Runs `json:"runs"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Runs of a Tool and related Results
|
|
|
|
type Runs struct {
|
2022-03-17 14:09:15 +02:00
|
|
|
Results []Results `json:"results"`
|
|
|
|
Tool Tool `json:"tool"`
|
2022-06-16 15:24:23 +02:00
|
|
|
Invocations []Invocation `json:"invocations,omitempty"`
|
2022-03-17 14:09:15 +02:00
|
|
|
OriginalUriBaseIds *OriginalUriBaseIds `json:"originalUriBaseIds,omitempty"`
|
|
|
|
Artifacts []Artifact `json:"artifacts,omitempty"`
|
2022-10-10 10:06:20 +02:00
|
|
|
AutomationDetails *AutomationDetails `json:"automationDetails,omitempty"`
|
2022-03-17 14:09:15 +02:00
|
|
|
ColumnKind string `json:"columnKind,omitempty" default:"utf16CodeUnits"`
|
|
|
|
ThreadFlowLocations []Locations `json:"threadFlowLocations,omitempty"`
|
|
|
|
Taxonomies []Taxonomies `json:"taxonomies,omitempty"`
|
2022-06-16 15:24:23 +02:00
|
|
|
Conversion *Conversion `json:"conversion,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Results these structs are relevant to the Results object
|
|
|
|
type Results struct {
|
2022-05-11 17:05:51 +02:00
|
|
|
RuleID string `json:"ruleId"`
|
2022-10-10 10:06:20 +02:00
|
|
|
RuleIndex int `json:"ruleIndex,omitempty"`
|
2022-05-24 13:40:49 +02:00
|
|
|
Kind string `json:"kind,omitempty"`
|
2022-05-11 17:05:51 +02:00
|
|
|
Level string `json:"level,omitempty"`
|
|
|
|
Message *Message `json:"message,omitempty"`
|
|
|
|
AnalysisTarget *ArtifactLocation `json:"analysisTarget,omitempty"`
|
|
|
|
Locations []Location `json:"locations,omitempty"`
|
|
|
|
CodeFlows []CodeFlow `json:"codeFlows,omitempty"`
|
|
|
|
RelatedLocations []RelatedLocation `json:"relatedLocations,omitempty"`
|
2022-10-10 10:06:20 +02:00
|
|
|
PartialFingerprints PartialFingerprints `json:"partialFingerprints,omitempty"`
|
|
|
|
Properties *SarifProperties `json:"properties,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Message to detail the finding
|
|
|
|
type Message struct {
|
|
|
|
Text string `json:"text,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Location of the finding
|
|
|
|
type Location struct {
|
2022-03-14 12:26:05 +02:00
|
|
|
PhysicalLocation PhysicalLocation `json:"physicalLocation"`
|
|
|
|
Message *Message `json:"message,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// PhysicalLocation
|
|
|
|
type PhysicalLocation struct {
|
|
|
|
ArtifactLocation ArtifactLocation `json:"artifactLocation"`
|
|
|
|
Region Region `json:"region"`
|
2022-06-22 08:54:24 +02:00
|
|
|
ContextRegion *ContextRegion `json:"contextRegion,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
LogicalLocations []LogicalLocation `json:"logicalLocations,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// ArtifactLocation describing the path of the artifact
|
|
|
|
type ArtifactLocation struct {
|
2022-05-11 17:05:51 +02:00
|
|
|
URI string `json:"uri"`
|
2022-05-19 14:57:13 +02:00
|
|
|
URIBaseId string `json:"uriBaseId,omitempty"`
|
|
|
|
Index int `json:"index,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Region where the finding was detected
|
|
|
|
type Region struct {
|
2022-03-22 15:47:19 +02:00
|
|
|
StartLine int `json:"startLine,omitempty"`
|
|
|
|
StartColumn int `json:"startColumn,omitempty"`
|
|
|
|
EndLine int `json:"endLine,omitempty"`
|
|
|
|
EndColumn int `json:"endColumn,omitempty"`
|
|
|
|
ByteOffset int `json:"byteOffset,omitempty"`
|
|
|
|
ByteLength int `json:"byteLength,omitempty"`
|
|
|
|
Snippet *SnippetSarif `json:"snippet,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// LogicalLocation of the finding
|
|
|
|
type LogicalLocation struct {
|
|
|
|
FullyQualifiedName string `json:"fullyQualifiedName"`
|
|
|
|
}
|
|
|
|
|
2022-05-11 17:05:51 +02:00
|
|
|
// PartialFingerprints
|
|
|
|
type PartialFingerprints struct {
|
|
|
|
FortifyInstanceID string `json:"fortifyInstanceID,omitempty"`
|
|
|
|
CheckmarxSimilarityID string `json:"checkmarxSimilarityID,omitempty"`
|
|
|
|
PrimaryLocationLineHash string `json:"primaryLocationLineHash,omitempty"`
|
2022-08-11 13:12:14 +02:00
|
|
|
PackageURLPlusCVEHash string `json:"packageUrlPlusCveHash,omitempty"`
|
2022-05-11 17:05:51 +02:00
|
|
|
}
|
|
|
|
|
2022-02-23 10:30:19 +02:00
|
|
|
// SarifProperties adding additional information/context to the finding
|
|
|
|
type SarifProperties struct {
|
2022-07-21 11:15:55 +02:00
|
|
|
// common
|
2022-06-17 08:53:44 +02:00
|
|
|
RuleGUID string `json:"ruleGUID,omitempty"`
|
2022-04-04 16:12:35 +02:00
|
|
|
InstanceID string `json:"instanceID,omitempty"`
|
|
|
|
Audited bool `json:"audited"`
|
|
|
|
ToolSeverity string `json:"toolSeverity"`
|
|
|
|
ToolSeverityIndex int `json:"toolSeverityIndex"`
|
|
|
|
ToolState string `json:"toolState"`
|
|
|
|
ToolStateIndex int `json:"toolStateIndex"`
|
|
|
|
ToolAuditMessage string `json:"toolAuditMessage"`
|
|
|
|
UnifiedAuditState string `json:"unifiedAuditState"`
|
2022-07-21 11:15:55 +02:00
|
|
|
AuditRequirement string `json:"auditRequirement"`
|
|
|
|
AuditRequirementIndex int `json:"auditRequirementIndex"`
|
|
|
|
|
|
|
|
// specific
|
|
|
|
InstanceSeverity string `json:"instanceSeverity"`
|
|
|
|
Confidence string `json:"confidence"`
|
|
|
|
FortifyCategory string `json:"fortifyCategory"`
|
|
|
|
CheckmarxSimilarityID string `json:"checkmarxSimilarityID"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Tool these structs are relevant to the Tool object
|
|
|
|
type Tool struct {
|
2022-05-24 13:40:49 +02:00
|
|
|
Driver Driver `json:"driver"`
|
2022-06-09 10:32:08 +02:00
|
|
|
Extensions []Driver `json:"extensions,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Driver meta information for the scan and tool context
|
|
|
|
type Driver struct {
|
2022-03-14 12:26:05 +02:00
|
|
|
Name string `json:"name"`
|
2022-06-16 15:24:23 +02:00
|
|
|
Version string `json:"version,omitempty"`
|
2022-05-24 13:40:49 +02:00
|
|
|
GUID string `json:"guid,omitempty"`
|
2022-03-14 12:26:05 +02:00
|
|
|
InformationUri string `json:"informationUri,omitempty"`
|
2022-05-24 13:40:49 +02:00
|
|
|
Rules []SarifRule `json:"rules,omitempty"`
|
2022-03-17 14:09:15 +02:00
|
|
|
SupportedTaxonomies []SupportedTaxonomies `json:"supportedTaxonomies,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// SarifRule related rule use to identify the finding
|
|
|
|
type SarifRule struct {
|
2022-03-17 14:09:15 +02:00
|
|
|
ID string `json:"id"`
|
|
|
|
GUID string `json:"guid,omitempty"`
|
|
|
|
Name string `json:"name,omitempty"`
|
|
|
|
ShortDescription *Message `json:"shortDescription,omitempty"`
|
|
|
|
FullDescription *Message `json:"fullDescription,omitempty"`
|
|
|
|
DefaultConfiguration *DefaultConfiguration `json:"defaultConfiguration,omitempty"`
|
|
|
|
HelpURI string `json:"helpUri,omitempty"`
|
|
|
|
Help *Help `json:"help,omitempty"`
|
|
|
|
Relationships []Relationships `json:"relationships,omitempty"`
|
|
|
|
Properties *SarifRuleProperties `json:"properties,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Help provides additional guidance to resolve the finding
|
|
|
|
type Help struct {
|
|
|
|
Text string `json:"text,omitempty"`
|
|
|
|
Markdown string `json:"markdown,omitempty"`
|
|
|
|
}
|
|
|
|
|
2022-03-14 12:26:05 +02:00
|
|
|
// SnippetSarif holds the code snippet where the finding appears
|
|
|
|
type SnippetSarif struct {
|
|
|
|
Text string `json:"text"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContextRegion provides the context for the finding
|
|
|
|
type ContextRegion struct {
|
2022-03-22 15:47:19 +02:00
|
|
|
StartLine int `json:"startLine,omitempty"`
|
|
|
|
EndLine int `json:"endLine,omitempty"`
|
|
|
|
Snippet *SnippetSarif `json:"snippet,omitempty"`
|
2022-03-14 12:26:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// CodeFlow
|
|
|
|
type CodeFlow struct {
|
|
|
|
ThreadFlows []ThreadFlow `json:"threadFlows"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// ThreadFlow
|
|
|
|
type ThreadFlow struct {
|
|
|
|
Locations []Locations `json:"locations"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Locations
|
|
|
|
type Locations struct {
|
|
|
|
Location *Location `json:"location,omitempty"`
|
|
|
|
Kinds []string `json:"kinds,omitempty"`
|
|
|
|
Index int `json:"index,omitempty"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// RelatedLocation
|
|
|
|
type RelatedLocation struct {
|
|
|
|
ID int `json:"id"`
|
|
|
|
PhysicalLocation RelatedPhysicalLocation `json:"physicalLocation"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// RelatedPhysicalLocation
|
|
|
|
type RelatedPhysicalLocation struct {
|
|
|
|
ArtifactLocation ArtifactLocation `json:"artifactLocation"`
|
|
|
|
Region RelatedRegion `json:"region"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// RelatedRegion
|
|
|
|
type RelatedRegion struct {
|
2022-05-11 17:05:51 +02:00
|
|
|
StartLine int `json:"startLine,omitempty"`
|
2022-03-14 12:26:05 +02:00
|
|
|
StartColumn int `json:"startColumn,omitempty"`
|
|
|
|
}
|
|
|
|
|
2022-02-23 10:30:19 +02:00
|
|
|
// SupportedTaxonomies
|
|
|
|
type SupportedTaxonomies struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Index int `json:"index"`
|
2022-03-14 12:26:05 +02:00
|
|
|
Guid string `json:"guid"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// DefaultConfiguration
|
|
|
|
type DefaultConfiguration struct {
|
2022-03-17 14:09:15 +02:00
|
|
|
Properties DefaultProperties `json:"properties,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
Level string `json:"level,omitempty"` //This exists in the template, but not sure how it is populated. TODO.
|
2022-05-24 13:40:49 +02:00
|
|
|
Enabled bool `json:"enabled,omitempty"`
|
|
|
|
Rank float64 `json:"rank,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
2022-03-14 12:26:05 +02:00
|
|
|
// DefaultProperties
|
2022-02-23 10:30:19 +02:00
|
|
|
type DefaultProperties struct {
|
2022-03-22 15:47:19 +02:00
|
|
|
DefaultSeverity string `json:"defaultSeverity,omitempty"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Relationships
|
|
|
|
type Relationships struct {
|
|
|
|
Target Target `json:"target"`
|
|
|
|
Kinds []string `json:"kinds"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Target
|
|
|
|
type Target struct {
|
2022-03-14 12:26:05 +02:00
|
|
|
Id string `json:"id"`
|
2022-02-23 10:30:19 +02:00
|
|
|
ToolComponent ToolComponent `json:"toolComponent"`
|
|
|
|
}
|
|
|
|
|
2022-03-14 12:26:05 +02:00
|
|
|
// ToolComponent
|
2022-02-23 10:30:19 +02:00
|
|
|
type ToolComponent struct {
|
|
|
|
Name string `json:"name"`
|
2022-03-14 12:26:05 +02:00
|
|
|
Guid string `json:"guid"`
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
|
|
|
|
2022-03-14 12:26:05 +02:00
|
|
|
//SarifRuleProperties
|
2022-02-23 10:30:19 +02:00
|
|
|
type SarifRuleProperties struct {
|
2022-05-24 13:40:49 +02:00
|
|
|
Accuracy string `json:"accuracy,omitempty"`
|
|
|
|
Impact string `json:"impact,omitempty"`
|
|
|
|
Probability string `json:"probability,omitempty"`
|
|
|
|
Tags []string `json:"tags,omitempty"`
|
|
|
|
Precision string `json:"precision,omitempty"`
|
|
|
|
SecuritySeverity string `json:"security-severity,omitempty"` //used by GHAS to defined the tag (low,medium,high)
|
2022-02-23 10:30:19 +02:00
|
|
|
}
|
2022-03-14 12:26:05 +02:00
|
|
|
|
2022-06-16 15:24:23 +02:00
|
|
|
// Invocation These structs are relevant to the Invocation object
|
|
|
|
type Invocation struct {
|
|
|
|
CommandLine string `json:"commandLine,omitempty"`
|
|
|
|
StartTimeUtc string `json:"startTimeUtc,omitempty"`
|
|
|
|
ToolExecutionNotifications []ToolExecutionNotifications `json:"toolExecutionNotifications,omitempty"`
|
2022-03-14 12:26:05 +02:00
|
|
|
ExecutionSuccessful bool `json:"executionSuccessful"`
|
2022-06-16 15:24:23 +02:00
|
|
|
Machine string `json:"machine,omitempty"`
|
|
|
|
Account string `json:"account,omitempty"`
|
|
|
|
Properties *InvocationProperties `json:"properties,omitempty"`
|
2022-03-14 12:26:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// ToolExecutionNotifications
|
|
|
|
type ToolExecutionNotifications struct {
|
|
|
|
Message Message `json:"message"`
|
|
|
|
Descriptor Descriptor `json:"descriptor"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Descriptor
|
|
|
|
type Descriptor struct {
|
|
|
|
Id string `json:"id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// InvocationProperties
|
|
|
|
type InvocationProperties struct {
|
2022-03-22 15:47:19 +02:00
|
|
|
Platform string `json:"platform"`
|
2022-03-14 12:26:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// OriginalUriBaseIds These structs are relevant to the originalUriBaseIds object
|
|
|
|
type OriginalUriBaseIds struct {
|
|
|
|
SrcRoot SrcRoot `json:"%SRCROOT%"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// SrcRoot
|
|
|
|
type SrcRoot struct {
|
|
|
|
Uri string `json:"uri"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Artifact These structs are relevant to the artifacts object
|
|
|
|
type Artifact struct {
|
|
|
|
Location SarifLocation `json:"location"`
|
2022-05-19 14:57:13 +02:00
|
|
|
Length int `json:"length,omitempty"`
|
|
|
|
MimeType string `json:"mimeType,omitempty"`
|
|
|
|
Encoding string `json:"encoding,omitempty"`
|
2022-03-14 12:26:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// SarifLocation
|
|
|
|
type SarifLocation struct {
|
|
|
|
Uri string `json:"uri"`
|
|
|
|
UriBaseId string `json:"uriBaseId"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// AutomationDetails These structs are relevant to the automationDetails object
|
|
|
|
type AutomationDetails struct {
|
|
|
|
Id string `json:"id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// These structs are relevant to the threadFlowLocations object
|
|
|
|
|
|
|
|
// Taxonomies These structs are relevant to the taxonomies object
|
|
|
|
type Taxonomies struct {
|
2022-04-04 16:12:35 +02:00
|
|
|
GUID string `json:"guid,omitempty"`
|
2022-03-14 12:26:05 +02:00
|
|
|
Name string `json:"name"`
|
|
|
|
Organization string `json:"organization"`
|
|
|
|
ShortDescription Message `json:"shortDescription"`
|
|
|
|
Taxa []Taxa `json:"taxa"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Taxa
|
|
|
|
type Taxa struct {
|
|
|
|
Id string `json:"id"`
|
|
|
|
}
|
2022-06-16 15:24:23 +02:00
|
|
|
|
|
|
|
// Conversion object
|
|
|
|
type Conversion struct {
|
|
|
|
Tool Tool `json:"tool,omitempty"`
|
|
|
|
Invocation Invocation `json:"invocation,omitempty"`
|
|
|
|
}
|