Skip to content

Commit 83fc255

Browse files
committed
fix intoto schema refs
1 parent 485ac23 commit 83fc255

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

internal/validate/vsa/rekor_retriever.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,9 @@ func (r *RekorVSARetriever) classifyEntryKind(entry models.LogEntryAnon) string
205205
}
206206
}
207207

208-
// Check for IntotoObj structure (in-toto 0.0.2 entries)
209-
if intotoObj, ok := body["IntotoObj"].(map[string]any); ok {
210-
if content, ok := intotoObj["content"].(map[string]any); ok {
208+
// Check for spec structure (in-toto 0.0.2 entries)
209+
if spec, ok := body["spec"].(map[string]any); ok {
210+
if content, ok := spec["content"].(map[string]any); ok {
211211
if envelope, ok := content["envelope"].(map[string]any); ok {
212212
// Check if this has both payloadType and signatures (0.0.2)
213213
if _, hasPayloadType := envelope["payloadType"]; hasPayloadType {
@@ -310,14 +310,14 @@ func (r *RekorVSARetriever) buildDSSEEnvelopeFromIntotoV002(entry models.LogEntr
310310
}
311311

312312
// Navigate to the in-toto 0.0.2 structure
313-
intotoObj, ok := body["IntotoObj"].(map[string]interface{})
313+
spec, ok := body["spec"].(map[string]interface{})
314314
if !ok {
315-
return nil, fmt.Errorf("entry does not contain IntotoObj")
315+
return nil, fmt.Errorf("entry does not contain spec")
316316
}
317317

318-
content, ok := intotoObj["content"].(map[string]interface{})
318+
content, ok := spec["content"].(map[string]interface{})
319319
if !ok {
320-
return nil, fmt.Errorf("IntotoObj does not contain content")
320+
return nil, fmt.Errorf("spec does not contain content")
321321
}
322322

323323
envelopeData, ok := content["envelope"].(map[string]interface{})
@@ -338,8 +338,8 @@ func (r *RekorVSARetriever) buildDSSEEnvelopeFromIntotoV002(entry models.LogEntr
338338
if payload, ok := envelopeData["payload"].(string); ok && payload != "" {
339339
payloadB64 = payload
340340
} else if entry.Attestation != nil && entry.Attestation.Data != nil {
341-
// Fallback to Attestation.Data
342-
payloadB64 = base64.StdEncoding.EncodeToString(entry.Attestation.Data)
341+
// Fallback to Attestation.Data (already base64-encoded)
342+
payloadB64 = string(entry.Attestation.Data)
343343
} else {
344344
return nil, fmt.Errorf("no payload found in envelope or attestation data")
345345
}
@@ -454,7 +454,7 @@ func (rc *rekorClient) fetchLogEntriesParallel(ctx context.Context, uuids []stri
454454
wg.Add(1)
455455
go func(workerID int) {
456456
defer wg.Done()
457-
rc.worker(ctx, uuidChan, resultChan, errorChan, workerID)
457+
rc.worker(ctx, uuidChan, resultChan, workerID)
458458
}(i)
459459
}
460460

@@ -517,7 +517,7 @@ type fetchResult struct {
517517
}
518518

519519
// worker processes UUIDs from the input channel and sends results to the output channel
520-
func (rc *rekorClient) worker(ctx context.Context, uuidChan <-chan string, resultChan chan<- fetchResult, errorChan chan<- error, workerID int) {
520+
func (rc *rekorClient) worker(ctx context.Context, uuidChan <-chan string, resultChan chan<- fetchResult, workerID int) {
521521

522522
for uuid := range uuidChan {
523523
select {

internal/validate/vsa/rekor_retriever_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestRekorVSARetriever_ClassifyEntryKind(t *testing.T) {
7272
{
7373
name: "intoto 0.0.2 entry by body",
7474
entry: models.LogEntryAnon{
75-
Body: base64.StdEncoding.EncodeToString([]byte(`{"IntotoObj": {"content": {"envelope": {"payloadType": "application/vnd.in-toto+json", "signatures": [{"sig": "dGVzdA=="}]}}}}`)),
75+
Body: base64.StdEncoding.EncodeToString([]byte(`{"spec": {"content": {"envelope": {"payloadType": "application/vnd.in-toto+json", "signatures": [{"sig": "dGVzdA=="}]}}}}`)),
7676
},
7777
expected: "intoto-v002",
7878
},
@@ -123,7 +123,7 @@ func TestRekorVSARetriever_RetrieveVSA(t *testing.T) {
123123

124124
// Create in-toto 0.0.2 entry body
125125
intotoV002Body := `{
126-
"IntotoObj": {
126+
"spec": {
127127
"content": {
128128
"envelope": {
129129
"payloadType": "application/vnd.in-toto+json",
@@ -140,7 +140,7 @@ func TestRekorVSARetriever_RetrieveVSA(t *testing.T) {
140140
LogID: &[]string{"intoto-v002-uuid"}[0],
141141
Body: base64.StdEncoding.EncodeToString([]byte(intotoV002Body)),
142142
Attestation: &models.LogEntryAnonAttestation{
143-
Data: strfmt.Base64(vsaStatement),
143+
Data: strfmt.Base64(base64.StdEncoding.EncodeToString([]byte(vsaStatement))),
144144
},
145145
},
146146
},

0 commit comments

Comments
 (0)