-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (39 loc) · 1.28 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package cmd
import (
"fmt"
"github.com/bzcorn/security-check-repo/checker"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var rootCmd = &cobra.Command{
Use: "security-check-repo",
Short: "security-check-repo checks if a project has had a commit in the last year",
Long: `A Fast and Flexible checker for security teams to quickly determine if
a project has had a commit in the last year. This can be useful to detect an abandoned
project that is no longer maintaining itself for security vulnerabilities.`,
Run: func(cmd *cobra.Command, args []string) {
repos := viper.GetStringSlice("repos")
repos = append(repos, args...)
if len(repos) < 1 {
fmt.Println("Please provide at least one repository.")
return
}
token := viper.GetString("token")
if token == "" {
fmt.Println("Please provide a GitHub Personal Access Token.")
return
}
checker.CheckRepos(repos, token)
},
}
func init() {
viper.SetConfigName("config") // name of config file (without extension)
viper.AddConfigPath(".") // path to look for the config file in
viper.AutomaticEnv() // read in environment variables that match
if err := viper.ReadInConfig(); err != nil {
fmt.Printf("Error reading config file, %s", err)
}
}
func Execute() {
cobra.CheckErr(rootCmd.Execute())
}