fix prints to stdout and stderr and update README.md (#77)

Signed-off-by: Asra Ali <asraa@google.com>
This commit is contained in:
asraa
2022-06-02 16:07:21 -07:00
committed by GitHub
parent 50e8539e35
commit c80938e298
3 changed files with 8 additions and 4 deletions
+4
View File
@@ -78,8 +78,12 @@ verified SLSA provenance produced at
"trigger": "workflow_dispatch",
"issuer": "https://token.actions.githubusercontent.com"
}
{"_type":"https://in-toto.io/Statement/v0.1","predicateType":"https://slsa.dev/provenance/v0.2","subject":[{"name":"binary-linux-amd64","digest":{"sha256":"723ccb85318bc8b1a9dd29340612ce1268cd3418d70f68e775edbdc16d1d9158"}}],"predicate":{...}}
successfully verified SLSA provenance
```
The verified in-toto statement is written to stdout and can be used to pipe into policy engines.
## Technical design
### Blog post
+2 -2
View File
@@ -100,7 +100,7 @@ func verify(ctx context.Context,
if err != nil {
return fmt.Errorf("%w: %s", pkg.ErrorInvalidDssePayload, "decoding payload")
}
fmt.Fprintf(os.Stdout, string(pyld))
fmt.Fprintf(os.Stdout, "%s\n", string(pyld))
return nil
}
@@ -138,7 +138,7 @@ func main() {
os.Exit(2)
}
fmt.Fprintf(os.Stderr, "successfully verified SLSA provenance")
fmt.Fprintf(os.Stderr, "successfully verified SLSA provenance\n")
}
func isFlagPassed(name string) bool {
+2 -2
View File
@@ -11,6 +11,7 @@ import (
"encoding/json"
"errors"
"fmt"
"os"
"strings"
"time"
@@ -315,7 +316,6 @@ func FindSigningCertificate(ctx context.Context, uuids []string, dssePayload dss
for _, uuid := range uuids {
entry, err := verifyTlogEntry(ctx, rClient, uuid)
if err != nil {
fmt.Printf(err.Error())
continue
}
cert, err := extractCert(entry)
@@ -340,7 +340,7 @@ func FindSigningCertificate(ctx context.Context, uuids []string, dssePayload dss
continue
}
// success!
fmt.Printf("Verified against tlog entry %d\n", *entry.LogIndex)
fmt.Fprintf(os.Stderr, "Verified against tlog entry %d\n", *entry.LogIndex)
return cert, nil
}