@@ -21,9 +21,12 @@ import (
2121 "fmt"
2222 "io"
2323 "os"
24+ "strings"
2425 "time"
2526
2627 "github.com/chainloop-dev/chainloop/app/cli/internal/action"
28+ v1 "github.com/chainloop-dev/chainloop/internal/attestation/crafter/api/attestation/v1"
29+ "github.com/chainloop-dev/chainloop/internal/attestation/renderer"
2730 "github.com/jedib0t/go-pretty/v6/table"
2831 "github.com/jedib0t/go-pretty/v6/text"
2932 "github.com/muesli/reflow/wrap"
@@ -193,6 +196,12 @@ func predicateV1Table(att *action.WorkflowRunAttestationItem) {
193196 mt .AppendRow (table.Row {"" , fmt .Sprintf ("%s: %s" , a .Name , a .Value )})
194197 }
195198 }
199+ evs := att .PolicyEvaluations [m .Name ].GetEvaluations ()
200+ if len (evs ) > 0 {
201+ mt .AppendSeparator ()
202+ mt .AppendRow (table.Row {"Policies" })
203+ policiesTable (evs , mt )
204+ }
196205 mt .AppendSeparator ()
197206 }
198207
@@ -211,6 +220,30 @@ func predicateV1Table(att *action.WorkflowRunAttestationItem) {
211220 }
212221 mt .Render ()
213222 }
223+
224+ evs := att .PolicyEvaluations [renderer .AttPolicyEvaluation ].GetEvaluations ()
225+ if len (evs ) > 0 {
226+ mt := newTableWriter ()
227+ mt .SetTitle ("Attestation policies" )
228+ policiesTable (evs , mt )
229+ mt .Render ()
230+ }
231+ }
232+
233+ func policiesTable (evs []* v1.PolicyEvaluation , mt table.Writer ) {
234+ for _ , ev := range evs {
235+ mt .AppendSeparator ()
236+ mt .AppendRow (table.Row {"Policy" , ev .Name })
237+ var violations []string
238+ if len (ev .Violations ) > 0 {
239+ for _ , v := range ev .Violations {
240+ violations = append (violations , v .Message )
241+ }
242+ } else {
243+ violations = append (violations , "None" )
244+ }
245+ mt .AppendRow (table.Row {"Violations" , fmt .Sprint (strings .Join (violations , "\n " ))})
246+ }
214247}
215248
216249func encodeAttestationOutput (run * action.WorkflowRunItemFull , writer io.Writer ) error {
0 commit comments