@@ -150,19 +150,6 @@ func toGosecConfig(settings *config.GoSecSettings) gosec.Config {
150
150
return conf
151
151
}
152
152
153
- func convertScoreToString (score issue.Score ) string {
154
- switch score {
155
- case issue .Low :
156
- return "low"
157
- case issue .Medium :
158
- return "medium"
159
- case issue .High :
160
- return "high"
161
- default :
162
- return ""
163
- }
164
- }
165
-
166
153
// based on https://github.com/securego/gosec/blob/47bfd4eb6fc7395940933388550b547538b4c946/config.go#L52-L62
167
154
func convertGosecGlobals (globalOptionFromConfig any , conf gosec.Config ) {
168
155
globalOptionMap , ok := globalOptionFromConfig .(map [string ]any )
@@ -179,17 +166,35 @@ func convertGosecGlobals(globalOptionFromConfig any, conf gosec.Config) {
179
166
func gosecRuleFilters (includes , excludes []string ) []rules.RuleFilter {
180
167
var filters []rules.RuleFilter
181
168
182
- if len (includes ) > 0 {
183
- filters = append (filters , rules .NewRuleFilter (false , includes ... ))
169
+ cleanIncludes := cleanRules (includes )
170
+
171
+ if len (cleanIncludes ) > 0 {
172
+ filters = append (filters , rules .NewRuleFilter (false , cleanIncludes ... ))
184
173
}
185
174
186
- if len (excludes ) > 0 {
187
- filters = append (filters , rules .NewRuleFilter (true , excludes ... ))
175
+ cleanExcludes := cleanRules (excludes )
176
+ cleanExcludes = append (cleanExcludes , "G601" , "G113" )
177
+
178
+ if len (cleanExcludes ) > 0 {
179
+ filters = append (filters , rules .NewRuleFilter (true , cleanExcludes ... ))
188
180
}
189
181
190
182
return filters
191
183
}
192
184
185
+ // code borrowed from https://github.com/securego/gosec/blob/69213955dacfd560562e780f723486ef1ca6d486/cmd/gosec/main.go#L264-L276
186
+ func filterIssues (issues []* issue.Issue , severity , confidence issue.Score ) []* issue.Issue {
187
+ res := make ([]* issue.Issue , 0 )
188
+
189
+ for _ , i := range issues {
190
+ if i .Severity >= severity && i .Confidence >= confidence {
191
+ res = append (res , i )
192
+ }
193
+ }
194
+
195
+ return res
196
+ }
197
+
193
198
// code borrowed from https://github.com/securego/gosec/blob/69213955dacfd560562e780f723486ef1ca6d486/cmd/gosec/main.go#L250-L262
194
199
func convertToScore (str string ) (issue.Score , error ) {
195
200
str = strings .ToLower (str )
@@ -205,15 +210,27 @@ func convertToScore(str string) (issue.Score, error) {
205
210
}
206
211
}
207
212
208
- // code borrowed from https://github.com/securego/gosec/blob/69213955dacfd560562e780f723486ef1ca6d486/cmd/gosec/main.go#L264-L276
209
- func filterIssues (issues []* issue.Issue , severity , confidence issue.Score ) []* issue.Issue {
210
- res := make ([]* issue.Issue , 0 )
213
+ func convertScoreToString (score issue.Score ) string {
214
+ switch score {
215
+ case issue .Low :
216
+ return "low"
217
+ case issue .Medium :
218
+ return "medium"
219
+ case issue .High :
220
+ return "high"
221
+ default :
222
+ return ""
223
+ }
224
+ }
211
225
212
- for _ , i := range issues {
213
- if i .Severity >= severity && i .Confidence >= confidence {
214
- res = append (res , i )
226
+ func cleanRules (ruleNames []string ) []string {
227
+ var cleanRuleNames []string
228
+ for _ , ruleName := range ruleNames {
229
+ if ruleName == "G601" || ruleName == "G113" {
230
+ continue
215
231
}
232
+ cleanRuleNames = append (cleanRuleNames , ruleName )
216
233
}
217
234
218
- return res
235
+ return cleanRuleNames
219
236
}
0 commit comments