Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Add capture of panics (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
Owen Rumney authored Nov 10, 2021
1 parent 0e0da2b commit 2c71997
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pkg/externalscan/external_scan.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package externalscan

import (
"fmt"

"github.com/aquasecurity/cfsec/internal/app/cfsec/debug"
_ "github.com/aquasecurity/cfsec/internal/app/cfsec/loader"
"github.com/aquasecurity/cfsec/internal/app/cfsec/parser"
"github.com/aquasecurity/cfsec/internal/app/cfsec/scanner"
Expand All @@ -20,6 +23,12 @@ func NewExternalScanner(options ...Option) *ExternalScanner {
}

func (t *ExternalScanner) Scan(toScan string) ([]result.Result, error) {
defer func() {
if r := recover(); r != nil {
debug.Log("error: %v", r)
fmt.Printf("an error was encountered scanning %s\n", toScan)
}
}()
fileContexts, err := parser.NewParser().ParseFiles(toScan)
if err != nil {
return nil, err
Expand Down

0 comments on commit 2c71997

Please sign in to comment.