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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user