-
Notifications
You must be signed in to change notification settings - Fork 9
/
batten.go
57 lines (48 loc) · 1.29 KB
/
batten.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
package main
import (
"os"
"fmt"
"github.com/dockersecuritytools/batten/batten"
"github.com/dockersecuritytools/batten/cli"
"github.com/Sirupsen/logrus"
"gopkg.in/alecthomas/kingpin.v1"
)
const (
Name = "batten"
Description = "Hardening and Auditing Tool For Docker Hosts & Containers"
Version = "0.1.0"
)
var (
app = kingpin.New(Name, Description)
// appDebug = app.Flag("debug", "Enable debug mode.").Bool()
serverIP = app.Flag("server", "Connect to remote host.").String()
tlscacert = app.Flag("tlscacert", "TLS CA Certificate.").String()
tlscert = app.Flag("tlscert", "TLS Certificate.").String()
tlskey = app.Flag("tlskey", "TLS Key.").String()
appCheck = app.Command("check", "Check host for known issues.")
)
func fatalf(format string, args ...interface{}) {
fmt.Printf("* fatal: "+format+"\n", args...)
os.Exit(1)
}
func init() {
logrus.SetLevel(logrus.DebugLevel)
logrus.SetOutput(os.Stderr)
}
func main() {
kingpin.Version(Version)
args, err := app.Parse(os.Args[1:])
switch kingpin.MustParse(args, err) {
case appCheck.FullCommand():
if len(*serverIP) > 0 {
remoteCheck()
} else {
for i, check := range batten.Checks {
results := batten.RunCheck(check)
cli.FormatResultsForConsole(i, results)
}
}
default:
app.Usage(os.Stdout)
}
}