4
0
Эх сурвалжийг харах

updating changelog, readme, some other things

zach rice 7 жил өмнө
parent
commit
23489f3f18
4 өөрчлөгдсөн 28 нэмэгдсэн , 3 устгасан
  1. 1 0
      CHANGELOG.md
  2. 1 0
      README.md
  3. 22 0
      gitleaks_test.go
  4. 4 3
      main.go

+ 1 - 0
CHANGELOG.md

@@ -4,6 +4,7 @@ CHANGELOG
 1.13.0
 1.13.0
 ----
 ----
 - Github PR support
 - Github PR support
+- Github has its own go file. All other services, bitbucket, gitlab, etc should follow this convention
 
 
 1.12.1
 1.12.1
 ----
 ----

+ 1 - 0
README.md

@@ -29,6 +29,7 @@ Application Options:
       --github-user=   Github user to audit
       --github-user=   Github user to audit
       --github-org=    Github organization to audit
       --github-org=    Github organization to audit
       --github-url=    GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/ (default: https://api.github.com/)
       --github-url=    GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/ (default: https://api.github.com/)
+      --github-pr=     Github PR url to audit. This does not clone the repo. GITHUB_TOKEN must be set
   -p, --private        Include private repos in audit
   -p, --private        Include private repos in audit
   -b, --branch=        branch name to audit (defaults to HEAD)
   -b, --branch=        branch name to audit (defaults to HEAD)
   -c, --commit=        sha of commit to stop at
   -c, --commit=        sha of commit to stop at

+ 22 - 0
gitleaks_test.go

@@ -198,6 +198,7 @@ func TestRun(t *testing.T) {
 		whiteListRepos []string
 		whiteListRepos []string
 		numLeaks       int
 		numLeaks       int
 		configPath     string
 		configPath     string
+		commitPerPage  int
 	}{
 	}{
 		{
 		{
 			testOpts: Options{
 			testOpts: Options{
@@ -293,6 +294,23 @@ func TestRun(t *testing.T) {
 			numLeaks:       0,
 			numLeaks:       0,
 			expectedErrMsg: "",
 			expectedErrMsg: "",
 		},
 		},
+		{
+			testOpts: Options{
+				GithubPR: "https://github.com/gitleakstest/gronit/pull/1",
+			},
+			description:    "test github pr",
+			numLeaks:       4,
+			expectedErrMsg: "",
+		},
+		{
+			testOpts: Options{
+				GithubPR: "https://github.com/gitleakstest/gronit/pull/1",
+			},
+			description:    "test github pr",
+			numLeaks:       4,
+			expectedErrMsg: "",
+			commitPerPage:  1,
+		},
 	}
 	}
 	g := goblin.Goblin(t)
 	g := goblin.Goblin(t)
 	for _, test := range tests {
 	for _, test := range tests {
@@ -301,12 +319,16 @@ func TestRun(t *testing.T) {
 				if test.configPath != "" {
 				if test.configPath != "" {
 					os.Setenv("GITLEAKS_CONFIG", test.configPath)
 					os.Setenv("GITLEAKS_CONFIG", test.configPath)
 				}
 				}
+				if test.commitPerPage != 0 {
+					githubPages = test.commitPerPage
+				}
 				opts = test.testOpts
 				opts = test.testOpts
 				leaks, err := run()
 				leaks, err := run()
 				if err != nil {
 				if err != nil {
 					g.Assert(err.Error()).Equal(test.expectedErrMsg)
 					g.Assert(err.Error()).Equal(test.expectedErrMsg)
 				}
 				}
 				g.Assert(len(leaks)).Equal(test.numLeaks)
 				g.Assert(len(leaks)).Equal(test.numLeaks)
+				githubPages = 100
 			})
 			})
 		})
 		})
 	}
 	}

+ 4 - 3
main.go

@@ -63,7 +63,7 @@ type Options struct {
 	GithubUser     string `long:"github-user" description:"Github user to audit"`
 	GithubUser     string `long:"github-user" description:"Github user to audit"`
 	GithubOrg      string `long:"github-org" description:"Github organization to audit"`
 	GithubOrg      string `long:"github-org" description:"Github organization to audit"`
 	GithubURL      string `long:"github-url" default:"https://api.github.com/" description:"GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/"`
 	GithubURL      string `long:"github-url" default:"https://api.github.com/" description:"GitHub API Base URL, use for GitHub Enterprise. Example: https://github.example.com/api/v3/"`
-	GithubPR       string `long:"github-pr" description:"Github PR number to audit. This does not clone the repo."`
+	GithubPR       string `long:"github-pr" description:"Github PR url to audit. This does not clone the repo. GITHUB_TOKEN must be set"`
 	IncludePrivate bool   `short:"p" long:"private" description:"Include private repos in audit"`
 	IncludePrivate bool   `short:"p" long:"private" description:"Include private repos in audit"`
 
 
 	/*
 	/*
@@ -240,10 +240,11 @@ func main() {
 	if opts.Report != "" {
 	if opts.Report != "" {
 		writeReport(leaks)
 		writeReport(leaks)
 	}
 	}
-	log.Infof("%d commits inspected in %s", totalCommits, durafmt.Parse(time.Now().Sub(now)).String())
 	if len(leaks) != 0 {
 	if len(leaks) != 0 {
-		log.Warnf("%d leaks detected", len(leaks))
+		log.Warnf("%d leaks detected. %d commits inspected in %s", len(leaks), totalCommits, durafmt.Parse(time.Now().Sub(now)).String())
 		os.Exit(leakExit)
 		os.Exit(leakExit)
+	} else {
+		log.Infof("%d leaks detected. %d commits inspected in %s", len(leaks), totalCommits, durafmt.Parse(time.Now().Sub(now)).String())
 	}
 	}
 }
 }