From 3ea24b4c71c35ede3096ad20b2cf5322c39024bd Mon Sep 17 00:00:00 2001 From: Jawed khelil Date: Tue, 12 Nov 2024 13:41:03 +0100 Subject: [PATCH] fix nil pointer --- pkg/chains/formats/slsa/v1/pipelinerun/pipelinerun.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/chains/formats/slsa/v1/pipelinerun/pipelinerun.go b/pkg/chains/formats/slsa/v1/pipelinerun/pipelinerun.go index 62690efb7c..f6b5eaa1f4 100644 --- a/pkg/chains/formats/slsa/v1/pipelinerun/pipelinerun.go +++ b/pkg/chains/formats/slsa/v1/pipelinerun/pipelinerun.go @@ -119,12 +119,16 @@ func buildConfig(ctx context.Context, pro *objects.PipelineRunObjectV1Beta1) Bui steps := []attest.StepAttestation{} // tr.Status.TaskSpec.Steps and tr.Status.Steps should be sime size - if tr.Status.TaskSpec == nil || len(tr.Status.TaskSpec.Steps) != len(tr.Status.Steps) { + if tr.Status.TaskSpec == nil { + logger.Errorf("TaskSpec is nil for task run %s. Skipping this task run.", tr.Name) + continue + } + + if len(tr.Status.TaskSpec.Steps) != len(tr.Status.Steps) { logger.Errorf("Mismatch in number of steps for task run %s. TaskSpec steps: %d, Status steps: %d", tr.Name, len(tr.Status.TaskSpec.Steps), len(tr.Status.Steps)) - continue // Skip this task run entirely + continue } - // Validate and process steps valid := true for i, step := range tr.Status.TaskSpec.Steps {