Skip to content
This repository was archived by the owner on Apr 10, 2019. It is now read-only.

Commit 25cd8f4

Browse files
Fabian Holleralecthomas
authored andcommitted
linters: fix: multiline gosec warnings not shown in gometalinter result
The gosec linter is printing a range expression like "1200-1204" for the line number in some cases. The gosec output in csv looks like: /home/fho/git/test/example.go,1200-1204,SQL string formatting,MEDIUM,HIGH,"fmt.Sprintf(` SELECT %s, FROM test )" The gometalinter line pattern was only expecting one or more digits as line number. This caused that some warnings did not match the pattern and did not show up in the gometalinter results. The Gosec pattern is changed to parse the first number as line number and ignore an eventual following "-<NUMBER>" expression. Gometalinter only supports to work with a single number for lines.
1 parent 8edca99 commit 25cd8f4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

linters.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ var defaultLinters = map[string]LinterConfig{
233233
},
234234
"gosec": {
235235
Command: `gosec -fmt=csv`,
236-
Pattern: `^(?P<path>.*?\.go),(?P<line>\d+),(?P<message>[^,]+,[^,]+,[^,]+)`,
236+
Pattern: `^(?P<path>.*?\.go),(?P<line>\d+)(-\d+)?,(?P<message>[^,]+,[^,]+,[^,]+)`,
237237
InstallFrom: "github.com/securego/gosec/cmd/gosec",
238238
PartitionStrategy: partitionPathsAsPackages,
239239
defaultEnabled: true,

0 commit comments

Comments
 (0)