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
5 changes: 3 additions & 2 deletions internal/cmd/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ func (ao *auditOpts) AddFlags(cmd *cobra.Command) {
func addAudit(parentCmd *cobra.Command) {
opts := &auditOpts{}
auditCmd := &cobra.Command{
Use: "audit",
Short: "Audits the SLSA properties and controls of a repository",
Use: "audit",
GroupID: "verification",
Short: "Verifies multiple commits in the branch history",
Long: `Checks the revisions on the specified branch within the repository.

Revisions 'pass' an audit if they have:
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var colorHiRed = color.New(color.FgHiRed).SprintFunc()

func addAuth(parentCmd *cobra.Command) {
authCmd := &cobra.Command{
GroupID: "configuration",
Short: "Manage user authentication",
Use: "auth",
SilenceUsage: false,
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/checklevel.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ func addCheckLevel(parentCmd *cobra.Command) {
opts := checkLevelOpts{}

checklevelCmd := &cobra.Command{
Use: "checklevel",
Short: "Determines the SLSA Source Level of the repo",
Use: "checklevel",
GroupID: "assessment",
Short: "Determines the SLSA Source Level of the repo",
Long: `Determines the SLSA Source Level of the repo.

This is meant to be run within the corresponding GitHub Actions workflow.`,
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/checklevelprov.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ func addCheckLevelProv(parentCmd *cobra.Command) {
opts := &checkLevelProvOpts{}

checklevelprovCmd := &cobra.Command{
Use: "checklevelprov",
Short: "Checks the given commit against policy using & creating provenance",
Use: "checklevelprov",
GroupID: "assessment",
Short: "Checks the given commit against policy using & creating provenance",
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
if err := opts.ParseLocator(args[0]); err != nil {
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/checktag.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ func addCheckTag(parentCmd *cobra.Command) {
opts := &checkTagOptions{}

checktagCmd := &cobra.Command{
Use: "checktag",
Short: "Checks to see if the tag operation should be allowed and issues a VSA",
Use: "checktag",
GroupID: "assessment",
Short: "Checks to see if the tag operation should be allowed and issues a VSA",
RunE: func(cmd *cobra.Command, args []string) error {
return doCheckTag(opts)
},
Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/createpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ func addCreatePolicy(parentCmd *cobra.Command) {
opts := createPolicyOptions{}

createpolicyCmd := &cobra.Command{
Use: "createpolicy",
Short: "Creates a policy in a local copy of source-policies",
Use: "createpolicy",
GroupID: "policy",
Short: "Creates a policy in a local copy of source-policies",
Long: `Creates a SLSA source policy in a local copy of source-policies.

The created policy should then be sent as a PR to slsa-framework/source-policies.`,
Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ func (pco *policyCreateOpts) AddFlags(cmd *cobra.Command) {

func addPolicy(parentCmd *cobra.Command) {
policyCmd := &cobra.Command{
Short: "tools to work with source policies",
GroupID: "policy",
Short: "tools to work with source policies",
Long: fmt.Sprintf(`
%s %s

Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/prov.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ func (po *provOptions) AddFlags(cmd *cobra.Command) {
func addProv(parentCmd *cobra.Command) {
opts := provOptions{}
provCmd := &cobra.Command{
Use: "prov",
Short: "Creates provenance for the given commit, but does not check policy.",
Use: "prov",
GroupID: "assessment",
Short: "Creates provenance for the given commit, but does not check policy.",
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
if err := opts.ParseLocator(args[0]); err != nil {
Expand Down
40 changes: 34 additions & 6 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,45 @@ controls and much more.

rootCmd.PersistentFlags().StringVar(&githubToken, "github_token", "", "the github token to use for auth")

addCheckLevel(rootCmd)
addCheckLevelProv(rootCmd)
// Define command groups for better organization
rootCmd.AddGroup(
&cobra.Group{
ID: "verification",
Title: "Verification Commands:",
},
&cobra.Group{
ID: "assessment",
Title: "Assessment Commands:",
},
&cobra.Group{
ID: "policy",
Title: "Policy Commands:",
},
&cobra.Group{
ID: "configuration",
Title: "Configuration & Setup Commands:",
},
)

// Verification commands
addVerifyCommit(rootCmd)
addStatus(rootCmd)
addSetup(rootCmd)
addAudit(rootCmd)
addProv(rootCmd)

// Assessment commands
addStatus(rootCmd)
addCheckLevel(rootCmd)
addCheckLevelProv(rootCmd)
addCheckTag(rootCmd)
addProv(rootCmd)

// Policy commands
addPolicy(rootCmd)
addCreatePolicy(rootCmd)

// Configuration & setup commands
addSetup(rootCmd)
addAuth(rootCmd)
addPolicy(rootCmd)

return rootCmd
}

Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func (so *setupOpts) Validate() error {

func addSetup(parentCmd *cobra.Command) {
setupCmd := &cobra.Command{
Short: "configure SLSA source features in a repository",
GroupID: "configuration",
Short: "configure SLSA source features in a repository",
Long: fmt.Sprintf(`
%s %s

Expand Down
3 changes: 2 additions & 1 deletion internal/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ func (so *statusOptions) AddFlags(cmd *cobra.Command) {
func addStatus(parentCmd *cobra.Command) {
opts := &statusOptions{}
statusCmd := &cobra.Command{
Short: "Check the SLSA Source status of a repo/branch",
GroupID: "assessment",
Short: "Check the SLSA Source status of a repo/branch",
Long: `
sourcetool status: Check the SLSA Source status of a repo/branch

Expand Down
5 changes: 3 additions & 2 deletions internal/cmd/verifycommit.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ func (vco *verifyCommitOptions) AddFlags(cmd *cobra.Command) {
func addVerifyCommit(cmd *cobra.Command) {
opts := verifyCommitOptions{}
verifyCommitCmd := &cobra.Command{
Use: "verifycommit",
Short: "Verifies the specified commit is valid",
Use: "verifycommit",
GroupID: "verification",
Short: "Verifies the specified commit is valid",
PreRunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
if err := opts.ParseLocator(args[0]); err != nil {
Expand Down
Loading