🌱 add stack info to osv-scanner error (#4172)

* add stack info to osv-scanner error

Signed-off-by: Zxilly <zxilly@outlook.com>

* print error stack to stderr

Signed-off-by: Zxilly <zxilly@outlook.com>

* follow the lint rule

Signed-off-by: Zxilly <zxilly@outlook.com>

---------

Signed-off-by: Zxilly <zxilly@outlook.com>
This commit is contained in:
Zxilly 2024-06-15 07:02:21 +08:00 committed by GitHub
parent c7821b633c
commit 5ef9831b91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,6 +18,8 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"os"
"runtime/debug"
"github.com/google/osv-scanner/pkg/osvscanner" "github.com/google/osv-scanner/pkg/osvscanner"
@ -39,6 +41,7 @@ func (v osvClient) ListUnfixedVulnerabilities(
defer func() { defer func() {
if r := recover(); r != nil { if r := recover(); r != nil {
err = sce.CreateInternal(sce.ErrScorecardInternal, fmt.Sprintf("osv-scanner panic: %v", r)) err = sce.CreateInternal(sce.ErrScorecardInternal, fmt.Sprintf("osv-scanner panic: %v", r))
fmt.Fprintf(os.Stderr, "osv-scanner panic: %v\n%s\n", r, string(debug.Stack()))
} }
}() }()
directoryPaths := []string{} directoryPaths := []string{}