security fixes and branch listing
This commit is contained in:
parent
fc73cc3156
commit
ea3c106944
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
/vendor
|
/vendor
|
||||||
.idea/
|
.idea/
|
||||||
|
.cache.json
|
||||||
|
23
main.go
23
main.go
@ -16,11 +16,11 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Cache struct {
|
type Cache struct {
|
||||||
token string `json:token`
|
token string `json:"token"`
|
||||||
baseURL string `json:baseURL`
|
baseURL string `json:"baseURL"`
|
||||||
orgName string `json:orgName`
|
orgName string `json:"orgName"`
|
||||||
repoExclude string `json:repoExclude`
|
repoExclude string `json:"repoExclude"`
|
||||||
pullBaseBranch string `json:pullBaseBranch`
|
pullBaseBranch string `json:"pullBaseBranch"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadCache() (cache *Cache) {
|
func loadCache() (cache *Cache) {
|
||||||
@ -49,7 +49,7 @@ func saveCache(cache *Cache) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("ERROR: marshal cache: %v\n", err)
|
fmt.Printf("ERROR: marshal cache: %v\n", err)
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(".cache.json", data, 0666)
|
err = ioutil.WriteFile(".cache.json", data, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("ERROR: save cache: %v\n", err)
|
fmt.Printf("ERROR: save cache: %v\n", err)
|
||||||
}
|
}
|
||||||
@ -102,8 +102,9 @@ func main() {
|
|||||||
|
|
||||||
var repoList []*gitlab.Project
|
var repoList []*gitlab.Project
|
||||||
var page = 1
|
var page = 1
|
||||||
|
fmt.Printf("Retrieving repository list...\n")
|
||||||
for {
|
for {
|
||||||
fmt.Printf("Get Repo List Page %d", page)
|
fmt.Printf("%d", page)
|
||||||
repos, _, err := client.Groups.ListGroupProjects(org.ID, &gitlab.ListGroupProjectsOptions{
|
repos, _, err := client.Groups.ListGroupProjects(org.ID, &gitlab.ListGroupProjectsOptions{
|
||||||
ListOptions: gitlab.ListOptions{PerPage: 10, Page: page},
|
ListOptions: gitlab.ListOptions{PerPage: 10, Page: page},
|
||||||
Archived: optBool(false),
|
Archived: optBool(false),
|
||||||
@ -121,6 +122,7 @@ func main() {
|
|||||||
|
|
||||||
page++
|
page++
|
||||||
}
|
}
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
for i := range repoList {
|
for i := range repoList {
|
||||||
if !excludeRule.Match(repoList[i].Name) {
|
if !excludeRule.Match(repoList[i].Name) {
|
||||||
@ -140,7 +142,12 @@ func threatRepo(baseBranchRule glob.Glob, client *gitlab.Client, repo *gitlab.Pr
|
|||||||
error(10, "Could not obtain branch list from '%s': %v\n", repo.Name, err)
|
error(10, "Could not obtain branch list from '%s': %v\n", repo.Name, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(" found %d branches\n", len(branchList))
|
fmt.Printf(" found %d branches:", len(branchList))
|
||||||
|
fmt.Printf(" ")
|
||||||
|
for _, b := range branchList {
|
||||||
|
fmt.Printf("'%s' ", b.Name)
|
||||||
|
}
|
||||||
|
fmt.Println()
|
||||||
|
|
||||||
for _, baseBranch := range branchList {
|
for _, baseBranch := range branchList {
|
||||||
if baseBranchRule.Match(baseBranch.Name) && !baseBranch.Default {
|
if baseBranchRule.Match(baseBranch.Name) && !baseBranch.Default {
|
||||||
|
Loading…
Reference in New Issue
Block a user