forked from owenrumney/go-sarif
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c621d4b
commit 37bbd09
Showing
2 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package sarif | ||
|
||
// Notification represents different Notifications in the SARIF spec | ||
type Notification struct { | ||
PropertyBag | ||
Level *string `json:"level,omitempty"` | ||
Message Message `json:"message"` | ||
Locations []*Location `json:"locations,omitempty"` | ||
Properties Properties `json:"properties,omitempty"` | ||
} | ||
|
||
// NewNotification ... | ||
func NewNotification() *Notification { | ||
return &Notification{} | ||
} | ||
|
||
func newLevelNotification(level string) *Notification { | ||
return NewNotification().WithLevel(level) | ||
} | ||
|
||
// WithLevel ... | ||
func (n *Notification) WithLevel(level string) *Notification { | ||
n.Level = &level | ||
return n | ||
} | ||
|
||
// WithMessage ... | ||
func (n *Notification) WithMessage(message *Message) *Notification { | ||
n.Message = *message | ||
return n | ||
} | ||
|
||
// WithLocation ... | ||
func (n *Notification) WithLocation(location *Location) *Notification { | ||
n.Locations = append(n.Locations, location) | ||
return n | ||
} | ||
|
||
// WithProperties specifies properties for a rule and returns the updated rule | ||
func (n *Notification) WithProperties(properties Properties) *Notification { | ||
n.Properties = properties | ||
return n | ||
} | ||
|
||
// AttachPropertyBag adds a property bag to a rule | ||
func (n *Notification) AttachPropertyBag(pb *PropertyBag) { | ||
n.Properties = pb.Properties | ||
} |