(logger *io.Handler, bundles []BundleInspection)
| 250 | } |
| 251 | |
| 252 | func printInspectionSummary(logger *io.Handler, bundles []BundleInspection) { |
| 253 | logger.Printf("Inspecting bundles…\n") |
| 254 | logger.Printf("Found %s:\n---\n", text.Pluralize(len(bundles), "attestation")) |
| 255 | |
| 256 | bundleSummaries := make([][][]string, len(bundles)) |
| 257 | for i, iB := range bundles { |
| 258 | bundleSummaries[i] = [][]string{ |
| 259 | {"Authentic", formatAuthentic(iB.Authentic, iB.Certificate.CertificateIssuer)}, |
| 260 | {"Source Repo", formatNwo(iB.Certificate.SourceRepositoryURI)}, |
| 261 | {"PredicateType", iB.Statement.GetPredicateType()}, |
| 262 | {"SubjectAlternativeName", iB.Certificate.SubjectAlternativeName}, |
| 263 | {"RunInvocationURI", iB.Certificate.RunInvocationURI}, |
| 264 | {"CertificateNotBefore", iB.Certificate.NotBefore.Format(time.RFC3339)}, |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | // "SubjectAlternativeName" has 22 chars |
| 269 | maxNameLength := 22 |
| 270 | |
| 271 | scheme := logger.ColorScheme |
| 272 | for i, bundle := range bundleSummaries { |
| 273 | for _, pair := range bundle { |
| 274 | colName := pair[0] |
| 275 | dots := maxNameLength - len(colName) |
| 276 | logger.OutPrintf("%s:%s %s\n", scheme.Bold(colName), strings.Repeat(".", dots), pair[1]) |
| 277 | } |
| 278 | if i < len(bundleSummaries)-1 { |
| 279 | logger.OutPrintln("---") |
| 280 | } |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | func formatNwo(longUrl string) string { |
| 285 | repo, err := ghrepo.FromFullName(longUrl) |
no test coverage detected