mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
Replace the deprecated load mode with more specific flags are recommended in the packages docs (#400)
Signed-off-by: Cosmin Cojocar <cosmin.cojocar@gmx.ch>
This commit is contained in:
parent
ad375d3b8f
commit
e680875ea1
2 changed files with 12 additions and 2 deletions
12
analyzer.go
12
analyzer.go
|
@ -33,6 +33,16 @@ import (
|
||||||
"golang.org/x/tools/go/packages"
|
"golang.org/x/tools/go/packages"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// LoadMode controls the amount of details to return when loading the packages
|
||||||
|
const LoadMode = packages.NeedName |
|
||||||
|
packages.NeedFiles |
|
||||||
|
packages.NeedCompiledGoFiles |
|
||||||
|
packages.NeedImports |
|
||||||
|
packages.NeedTypes |
|
||||||
|
packages.NeedTypesSizes |
|
||||||
|
packages.NeedTypesInfo |
|
||||||
|
packages.NeedSyntax
|
||||||
|
|
||||||
// The Context is populated with data parsed from the source code as it is scanned.
|
// The Context is populated with data parsed from the source code as it is scanned.
|
||||||
// It is passed through to all rule functions as they are called. Rules may use
|
// It is passed through to all rule functions as they are called. Rules may use
|
||||||
// this data in conjunction withe the encountered AST node.
|
// this data in conjunction withe the encountered AST node.
|
||||||
|
@ -140,7 +150,7 @@ func (gosec *Analyzer) pkgConfig(buildTags []string) *packages.Config {
|
||||||
flags = append(flags, tagsFlag)
|
flags = append(flags, tagsFlag)
|
||||||
}
|
}
|
||||||
return &packages.Config{
|
return &packages.Config{
|
||||||
Mode: packages.LoadSyntax,
|
Mode: LoadMode,
|
||||||
BuildFlags: flags,
|
BuildFlags: flags,
|
||||||
Tests: gosec.tests,
|
Tests: gosec.tests,
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ func (p *TestPackage) Build() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
conf := &packages.Config{
|
conf := &packages.Config{
|
||||||
Mode: packages.LoadSyntax,
|
Mode: gosec.LoadMode,
|
||||||
Tests: false,
|
Tests: false,
|
||||||
}
|
}
|
||||||
pkgs, err := packages.Load(conf, packageFiles...)
|
pkgs, err := packages.Load(conf, packageFiles...)
|
||||||
|
|
Loading…
Reference in a new issue