Skip to content

Commit

Permalink
Update sarif comments
Browse files Browse the repository at this point in the history
  • Loading branch information
owenrumney committed Dec 17, 2021
1 parent aa1a813 commit a6967b6
Show file tree
Hide file tree
Showing 23 changed files with 151 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sarif/address.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package sarif

// Address ...
type Address struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html#_Toc10541049
PropertyBag
Index *uint `json:"index,omitempty"`
Expand All @@ -13,52 +14,62 @@ type Address struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/
ParentIndex *uint `json:"parentIndex,omitempty"`
}

// NewAddress ...
func NewAddress() *Address {
return &Address{}
}

// WithIndex ...
func (a *Address) WithIndex(index int) *Address {
i := uint(index)
a.Index = &i
return a
}

// WithAbsoluteAddress ...
func (a *Address) WithAbsoluteAddress(absoluteAddress int) *Address {
i := uint(absoluteAddress)
a.AbsoluteAddress = &i
return a
}

// WithRelativeAddress ...
func (a *Address) WithRelativeAddress(relativeAddress int) *Address {
a.RelativeAddress = &relativeAddress
return a
}

// WithOffsetFromParent ...
func (a *Address) WithOffsetFromParent(offsetFromParent int) *Address {
a.OffsetFromParent = &offsetFromParent
return a
}

// WithLength ...
func (a *Address) WithLength(length int) *Address {
a.Length = &length
return a
}

// WithName ...
func (a *Address) WithName(name string) *Address {
a.Name = &name
return a
}

// WithFullyQualifiedName ...
func (a *Address) WithFullyQualifiedName(fullyQualifiedName string) *Address {
a.FullyQualifiedName = &fullyQualifiedName
return a
}

// WithKind ...
func (a *Address) WithKind(kind string) *Address {
a.Kind = &kind
return a
}

// WithParentIndex ...
func (a *Address) WithParentIndex(parentIndex int) *Address {
i := uint(parentIndex)
a.ParentIndex = &i
Expand Down
14 changes: 14 additions & 0 deletions sarif/artifact.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package sarif

// Artifact ...
type Artifact struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html#_Toc10541049
PropertyBag
Location *ArtifactLocation `json:"location,omitempty"`
Expand All @@ -16,67 +17,80 @@ type Artifact struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01
Description *Message `json:"description,omitempty"`
}

// NewArtifact ...
func NewArtifact() *Artifact {
return &Artifact{}
}

// WithLocation ...
func (a *Artifact) WithLocation(artifactLocation *ArtifactLocation) *Artifact {
a.Location = artifactLocation
return a
}

// WithParentIndex ...
func (a *Artifact) WithParentIndex(parentIndex int) *Artifact {
i := uint(parentIndex)
a.ParentIndex = &i
return a
}

// WithOffset ...
func (a *Artifact) WithOffset(offset int) *Artifact {
o := uint(offset)
a.Offset = &o
return a
}

// WithLength ...
func (a *Artifact) WithLength(length int) *Artifact {
a.Length = length
return a
}

// WithRole ...
func (a *Artifact) WithRole(role string) *Artifact {
a.Roles = append(a.Roles, role)
return a
}

// WithMimeType ...
func (a *Artifact) WithMimeType(mimeType string) *Artifact {
a.MimeType = &mimeType
return a
}

// WithContents ...
func (a *Artifact) WithContents(artifactContent *ArtifactContent) *Artifact {
a.Contents = artifactContent
return a
}

// WithEncoding ...
func (a *Artifact) WithEncoding(encoding string) *Artifact {
a.Encoding = &encoding
return a
}

// WithSourceLanguage ...
func (a *Artifact) WithSourceLanguage(sourceLanguage string) *Artifact {
a.SourceLanguage = &sourceLanguage
return a
}

// WithHashes ...
func (a *Artifact) WithHashes(hashes map[string]string) *Artifact {
a.Hashes = hashes
return a
}

// WithLastModifiedTimeUtc ...
func (a *Artifact) WithLastModifiedTimeUtc(lastModified string) *Artifact {
a.LastModifiedTimeUtc = &lastModified
return a
}

