Debian Codegraph @

v2/sarif/reporting_descriptor.go

raw
1 package sarif
2
3 // ReportingDescriptor specifies a Sarif ReportingDescriptor object
4 type ReportingDescriptor struct {
5 PropertyBag
6 ID string `json:"id"`
7 Name *string `json:"name,omitempty"`
8 ShortDescription *MultiformatMessageString `json:"shortDescription"`
9 FullDescription *MultiformatMessageString `json:"fullDescription,omitempty"`
10 DefaultConfiguration *ReportingConfiguration `json:"defaultConfiguration,omitempty"`
11 DeprecatedIds []string `json:"deprecatedIds,omitempty"`
12 DeprecatedGuids []string `json:"deprecatedGuids,omitempty"`
13 DeprecatedNames []string `json:"deprecatedNames,omitempty"`
14 HelpURI *string `json:"helpUri,omitempty"`
15 Help *MultiformatMessageString `json:"help,omitempty"`
16 MessageStrings *MessageStrings `json:"messageStrings,omitempty"`
17 Properties Properties `json:"properties,omitempty"`
18 }
19
20 // NewRule creates a new Rule and returns a pointer to it
21 func NewRule(ruleID string) *ReportingDescriptor {
22 return &ReportingDescriptor{
23 ID: ruleID,
24 }
25 }
26
27 // WithName specifies rule name that is understandable to an end user and returns the updated rule.
28 func (rule *ReportingDescriptor) WithName(name string) *ReportingDescriptor {
29 rule.Name = &name
30 return rule
31 }
32
33 // WithDescription specifies short description for a rule and returns the updated rule.
34 // Short description should be a single sentence that is understandable when visible space is limited to a single line
35 // of text.
36 func (rule *ReportingDescriptor) WithDescription(description string) *ReportingDescriptor {
37 rule.ShortDescription = NewMultiformatMessageString(description)
38 return rule
39 }
40
41 // WithShortDescription specifies short description for a rule and returns the updated rule.
42 // Short description should be a single sentence that is understandable when visible space is limited to a single line
43 // of text.
44 func (rule *ReportingDescriptor) WithShortDescription(description *MultiformatMessageString) *ReportingDescriptor {
45 rule.ShortDescription = description
46 return rule
47 }
48
49 // WithFullDescription specifies full description for a rule and returns the updated rule.
50 // Full description should, as far as possible, provide details sufficient to enable resolution of any problem indicated
51 // by the result.
52 func (rule *ReportingDescriptor) WithFullDescription(description *MultiformatMessageString) *ReportingDescriptor {
53 rule.FullDescription = description
54 return rule
55 }
56
57 // WithHelpURI specifies a helpURI for a rule and returns the updated rule
58 func (rule *ReportingDescriptor) WithHelpURI(helpURI string) *ReportingDescriptor {
59 rule.HelpURI = &helpURI
60 return rule
61 }
62
63 // WithHelp sets the rule Help to the provided multiformat message
64 func (rule *ReportingDescriptor) WithHelp(help *MultiformatMessageString) *ReportingDescriptor {
65 rule.Help = help
66 return rule
67 }
68
69 // WithTextHelp specifies a help text for a rule and returns the updated rule
70 func (rule *ReportingDescriptor) WithTextHelp(text string) *ReportingDescriptor {
71 if rule.Help == nil {
72 rule.Help = &MultiformatMessageString{}
73 }
74 rule.Help.Text = &text
75 return rule
76 }
77
78 // WithMarkdownHelp specifies a help text for a rule and returns the updated rule
79 func (rule *ReportingDescriptor) WithMarkdownHelp(markdown string) *ReportingDescriptor {
80 if rule.Help == nil {
81 rule.Help = &MultiformatMessageString{}
82 }
83 rule.Help.Markdown = &markdown
84 return rule
85 }
86
87 // WithProperties specifies properties for a rule and returns the updated rule
88 func (rule *ReportingDescriptor) WithProperties(properties Properties) *ReportingDescriptor {
89 rule.Properties = properties
90 return rule
91 }
92
93 // AttachPropertyBag adds a property bag to a rule
94 func (rule *ReportingDescriptor) AttachPropertyBag(pb *PropertyBag) {
95 rule.Properties = pb.Properties
96 }
97
98 // WithDefaultConfiguration adds the default configuration to the rule
99 func (rule *ReportingDescriptor) WithDefaultConfiguration(configuration *ReportingConfiguration) *ReportingDescriptor {
100 rule.DefaultConfiguration = configuration
101 return rule
102 }