-
Notifications
You must be signed in to change notification settings - Fork 76
/
go-earlybird.go
65 lines (55 loc) · 2.23 KB
/
go-earlybird.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
/*
* Copyright 2021 American Express
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package main
import (
"flag"
"os"
"github.com/americanexpress/earlybird/v4/pkg/core"
"github.com/americanexpress/earlybird/v4/pkg/scan"
"github.com/americanexpress/earlybird/v4/pkg/utils"
)
var (
eb core.EarlybirdCfg
ptr core.PTRHTTPConfig
gitcfg core.PTRGitConfig
)
func main() {
//Define HTTP server cli params
ptr.HTTP = flag.String("http", "", "Listen IP and Port for HTTP API e.g. 127.0.0.1:8080")
ptr.HTTPConfig = flag.String("http-config", "", "Path to webserver config JSON file")
ptr.HTTPS = flag.String("https", "", "Listen IP and Port for HTTPS/2 API e.g. 127.0.0.1:8080 (Don't forget the https-cert and https-key flags)")
ptr.HTTPSCert = flag.String("https-cert", "", "Certificate file for TLS")
ptr.HTTPSKey = flag.String("https-key", "", "Private key file for TLS")
//Define Git cli params
gitcfg.Project = flag.String("git-project", "", "Full URL to a github organization to scan e.g. github.com/org")
gitcfg.Repo = flag.String("git", "", "Full URL to a git repo to scan e.g. github.com/user/repo")
gitcfg.RepoUser = flag.String("git-user", os.Getenv("gituser"), "If the git repository is private, enter an authorized username")
gitcfg.RepoBranch = flag.String("git-branch", "", "Name of branch to be scanned")
//Load CLI params and Earlybird config
eb.ConfigInit()
//Load in the rules
scan.Init(eb.Config)
//Start earlybird webserver when parameters provided
if *ptr.HTTP != "" || *ptr.HTTPS != "" {
eb.StartHTTP(ptr)
}
//Clone the repository we're scanning when param provided
eb.GitClone(gitcfg)
//Scan delete anything
eb.Scan()
//Delete any left over git data
utils.DeleteGit(*gitcfg.Repo, eb.Config.SearchDir)
}