| 1 |
package sarif |
| 2 |
|
| 3 |
// Result represents the results block in the sarif report |
| 4 |
type Result struct { |
| 5 |
PropertyBag |
| 6 |
Guid *string `json:"guid,omitempty"` |
| 7 |
CorrelationGuid *string `json:"correlationGuid,omitempty"` |
| 8 |
RuleID *string `json:"ruleId,omitempty"` |
| 9 |
RuleIndex *uint `json:"ruleIndex,omitempty"` |
| 10 |
Rule *ReportingDescriptorReference `json:"rule,omitempty"` |
| 11 |
Taxa []*ReportingDescriptorReference `json:"taxa,omitempty"` |
| 12 |
Kind *string `json:"kind,omitempty"` |
| 13 |
Level *string `json:"level,omitempty"` |
| 14 |
Message Message `json:"message"` |
| 15 |
Locations []*Location `json:"locations,omitempty"` |
| 16 |
AnalysisTarget *ArtifactLocation `json:"analysisTarget,omitempty"` |
| 17 |
WebRequest *WebRequest `json:"webRequest,omitempty"` |
| 18 |
WebResponse *WebResponse `json:"webResponse,omitempty"` |
| 19 |
Fingerprints map[string]interface{} `json:"fingerprints,omitempty"` |
| 20 |
PartialFingerprints map[string]interface{} `json:"partialFingerprints,omitempty"` |
| 21 |
CodeFlows []*CodeFlow `json:"codeFlows,omitempty"` |
| 22 |
Graphs []*Graph `json:"graphs,omitempty"` |
| 23 |
GraphTraversals []*GraphTraversal `json:"graphTraversals,omitempty"` |
| 24 |
Stacks []*Stack `json:"stacks,omitempty"` |
| 25 |
RelatedLocations []*Location `json:"relatedLocations,omitempty"` |
| 26 |
Suppressions []*Suppression `json:"suppressions,omitempty"` |
| 27 |
BaselineState *string `json:"baselineState,omitempty"` |
| 28 |
Rank *float32 `json:"rank,omitempty"` |
| 29 |
Attachments []*Attachment `json:"attachments,omitempty"` |
| 30 |
WorkItemUris []string `json:"workItemUris,omitempty"` // can be null |
| 31 |
HostedViewerUri *string `json:"hostedViewerUri,omitempty"` |
| 32 |
Provenance *ResultProvenance `json:"provenance,omitempty"` |
| 33 |
Fixes []*Fix `json:"fixes,omitempty"` |
| 34 |
OccurrenceCount *uint `json:"occurrenceCount,omitempty"` |
| 35 |
} |
| 36 |
|
| 37 |
// NewRuleResult ... |
| 38 |
func NewRuleResult(ruleID string) *Result { |
| 39 |
return &Result{ |
| 40 |
RuleID: &ruleID, |
| 41 |
} |
| 42 |
} |
| 43 |
|
| 44 |
// WithGuid sets the Guid |
| 45 |
func (result *Result) WithGuid(guid string) *Result { |
| 46 |
result.Guid = &guid |
| 47 |
return result |
| 48 |
} |
| 49 |
|
| 50 |
// WithCorrelationGuid sets the CorrelationGuid |
| 51 |
func (result *Result) WithCorrelationGuid(correlationGuid string) *Result { |
| 52 |
result.CorrelationGuid = &correlationGuid |
| 53 |
return result |
| 54 |
} |
| 55 |
|
| 56 |
// WithRuleIndex sets the RuleIndex |
| 57 |
func (result *Result) WithRuleIndex(ruleIndex int) *Result { |
| 58 |
index := uint(ruleIndex) |
| 59 |
result.RuleIndex = &index |
| 60 |
return result |
| 61 |
} |
| 62 |
|
| 63 |
// WithRule sets the Rule |
| 64 |
func (result *Result) WithRule(rule *ReportingDescriptorReference) *Result { |
| 65 |
result.Rule = rule |
| 66 |
return result |
| 67 |
} |
| 68 |
|
| 69 |
// WithTaxa sets the Taxa |
| 70 |
func (result *Result) WithTaxa(taxa []*ReportingDescriptorReference) *Result { |
| 71 |
result.Taxa = taxa |
| 72 |
return result |
| 73 |
} |
| 74 |
|
| 75 |
// AddTaxa ... |
| 76 |
func (result *Result) AddTaxa(taxa *ReportingDescriptorReference) { |
| 77 |
result.Taxa = append(result.Taxa, taxa) |
| 78 |
} |
| 79 |
|
| 80 |
// WithKind sets the Kind |
| 81 |
func (result *Result) WithKind(kind string) *Result { |
| 82 |
result.Kind = &kind |
| 83 |
return result |
| 84 |
} |
| 85 |
|
| 86 |
// WithLevel sets the Level |
| 87 |
func (result *Result) WithLevel(level string) *Result { |
| 88 |
result.Level = &level |
| 89 |
return result |
| 90 |
} |
| 91 |
|
| 92 |
// WithMessage sets the Message |
| 93 |
func (result *Result) WithMessage(message *Message) *Result { |
| 94 |
result.Message = *message |
| 95 |
return result |
| 96 |
} |
| 97 |
|
| 98 |
// WithLocations sets the Locations |
| 99 |
func (result *Result) WithLocations(locations []*Location) *Result { |
| 100 |
result.Locations = locations |
| 101 |
return result |
| 102 |
} |
| 103 |
|
| 104 |
// AddLocation ... |
| 105 |
func (result *Result) AddLocation(location *Location) { |
| 106 |
result.Locations = append(result.Locations, location) |
| 107 |
} |
| 108 |
|
| 109 |
// WithAnalysisTarget sets the AnalysisTarget |
| 110 |
func (result *Result) WithAnalysisTarget(target *ArtifactLocation) *Result { |
| 111 |
result.AnalysisTarget = target |
| 112 |
return result |
| 113 |
} |
| 114 |
|
| 115 |
// WithFingerPrints sets the FingerPrints |
| 116 |
func (result *Result) WithFingerPrints(fingerPrints map[string]interface{}) *Result { |
| 117 |
result.Fingerprints = fingerPrints |
| 118 |
return result |
| 119 |
} |
| 120 |
|
| 121 |
// SetFingerPrint ... |
| 122 |
func (result *Result) SetFingerPrint(name string, value interface{}) { |
| 123 |
result.Fingerprints[name] = value |
| 124 |
} |
| 125 |
|
| 126 |
// WithPartialFingerPrints sets the PartialFingerPrints |
| 127 |
func (result *Result) WithPartialFingerPrints(fingerPrints map[string]interface{}) *Result { |
| 128 |
result.PartialFingerprints = fingerPrints |
| 129 |
return result |
| 130 |
} |
| 131 |
|
| 132 |
// SetPartialFingerPrint ... |
| 133 |
func (result *Result) SetPartialFingerPrint(name string, value interface{}) { |
| 134 |
result.PartialFingerprints[name] = value |
| 135 |
} |
| 136 |
|
| 137 |
// WithCodeFlows sets the CodeFlows |
| 138 |
func (result *Result) WithCodeFlows(codeFlows []*CodeFlow) *Result { |
| 139 |
result.CodeFlows = codeFlows |
| 140 |
return result |
| 141 |
} |
| 142 |
|
| 143 |
// AddCodeFlow ... |
| 144 |
func (result *Result) AddCodeFlow(codeFlow *CodeFlow) { |
| 145 |
result.CodeFlows = append(result.CodeFlows, codeFlow) |
| 146 |
|
| 147 |
} |
| 148 |
|
| 149 |
// WithGraphs sets the Graphs |
| 150 |
func (result *Result) WithGraphs(graphs []*Graph) *Result { |
| 151 |
result.Graphs = graphs |
| 152 |
return result |
| 153 |
} |
| 154 |
|
| 155 |
// AddGraph ... |
| 156 |
func (result *Result) AddGraph(graph *Graph) { |
| 157 |
result.Graphs = append(result.Graphs, graph) |
| 158 |
|
| 159 |
} |
| 160 |
|
| 161 |
// WithGraphTraversal sets the GraphTraversal |
| 162 |
func (result *Result) WithGraphTraversal(graphTraversals []*GraphTraversal) *Result { |
| 163 |
result.GraphTraversals = graphTraversals |
| 164 |
return result |
| 165 |
} |
| 166 |
|
| 167 |
// AddGraphTraversal ... |
| 168 |
func (result *Result) AddGraphTraversal(graphTraversal *GraphTraversal) { |
| 169 |
result.GraphTraversals = append(result.GraphTraversals, graphTraversal) |
| 170 |
|
| 171 |
} |
| 172 |
|
| 173 |
// WithStack sets the Stack |
| 174 |
func (result *Result) WithStack(stacks []*Stack) *Result { |
| 175 |
result.Stacks = stacks |
| 176 |
return result |
| 177 |
} |
| 178 |
|
| 179 |
// AddStack ... |
| 180 |
func (result *Result) AddStack(stack *Stack) { |
| 181 |
result.Stacks = append(result.Stacks, stack) |
| 182 |
|
| 183 |
} |
| 184 |
|
| 185 |
// WithRelatedLocations sets the RelatedLocations |
| 186 |
func (result *Result) WithRelatedLocations(locations []*Location) *Result { |
| 187 |
result.RelatedLocations = locations |
| 188 |
return result |
| 189 |
} |
| 190 |
|
| 191 |
// AddRelatedLocation ... |
| 192 |
func (result *Result) AddRelatedLocation(location *Location) *Result { |
| 193 |
result.RelatedLocations = append(result.RelatedLocations, location) |
| 194 |
return result |
| 195 |
} |
| 196 |
|
| 197 |
// WithSuppression sets the Suppression |
| 198 |
func (result *Result) WithSuppression(suppressions []*Suppression) *Result { |
| 199 |
result.Suppressions = suppressions |
| 200 |
return result |
| 201 |
} |
| 202 |
|
| 203 |
// AddSuppression ... |
| 204 |
func (result *Result) AddSuppression(suppression *Suppression) { |
| 205 |
result.Suppressions = append(result.Suppressions, suppression) |
| 206 |
|
| 207 |
} |
| 208 |
|
| 209 |
// WithBaselineState sets the BaselineState |
| 210 |
func (result *Result) WithBaselineState(state string) *Result { |
| 211 |
result.BaselineState = &state |
| 212 |
return result |
| 213 |
} |
| 214 |
|
| 215 |
// WithRank sets the Rank |
| 216 |
func (result *Result) WithRank(rank float32) *Result { |
| 217 |
result.Rank = &rank |
| 218 |
return result |
| 219 |
} |
| 220 |
|
| 221 |
// WithAttachments sets the Attachments |
| 222 |
func (result *Result) WithAttachments(attachments []*Attachment) *Result { |
| 223 |
result.Attachments = attachments |
| 224 |
return result |
| 225 |
} |
| 226 |
|
| 227 |
// AddAttachment ... |
| 228 |
func (result *Result) AddAttachment(attachments *Attachment) { |
| 229 |
result.Attachments = append(result.Attachments, attachments) |
| 230 |
|
| 231 |
} |
| 232 |
|
| 233 |
// WithWorkItemUris sets the WorkItemUris |
| 234 |
func (result *Result) WithWorkItemUris(workItemUris []string) *Result { |
| 235 |
result.WorkItemUris = workItemUris |
| 236 |
return result |
| 237 |
} |
| 238 |
|
| 239 |
// AddWorkItemUri ... |
| 240 |
func (result *Result) AddWorkItemUri(workItemUri string) { |
| 241 |
result.WorkItemUris = append(result.WorkItemUris, workItemUri) |
| 242 |
|
| 243 |
} |
| 244 |
|
| 245 |
// WithHostedViewerUri sets the HostedViewerUri |
| 246 |
func (result *Result) WithHostedViewerUri(hostedViewerUri string) *Result { |
| 247 |
result.HostedViewerUri = &hostedViewerUri |
| 248 |
return result |
| 249 |
} |
| 250 |
|
| 251 |
// WithFix sets the Fix |
| 252 |
func (result *Result) WithFix(fixes []*Fix) *Result { |
| 253 |
result.Fixes = fixes |
| 254 |
return result |
| 255 |
} |
| 256 |
|
| 257 |
// AddFix ... |
| 258 |
func (result *Result) AddFix(fix *Fix) { |
| 259 |
result.Fixes = append(result.Fixes, fix) |
| 260 |
} |
| 261 |
|
| 262 |
// WithOccurrenceCount sets the OccurrenceCount |
| 263 |
func (result *Result) WithOccurrenceCount(occurrenceCount int) *Result { |
| 264 |
count := uint(occurrenceCount) |
| 265 |
result.OccurrenceCount = &count |
| 266 |
return result |
| 267 |
} |