Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/cli/cmd/attestation_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions app/cli/cmd/attestation_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
16 changes: 12 additions & 4 deletions app/cli/cmd/workflow_workflow_run_describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down Expand Up @@ -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()
}
Expand All @@ -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:
Expand Down
Loading