| 1 | package sarif |
| 2 | |
| 3 | // Artifact ... |
| 4 | type Artifact struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html#_Toc10541049 |
| 5 | PropertyBag |
| 6 | Location *ArtifactLocation `json:"location,omitempty"` |
| 7 | ParentIndex *uint `json:"parentIndex,omitempty"` |
| 8 | Offset *uint `json:"offset,omitempty"` |
| 9 | Length int `json:"length"` |
| 10 | Roles []string `json:"roles,omitempty"` |
| 11 | MimeType *string `json:"mimeType,omitempty"` |
| 12 | Contents *ArtifactContent `json:"contents,omitempty"` |
| 13 | Encoding *string `json:"encoding,omitempty"` |
| 14 | SourceLanguage *string `json:"sourceLanguage,omitempty"` |
| 15 | Hashes map[string]string `json:"hashes,omitempty"` |
| 16 | LastModifiedTimeUtc *string `json:"lastModifiedTimeUtc,omitempty"` |
| 17 | Description *Message `json:"description,omitempty"` |
| 18 | } |
| 19 | |
| 20 | // NewArtifact ... |
| 21 | func NewArtifact() *Artifact { |
| 22 | return &Artifact{} |
| 23 | } |
| 24 | |
| 25 | // WithLocation ... |
| 26 | func (a *Artifact) WithLocation(artifactLocation *ArtifactLocation) *Artifact { |
| 27 | a.Location = artifactLocation |
| 28 | return a |
| 29 | } |
| 30 | |
| 31 | // WithParentIndex ... |
| 32 | func (a *Artifact) WithParentIndex(parentIndex int) *Artifact { |
| 33 | i := uint(parentIndex) |
| 34 | a.ParentIndex = &i |
| 35 | return a |
| 36 | } |
| 37 | |
| 38 | // WithOffset ... |
| 39 | func (a *Artifact) WithOffset(offset int) *Artifact { |
| 40 | o := uint(offset) |
| 41 | a.Offset = &o |
| 42 | return a |
| 43 | } |
| 44 | |
| 45 | // WithLength ... |
| 46 | func (a *Artifact) WithLength(length int) *Artifact { |
| 47 | a.Length = length |
| 48 | return a |
| 49 | } |
| 50 | |
| 51 | // WithRole ... |
| 52 | func (a *Artifact) WithRole(role string) *Artifact { |
| 53 | a.Roles = append(a.Roles, role) |
| 54 | return a |
| 55 | } |
| 56 | |
| 57 | // WithMimeType ... |
| 58 | func (a *Artifact) WithMimeType(mimeType string) *Artifact { |
| 59 | a.MimeType = &mimeType |
| 60 | return a |
| 61 | } |
| 62 | |
| 63 | // WithContents ... |
| 64 | func (a *Artifact) WithContents(artifactContent *ArtifactContent) *Artifact { |
| 65 | a.Contents = artifactContent |
| 66 | return a |
| 67 | } |
| 68 | |
| 69 | // WithEncoding ... |
| 70 | func (a *Artifact) WithEncoding(encoding string) *Artifact { |
| 71 | a.Encoding = &encoding |
| 72 | return a |
| 73 | } |
| 74 | |
| 75 | // WithSourceLanguage ... |
| 76 | func (a *Artifact) WithSourceLanguage(sourceLanguage string) *Artifact { |
| 77 | a.SourceLanguage = &sourceLanguage |
| 78 | return a |
| 79 | } |
| 80 | |
| 81 | // WithHashes ... |
| 82 | func (a *Artifact) WithHashes(hashes map[string]string) *Artifact { |
| 83 | a.Hashes = hashes |
| 84 | return a |
| 85 | } |
| 86 | |
| 87 | // WithLastModifiedTimeUtc ... |
| 88 | func (a *Artifact) WithLastModifiedTimeUtc(lastModified string) *Artifact { |
| 89 | a.LastModifiedTimeUtc = &lastModified |
| 90 | return a |
| 91 | } |
| 92 | |
| 93 | // WithDescription ... |
| 94 | func (a *Artifact) WithDescription(message *Message) *Artifact { |
| 95 | |
| 96 | return a |
| 97 | } |