diff --git a/app/cli/cmd/attestation_add.go b/app/cli/cmd/attestation_add.go index c8b1720cb..84e2f73ab 100644 --- a/app/cli/cmd/attestation_add.go +++ b/app/cli/cmd/attestation_add.go @@ -209,7 +209,7 @@ func displayMaterialInfo(status *action.AttestationStatusMaterial, policyEvaluat mt.AppendRow(table.Row{"Policy evaluations", "------"}) } - policiesTable(policyEvaluations, mt) + policiesTable(policyEvaluations, mt, flagDebug) mt.SetStyle(table.StyleLight) mt.Style().Options.SeparateRows = true mt.Render() diff --git a/app/cli/cmd/attestation_status.go b/app/cli/cmd/attestation_status.go index b6530a37e..382ac3755 100644 --- a/app/cli/cmd/attestation_status.go +++ b/app/cli/cmd/attestation_status.go @@ -138,7 +138,7 @@ func attestationStatusTableOutput(status *action.AttestationStatusResult, w io.W evs := status.PolicyEvaluations[chainloop.AttPolicyEvaluation] if len(evs) > 0 { gt.AppendRow(table.Row{"Policies", "------"}) - policiesTable(evs, gt) + policiesTable(evs, gt, flagDebug) } // Add the Attestation View URL if available @@ -242,7 +242,7 @@ func materialsTable(status *action.AttestationStatusResult, w io.Writer, full bo evs := status.PolicyEvaluations[m.Name] if len(evs) > 0 { mt.AppendRow(table.Row{"Policies", "------"}) - policiesTable(evs, mt) + policiesTable(evs, mt, flagDebug) } mt.AppendSeparator() diff --git a/app/cli/cmd/workflow_workflow_run_describe.go b/app/cli/cmd/workflow_workflow_run_describe.go index 0e2ede462..2f920094c 100644 --- a/app/cli/cmd/workflow_workflow_run_describe.go +++ b/app/cli/cmd/workflow_workflow_run_describe.go @@ -175,7 +175,7 @@ func workflowRunDescribeTableOutput(run *action.WorkflowRunItemFull) error { evs := att.PolicyEvaluations[chainloop.AttPolicyEvaluation] if len(evs) > 0 { gt.AppendRow(table.Row{"Policies", "------"}) - policiesTable(evs, gt) + policiesTable(evs, gt, flagDebug) } if run.Attestation.AttestationViewURL != "" { @@ -227,7 +227,7 @@ func predicateV1Table(att *action.WorkflowRunAttestationItem) { evs := att.PolicyEvaluations[m.Name] if len(evs) > 0 { mt.AppendRow(table.Row{"Policies", "------"}) - policiesTable(evs, mt) + policiesTable(evs, mt, flagDebug) } mt.AppendSeparator() } @@ -249,13 +249,21 @@ func predicateV1Table(att *action.WorkflowRunAttestationItem) { } } -func policiesTable(evs []*action.PolicyEvaluation, mt table.Writer) { +func policiesTable(evs []*action.PolicyEvaluation, mt table.Writer, debugMode bool) { for _, ev := range evs { msg := "" switch { case ev.Skipped: - msg = text.Colors{text.FgHiYellow}.Sprintf("skipped - %s", strings.Join(ev.SkipReasons, ", ")) + switch { + case len(ev.SkipReasons) == 1: + msg = text.Colors{text.FgHiYellow}.Sprintf("skipped - %s", ev.SkipReasons[0]) + case debugMode: + msg = text.Colors{text.FgHiYellow}.Sprintf("skipped - multiple reasons:\n - %s", + strings.Join(ev.SkipReasons, "\n - ")) + default: + msg = text.Colors{text.FgHiYellow}.Sprint("the policy was skipped in all execution paths") + } case len(ev.Violations) == 0: msg = text.Colors{text.FgHiGreen}.Sprint("Ok") case len(ev.Violations) > 0: