@@ -52,29 +52,30 @@ type (
5252// GenerateProvenance translates github context into a SLSA provenance
5353// attestation.
5454// Spec: https://slsa.dev/provenance/v0.2
55- func GenerateProvenance (name , digest , command , envs string ) ([]byte , error ) {
55+ // Returns the SLSA provenance statement, and a string containing log reference information
56+ func GenerateProvenance (name , digest , command , envs string ) ([]byte , string , error ) {
5657 gh , err := github .GetWorkflowContext ()
5758 if err != nil {
58- return nil , err
59+ return nil , "" , err
5960 }
6061
6162 if _ , err := hex .DecodeString (digest ); err != nil || len (digest ) != 64 {
62- return nil , fmt .Errorf ("sha256 digest is not valid: %s" , digest )
63+ return nil , "" , fmt .Errorf ("sha256 digest is not valid: %s" , digest )
6364 }
6465
6566 com , err := unmarshallList (command )
6667 if err != nil {
67- return nil , err
68+ return nil , "" , err
6869 }
6970
7071 env , err := unmarshallList (envs )
7172 if err != nil {
72- return nil , err
73+ return nil , "" , err
7374 }
7475
7576 c , err := github .NewOIDCClient ()
7677 if err != nil {
77- return nil , err
78+ return nil , "" , err
7879 }
7980
8081 // Generate a basic WorkflowRun for our subject based on the github
@@ -106,7 +107,7 @@ func GenerateProvenance(name, digest, command, envs string) ([]byte, error) {
106107 ctx := context .Background ()
107108 p , err := slsa .HostedActionsProvenance (ctx , wr , c )
108109 if err != nil {
109- return nil , err
110+ return nil , "" , err
110111 }
111112
112113 // Set the architecture based on the runner. Architecture should be the
@@ -123,15 +124,21 @@ func GenerateProvenance(name, digest, command, envs string) ([]byte, error) {
123124 s := sigstore .NewDefaultSigner ()
124125 att , err := s .Sign (ctx , p )
125126 if err != nil {
126- return nil , err
127+ return nil , "" , err
127128 }
128129
129130 // Upload the signed attestation to recor.
130- if err := s .Upload (ctx , att ); err != nil {
131- return nil , err
131+ logEntry , err := s .Upload (ctx , att )
132+ if err != nil {
133+ return nil , "" , err
134+ }
135+
136+ if logEntry .LogIndex == nil || logEntry .LogID == nil {
137+ return nil , "" , fmt .Errorf ("logEntry fields not present for tlog upload" )
132138 }
139+ logRef := fmt .Sprintf ("index:%d, logID:%s" , * logEntry .LogIndex , * logEntry .LogID )
133140
134- return att .Bytes (), nil
141+ return att .Bytes (), logRef , nil
135142}
136143
137144func unmarshallList (arg string ) ([]string , error ) {
0 commit comments