mirror of
https://github.com/securego/gosec.git
synced 2024-12-25 03:55:54 +00:00
Handle empty ssa results
Signed-off-by: Cosmin Cojocar <gcojocar@adobe.com>
This commit is contained in:
parent
074353a2ab
commit
7e2d8d35f4
1 changed files with 3 additions and 3 deletions
|
@ -321,7 +321,7 @@ func (gosec *Analyzer) CheckRules(pkg *packages.Package) {
|
||||||
// CheckAnalyzers runs analyzers on a given package.
|
// CheckAnalyzers runs analyzers on a given package.
|
||||||
func (gosec *Analyzer) CheckAnalyzers(pkg *packages.Package) {
|
func (gosec *Analyzer) CheckAnalyzers(pkg *packages.Package) {
|
||||||
ssaResult, err := gosec.buildSSA(pkg)
|
ssaResult, err := gosec.buildSSA(pkg)
|
||||||
if err != nil {
|
if err != nil || ssaResult == nil {
|
||||||
gosec.logger.Printf("Error building the SSA representation of the package %q: %s", pkg.Name, err)
|
gosec.logger.Printf("Error building the SSA representation of the package %q: %s", pkg.Name, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -370,8 +370,8 @@ func (gosec *Analyzer) CheckAnalyzers(pkg *packages.Package) {
|
||||||
// buildSSA runs the SSA pass which builds the SSA representation of the package. It handles gracefully any panic.
|
// buildSSA runs the SSA pass which builds the SSA representation of the package. It handles gracefully any panic.
|
||||||
func (gosec *Analyzer) buildSSA(pkg *packages.Package) (interface{}, error) {
|
func (gosec *Analyzer) buildSSA(pkg *packages.Package) (interface{}, error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r = nil {
|
||||||
gosec.logger.Printf("Panic when running SSA analyser on package %q: %s", pkg.Name, r)
|
gosec.logger.Printf("Panic when running SSA analyser on package: %s", pkg.Name)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
ssaPass := &analysis.Pass{
|
ssaPass := &analysis.Pass{
|
||||||
|
|
Loading…
Reference in a new issue