1
0
mirror of https://github.com/securego/gosec.git synced 2025-11-23 22:15:04 +02:00

Do a single build for all packages.

This is much faster because the loader can reuse packages.
This commit is contained in:
Andrew S. Brown
2018-01-07 15:02:33 -08:00
parent 085e0f65af
commit 22dc89384d
3 changed files with 45 additions and 17 deletions

View File

@@ -73,6 +73,28 @@ var _ = Describe("Analyzer", func() {
Expect(metrics.NumFiles).To(Equal(2))
})
It("should be able to analyze mulitple Go packages", func() {
analyzer.LoadRules(rules.Generate().Builders()...)
pkg1 := testutils.NewTestPackage()
pkg2 := testutils.NewTestPackage()
defer pkg1.Close()
defer pkg2.Close()
pkg1.AddFile("foo.go", `
package main
func main(){
}`)
pkg2.AddFile("bar.go", `
package main
func bar(){
}`)
pkg1.Build()
pkg2.Build()
err := analyzer.Process(pkg1.Path, pkg2.Path)
Expect(err).ShouldNot(HaveOccurred())
_, metrics := analyzer.Report()
Expect(metrics.NumFiles).To(Equal(2))
})
It("should find errors when nosec is not in use", func() {
// Rule for MD5 weak crypto usage