// WithDescription ...
func (a *Artifact) WithDescription(message *Message) *Artifact {

return a
Expand Down
3 changes: 3 additions & 0 deletions sarif/artifact_change.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package sarif

// ArtifactChange ...
type ArtifactChange struct {
PropertyBag
ArtifactLocation ArtifactLocation `json:"artifactLocation"`
Replacements []*Replacement `json:"replacements"` //required
}

// NewArtifactChange ...
func NewArtifactChange(artifactLocation *ArtifactLocation) *ArtifactChange {
return &ArtifactChange{
ArtifactLocation: *artifactLocation,
}
}

// WithReplacement ...
func (a *ArtifactChange) WithReplacement(replacement *Replacement) *ArtifactChange {
a.Replacements = append(a.Replacements, replacement)
return a
Expand Down
5 changes: 5 additions & 0 deletions sarif/artifact_content.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
package sarif

// ArtifactContent ...
type ArtifactContent struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html#_Toc10540860
PropertyBag
Text *string `json:"text,omitempty"`
Binary *string `json:"binary,omitempty"`
Rendered *MultiformatMessageString `json:"rendered,omitempty"`
}

// NewArtifactContent ...
func NewArtifactContent() *ArtifactContent {
return &ArtifactContent{}
}

// WithText ...
func (a *ArtifactContent) WithText(text string) *ArtifactContent {
a.Text = &text
return a
}

// WithBinary ...
func (a *ArtifactContent) WithBinary(binary string) *ArtifactContent {
a.Binary = &binary
return a
}

// WithRendered ...
func (a *ArtifactContent) WithRendered(mms *MultiformatMessageString) *ArtifactContent {
a.Rendered = mms
return a
Expand Down
7 changes: 7 additions & 0 deletions sarif/artifact_location.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package sarif

// ArtifactLocation ...
type ArtifactLocation struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html#_Toc10540865
PropertyBag
URI *string `json:"uri,omitempty"`
Expand All @@ -8,30 +9,36 @@ type ArtifactLocation struct { // https://docs.oasis-open.org/sarif/sarif/v2.1.0
Description *Message `json:"description,omitempty"`
}

// NewArtifactLocation ...
func NewArtifactLocation() *ArtifactLocation {
return &ArtifactLocation{}
}

// NewSimpleArtifactLocation ...
func NewSimpleArtifactLocation(uri string) *ArtifactLocation {
return NewArtifactLocation().WithUri(uri)
}

// WithUri ...
func (a *ArtifactLocation) WithUri(uri string) *ArtifactLocation {
a.URI = &uri
return a
}

// WithUriBaseId ...
func (a *ArtifactLocation) WithUriBaseId(uriBaseId string) *ArtifactLocation {
a.URIBaseId = &uriBaseId
return a
}

// WithIndex ...
func (a *ArtifactLocation) WithIndex(index int) *ArtifactLocation {
i := uint(index)
a.Index = &i
return a
}

// WithDescription ...
func (a *ArtifactLocation) WithDescription(message *Message) *ArtifactLocation {
a.Description = message
return a
Expand Down
4 changes: 4 additions & 0 deletions sarif/fix.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
package sarif

// Fix ...
type Fix struct {
PropertyBag
Description *Message `json:"description,omitempty"`
ArtifactChanges []*ArtifactChange `json:"artifactChanges"` // required
}

// NewFix ...
func NewFix() *Fix {
return &Fix{}
}

// WithDescription ...
func (f *Fix) WithDescription(message *Message) *Fix {
f.Description = message
return f
}

// WithArtifactChange ...
func (f *Fix) WithArtifactChange(ac *ArtifactChange) *Fix {
f.ArtifactChanges = append(f.ArtifactChanges, ac)
return f
Expand Down
8 changes: 8 additions & 0 deletions sarif/location.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package sarif

// Location ...
type Location struct {
PropertyBag
Id *uint `json:"id,omitempty"`
Expand All @@ -10,35 +11,42 @@ type Location struct {
Relationships []*LocationRelationship `json:"relationships,omitempty"`
}

// NewLocation ...
func NewLocation() *Location {
return &Location{}
}

// NewLocationWithPhysicalLocation ...
func NewLocationWithPhysicalLocation(physicalLocation *PhysicalLocation) *Location {
return NewLocation().WithPhysicalLocation(physicalLocation)
}

// WithId ...
func (l *Location) WithId(id int) *Location {
i := uint(id)
l.Id = &i
return l
}

// WithPhysicalLocation ...
func (l *Location) WithPhysicalLocation(physicalLocation *PhysicalLocation) *Location {
l.PhysicalLocation = physicalLocation
return l
}

// WithMessage ...
func (l *Location) WithMessage(message *Message) *Location {
l.Message = message
return l
}

// WithAnnotation ...
func (l *Location) WithAnnotation(region *Region) *Location {
l.Annotations = append(l.Annotations, region)
return l
}

// WithRelationship ...
func (l *Location) WithRelationship(locationRelationship *LocationRelationship) *Location {
l.Relationships = append(l.Relationships, locationRelationship)
return l
Expand Down
4 changes: 4 additions & 0 deletions sarif/location_relationship.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
package sarif

// LocationRelationship ...
type LocationRelationship struct {
PropertyBag
Target uint `json:"target"`
Kinds []string `json:"kinds,omitempty"`
Description *Message `json:"description,omitempty"`
}

// NewLocationRelationship ...
func NewLocationRelationship(target int) *LocationRelationship {
t := uint(target)
return &LocationRelationship{
Target: t,
}
}

// WithKind ...
func (l *LocationRelationship) WithKind(kind string) *LocationRelationship {
l.Kinds = append(l.Kinds, kind)
return l
}

// WithDescription ...
func (l *LocationRelationship) WithDescription(message *Message) *LocationRelationship {
l.Description = message
return l
Expand Down
Loading

0 comments on commit a6967b6

Please sign in to comment.