-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
163 lines (152 loc) · 4.09 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package main
import (
"encoding/gob"
"net/http"
"os"
"time"
"github.com/pterm/pterm"
"github.com/urfave/cli/v2"
"gitlab.com/jstang/rasic/commands"
"gitlab.com/jstang/rasic/types"
)
// passed with ldflag
var appVersion string
// register types to gob
// this is required to proper serialize and deserialize the data
func init() {
gob.Register(http.DefaultClient)
gob.Register(types.RasicIssue{})
gob.Register(types.RasicIssueUpdate{})
gob.Register(types.RasicLabel{})
gob.Register(types.RasicProject{})
gob.Register(types.RasicRepository{})
gob.Register(map[string]interface{}{})
}
func main() {
// determine current user dir
// this is required for the pluginhome directory
// userHome, homeErr := os.UserHomeDir()
// if homeErr != nil {
// pterm.Error.Println(homeErr)
// }
app := &cli.App{
Name: "rasic",
HelpName: "",
Usage: "create issues from known cve's",
UsageText: "",
ArgsUsage: "",
Version: appVersion,
Description: "a simple app to create issues for known cve's or config flaws",
Commands: []*cli.Command{},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "source",
Aliases: []string{},
Usage: "specify the source of your files (gitlab, github)",
EnvVars: []string{"RASIC_SOURCE"},
FilePath: "",
Required: false,
Hidden: false,
TakesFile: false,
Value: "gitlab",
DefaultText: "",
Destination: new(string),
HasBeenSet: false,
},
&cli.StringFlag{
Name: "reporter",
Aliases: []string{},
Usage: "specify the platform to create issues in (gitlab, github, jira)",
EnvVars: []string{"RASIC_REPORTER"},
FilePath: "",
Required: false,
Hidden: false,
TakesFile: false,
Value: "gitlab",
DefaultText: "",
Destination: new(string),
HasBeenSet: false,
},
&cli.StringFlag{
Name: "scanner",
Aliases: []string{},
Usage: "specify the scanner tool (trivy, tfsec...)",
EnvVars: []string{"RASIC_SCANNER"},
FilePath: "",
Required: false,
Hidden: false,
TakesFile: false,
Value: "trivy",
DefaultText: "",
Destination: new(string),
HasBeenSet: false,
},
&cli.StringFlag{
Name: "pluginhome",
Aliases: []string{},
Usage: "lookup homebrew user dir for plugins",
EnvVars: []string{"HOMEBREW_PREFIX"},
FilePath: "",
Required: true,
Hidden: false,
TakesFile: false,
// TODO: rework plugin feature to use a user home based pathing.
// for now homebrew's user home is the base for our plugins.
// Value: userHome + "/.rasic/plugins/",
Value: "",
DefaultText: "",
Destination: new(string),
HasBeenSet: false,
},
},
EnableBashCompletion: false,
HideHelp: false,
HideHelpCommand: false,
HideVersion: false,
BashComplete: func(*cli.Context) {
},
Before: func(*cli.Context) error {
return nil
},
After: func(*cli.Context) error {
return nil
},
Action: func(*cli.Context) error {
return nil
},
CommandNotFound: func(*cli.Context, string) {
},
OnUsageError: func(context *cli.Context, err error, isSubcommand bool) error {
return nil
},
Compiled: time.Now(),
Authors: []*cli.Author{{Name: "Johannes Stang", Email: "tubenhirn@gmail.com"}},
Copyright: "(c) 2022 tubenhirn.com",
Reader: nil,
Writer: nil,
ErrWriter: nil,
ExitErrHandler: func(context *cli.Context, err error) {
},
Metadata: map[string]interface{}{},
ExtraInfo: func() map[string]string {
return nil
},
CustomAppHelpTemplate: "",
UseShortOptionHandling: false,
}
app.Commands = append(app.Commands, commands.Scan())
app.Commands = append(app.Commands, commands.Projects())
app.Commands = append(app.Commands, commands.Issues())
app.EnableBashCompletion = true
app.Action = func(c *cli.Context) error {
err := cli.ShowAppHelp(c)
if err != nil {
pterm.Error.Println(err)
}
return nil
}
err := app.Run(os.Args)
if err != nil {
pterm.Error.Println(err)
}
}