1
0
mirror of https://github.com/securego/gosec.git synced 2025-07-03 00:27:05 +02:00

Refactor AppendError to check for build.NoGoError (#1273)

This commit is contained in:
Oleksandr Redko
2024-12-19 12:55:12 +02:00
committed by GitHub
parent 9a2d74ffe0
commit 36c81ed69b
2 changed files with 8 additions and 2 deletions

View File

@ -16,6 +16,7 @@
package gosec
import (
"errors"
"fmt"
"go/ast"
"go/build"
@ -543,7 +544,8 @@ func (gosec *Analyzer) ParseErrors(pkg *packages.Package) error {
// AppendError appends an error to the file errors
func (gosec *Analyzer) AppendError(file string, err error) {
// Do not report the error for empty packages (e.g. files excluded from build with a tag)
if strings.Contains(err.Error(), "no buildable Go source files in") {
var noGoErr *build.NoGoError
if errors.As(err, &noGoErr) {
return
}
errors := make([]Error, 0)