Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
Print out metadata information about profiles and catalogs
Browse files Browse the repository at this point in the history
  • Loading branch information
isimluk committed Jan 14, 2020
1 parent 8d787e6 commit 52e8b9e
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions cli/cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/docker/oscalkit/generator"
"github.com/docker/oscalkit/types/oscal"
"github.com/docker/oscalkit/types/oscal/catalog"
"github.com/urfave/cli"
)

Expand Down Expand Up @@ -36,15 +37,39 @@ var Info = cli.Command{
return cli.NewExitError(err, 1)
}
if o.Profile != nil {
fmt.Println("OSCAL Profile")
fmt.Println("OSCAL Profile (represents subset of controls from OSCAL catalog(s))")
fmt.Println("ID:\t", o.Profile.Id)
printMetadata(o.Profile.Metadata)
return nil
}
if o.Catalog != nil {
fmt.Println("OSCAL Catalog")
fmt.Println("OSCAL Catalog (represents library of control assessment objectives and activities)")
fmt.Println("ID:\t", o.Catalog.Id)
printMetadata(o.Catalog.Metadata)
return nil
}
return cli.NewExitError("Unrecognized OSCAL resource", 1)
}
return cli.NewExitError("No file provided", 1)
},
}

func printMetadata(m *catalog.Metadata) {
if m == nil {
return
}
fmt.Println("Metadata:")
fmt.Println("\tTitle:\t\t\t", m.Title)
if m.Published != "" {
fmt.Println("\tPublished:\t\t", m.Published)
}
if m.LastModified != "" {
fmt.Println("\tLast Modified:\t\t", m.LastModified)
}
if m.Version != "" {
fmt.Println("\tDocument Version:\t", m.Version)
}
if m.OscalVersion != "" {
fmt.Println("\tOSCAL Version:\t\t", m.OscalVersion)
}
}

0 comments on commit 52e8b9e

Please sign in to comment.