Never panic, always return error (#199)

* Update main.go

Signed-off-by: laurentsimon <64505099+laurentsimon@users.noreply.github.com>

* Update main.go

Signed-off-by: laurentsimon <64505099+laurentsimon@users.noreply.github.com>
This commit is contained in:
laurentsimon
2022-08-07 20:30:09 -07:00
committed by GitHub
parent edb792b342
commit edb1ffd807

View File

@@ -7,7 +7,6 @@ import (
"flag"
"fmt"
"io"
"log"
"os"
"github.com/slsa-framework/slsa-verifier/options"
@@ -91,7 +90,7 @@ func runVerify(artifactPath, provenancePath, source, branch string,
) ([]byte, string, error) {
f, err := os.Open(artifactPath)
if err != nil {
log.Fatal(err)
return nil, "", err
}
defer f.Close()
@@ -102,7 +101,7 @@ func runVerify(artifactPath, provenancePath, source, branch string,
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
log.Panic(err)
return nil, "", err
}
artifactHash := hex.EncodeToString(h.Sum(nil))