mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 20:15:54 +00:00
Correct bad test cases and intermitent failure
The filelist test was non-deterministic and causing intermittent failures due to ordering. This change will ensure that the file list returns an ordered list of files in the String() method now. Additionally there were a number of test cases that the sample code was incorrect, or would not compile. These have also been corrected.
This commit is contained in:
parent
1c8e7ff686
commit
622440f167
5 changed files with 6 additions and 11 deletions
|
@ -15,6 +15,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/ryanuber/go-glob"
|
"github.com/ryanuber/go-glob"
|
||||||
|
@ -41,6 +42,7 @@ func (f *fileList) String() string {
|
||||||
for p := range f.patterns {
|
for p := range f.patterns {
|
||||||
ps = append(ps, p)
|
ps = append(ps, p)
|
||||||
}
|
}
|
||||||
|
sort.Strings(ps)
|
||||||
return strings.Join(ps, ", ")
|
return strings.Join(ps, ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,8 +65,8 @@ func Test_fileList_String(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "two patterns",
|
name: "two patterns",
|
||||||
fields: fields{patterns: []string{"foo", "bar"}},
|
fields: fields{patterns: []string{"bar", "foo"}},
|
||||||
want: "foo, bar",
|
want: "bar, foo",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
|
@ -22,6 +22,7 @@ package main
|
||||||
import (
|
import (
|
||||||
_ "crypto/md5"
|
_ "crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
func main() {
|
func main() {
|
||||||
for _, arg := range os.Args {
|
for _, arg := range os.Args {
|
||||||
|
|
|
@ -49,7 +49,7 @@ func TestNosecBlock(t *testing.T) {
|
||||||
`package main
|
`package main
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"os/exect"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
|
@ -89,8 +89,6 @@ func TestSQLInjectionFalsePositiveA(t *testing.T) {
|
||||||
package main
|
package main
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
//_ "github.com/mattn/go-sqlite3"
|
//_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -125,8 +123,6 @@ func TestSQLInjectionFalsePositiveB(t *testing.T) {
|
||||||
package main
|
package main
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
//_ "github.com/mattn/go-sqlite3"
|
//_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -161,8 +157,6 @@ func TestSQLInjectionFalsePositiveC(t *testing.T) {
|
||||||
package main
|
package main
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
//_ "github.com/mattn/go-sqlite3"
|
//_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -197,8 +191,6 @@ func TestSQLInjectionFalsePositiveD(t *testing.T) {
|
||||||
package main
|
package main
|
||||||
import (
|
import (
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
//_ "github.com/mattn/go-sqlite3"
|
//_ "github.com/mattn/go-sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue