- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
868e13e
commit 8b2ab29
Showing
11 changed files
with
166 additions
and
108 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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module github.com/owenrumney/go-sarif | ||
module github.com/owenrumney/go-sarif/v2 | ||
|
||
go 1.16 | ||
|
||
|
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,87 @@ | ||
package sarif | ||
|
||
type ReportingConfiguration struct { | ||
Enabled bool `json:"enabled,omitempty"` | ||
Level interface{} `json:"level,omitempty"` | ||
Parameters *PropertyBag `json:"parameters,omitempty"` | ||
Properties *PropertyBag `json:"properties,omitempty"` | ||
Rank float64 `json:"rank,omitempty"` | ||
} | ||
|
||
// ReportingDescriptor specifies a Sarif ReportingDescriptor object | ||
type ReportingDescriptor struct { | ||
PropertyBag | ||
ID string `json:"id"` | ||
Name *string `json:"name,omitempty"` | ||
ShortDescription *MultiformatMessageString `json:"shortDescription"` | ||
FullDescription *MultiformatMessageString `json:"fullDescription,omitempty"` | ||
DefaultConfiguration *ReportingConfiguration `json:"defaultConfiguration,omitempty"` | ||
HelpURI *string `json:"helpUri,omitempty"` | ||
Help *MultiformatMessageString `json:"help,omitempty"` | ||
Properties Properties `json:"properties,omitempty"` | ||
} | ||
|
||
func newRule(ruleID string) *ReportingDescriptor { | ||
return &ReportingDescriptor{ | ||
ID: ruleID, | ||
} | ||
} | ||
|
||
// WithName specifies rule name that is understandable to an end user and returns the updated rule. | ||
func (rule *ReportingDescriptor) WithName(name string) *ReportingDescriptor { | ||
rule.Name = &name | ||
return rule | ||
} | ||
|
||
// WithDescription specifies short description for a rule and returns the updated rule. | ||
// Short description should be a single sentence that is understandable when visible space is limited to a single line | ||
// of text. | ||
func (rule *ReportingDescriptor) WithDescription(description string) *ReportingDescriptor { | ||
rule.ShortDescription = NewMultiformatMessageString(description) | ||
return rule | ||
} | ||
|
||
// WithShortDescription specifies short description for a rule and returns the updated rule. | ||
// Short description should be a single sentence that is understandable when visible space is limited to a single line | ||
// of text. | ||
func (rule *ReportingDescriptor) WithShortDescription(description *MultiformatMessageString) *ReportingDescriptor { | ||
rule.ShortDescription = description | ||
return rule | ||
} | ||
|
||
// WithFullDescription specifies full description for a rule and returns the updated rule. | ||
// Full description should, as far as possible, provide details sufficient to enable resolution of any problem indicated | ||
// by the result. | ||
func (rule *ReportingDescriptor) WithFullDescription(description *MultiformatMessageString) *ReportingDescriptor { | ||
rule.FullDescription = description | ||
return rule | ||
} | ||
|
||
// WithHelpURI specifies a helpURI for a rule and returns the updated rule | ||
func (rule *ReportingDescriptor) WithHelpURI(helpURI string) *ReportingDescriptor { | ||
rule.HelpURI = &helpURI | ||
return rule | ||
} | ||
|
||
// WithHelp specifies a help text for a rule and returns the updated rule | ||
func (rule *ReportingDescriptor) WithHelp(helpText string) *ReportingDescriptor { | ||
rule.Help = NewMultiformatMessageString(helpText) | ||
return rule | ||
} | ||
|
||
// WithMarkdownHelp specifies a help text for a rule and returns the updated rule | ||
func (rule *ReportingDescriptor) WithMarkdownHelp(markdownText string) *ReportingDescriptor { | ||
rule.Help = NewMarkdownMultiformatMessageString(markdownText) | ||
return rule | ||
} | ||
|
||
// WithProperties specifies properties for a rule and returns the updated rule | ||
func (rule *ReportingDescriptor) WithProperties(properties Properties) *ReportingDescriptor { | ||
rule.Properties = properties | ||
return rule | ||
} | ||
|
||
// AttachPropertyBag adds a property bag to a rule | ||
func (rule *ReportingDescriptor) AttachPropertyBag(pb *PropertyBag) { | ||
rule.Properties = pb.Properties | ||
} |
This file was deleted.
Oops, something went wrong.
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
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,27 @@ | ||
package sarif | ||
|
||
type ToolComponent struct { | ||
PropertyBag | ||
Name string `json:"name"` | ||
Version *string `json:"version,omitempty"` | ||
InformationURI *string `json:"informationUri"` | ||
Notifications []*ReportingDescriptor `json:"notifications,omitempty"` | ||
Rules []*ReportingDescriptor `json:"rules,omitempty"` | ||
Taxa []*ReportingDescriptor `json:"taxa,omitempty"` | ||
} | ||
|
||
// WithVersion specifies tool version, in whatever format it natively provides. Returns updated driver. | ||
func (driver *ToolComponent) WithVersion(version string) *ToolComponent { | ||
driver.Version = &version | ||
return driver | ||
} | ||
|
||
func (driver *ToolComponent) getOrCreateRule(rule *ReportingDescriptor) uint { | ||
for i, r := range driver.Rules { | ||
if r.ID == rule.ID { | ||
return uint(i) | ||
} | ||
} | ||
driver.Rules = append(driver.Rules, rule) | ||
return uint(len(driver.Rules) - 1) | ||
} |
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