mirror of
https://github.com/gitleaks/gitleaks.git
synced 2026-11-28 20:24:22 +01:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
725da55905 | ||
|
|
cfac551ab8 | ||
|
|
c559fdbf04 | ||
|
|
e2ac47cd06 | ||
|
|
8ef16d9efb |
No files matched your search
+2
-3
@@ -1,8 +1,7 @@
|
|||||||
sudo: required
|
|
||||||
language: go
|
language: go
|
||||||
go:
|
go:
|
||||||
- 1.13
|
- 1.13.x
|
||||||
services:
|
services:
|
||||||
- docker
|
- docker
|
||||||
script:
|
script:
|
||||||
- env GO111MODULE=on make test
|
- make test
|
||||||
+2
-3
@@ -1,9 +1,9 @@
|
|||||||
FROM golang:1.13.0 AS build
|
FROM golang:1.13.4 AS build
|
||||||
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
WORKDIR /go/src/github.com/zricethezav/gitleaks
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks *.go
|
RUN GO111MODULE=on CGO_ENABLED=0 go build -o bin/gitleaks *.go
|
||||||
|
|
||||||
FROM alpine:3.7
|
FROM alpine:3.10
|
||||||
RUN apk add --no-cache bash git openssh
|
RUN apk add --no-cache bash git openssh
|
||||||
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
|
COPY --from=build /go/src/github.com/zricethezav/gitleaks/bin/* /usr/bin/
|
||||||
ENTRYPOINT ["gitleaks"]
|
ENTRYPOINT ["gitleaks"]
|
||||||
@@ -14,4 +14,3 @@ ENTRYPOINT ["gitleaks"]
|
|||||||
# docker run --rm --name=gitleaks gitleaks --repo=https://github.com/zricethezav/gitleaks
|
# docker run --rm --name=gitleaks gitleaks --repo=https://github.com/zricethezav/gitleaks
|
||||||
|
|
||||||
# This will check for secrets in https://github.com/zricethezav/gitleaks
|
# This will check for secrets in https://github.com/zricethezav/gitleaks
|
||||||
|
|
||||||
+4
-3
@@ -2,11 +2,12 @@ package audit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Run accepts a manager and begins an audit based on the options/configs set in the manager.
|
// Run accepts a manager and begins an audit based on the options/configs set in the manager.
|
||||||
|
|||||||
+21
-12
@@ -4,23 +4,25 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
"github.com/sergi/go-diff/diffmatchpatch"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
|
||||||
"gopkg.in/src-d/go-billy.v4"
|
|
||||||
"gopkg.in/src-d/go-git.v4"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/storer"
|
|
||||||
"gopkg.in/src-d/go-git.v4/storage/memory"
|
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/config"
|
||||||
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
|
|
||||||
|
"github.com/BurntSushi/toml"
|
||||||
|
"github.com/sergi/go-diff/diffmatchpatch"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"gopkg.in/src-d/go-billy.v4"
|
||||||
|
"gopkg.in/src-d/go-git.v4"
|
||||||
|
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||||
|
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||||
|
"gopkg.in/src-d/go-git.v4/plumbing/storer"
|
||||||
|
"gopkg.in/src-d/go-git.v4/storage/memory"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Repo wraps a *git.Repository object in addition to a manager object and the name of the repo.
|
// Repo wraps a *git.Repository object in addition to a manager object and the name of the repo.
|
||||||
@@ -209,7 +211,6 @@ func (repo *Repo) Audit() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//checker := make(map[string]bool)
|
|
||||||
cc := 0
|
cc := 0
|
||||||
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
|
semaphore := make(chan bool, howManyThreads(repo.Manager.Opts.Threads))
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
@@ -233,6 +234,14 @@ func (repo *Repo) Audit() error {
|
|||||||
|
|
||||||
cc++
|
cc++
|
||||||
err = c.Parents().ForEach(func(parent *object.Commit) error {
|
err = c.Parents().ForEach(func(parent *object.Commit) error {
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
// sometimes the patch generation will fail due to a known bug in
|
||||||
|
// sergi's go-diff: https://github.com/sergi/go-diff/issues/89.
|
||||||
|
// Once a fix has been merged I will remove this recover.
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
patch, err := c.Patch(parent)
|
patch, err := c.Patch(parent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+11
-10
@@ -2,19 +2,20 @@ package audit
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
|
||||||
"gopkg.in/src-d/go-git.v4"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
|
||||||
fdiff "gopkg.in/src-d/go-git.v4/plumbing/format/diff"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
|
||||||
"math"
|
"math"
|
||||||
"path"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/config"
|
||||||
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"gopkg.in/src-d/go-git.v4"
|
||||||
|
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||||
|
fdiff "gopkg.in/src-d/go-git.v4/plumbing/format/diff"
|
||||||
|
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxLineLen = 200
|
const maxLineLen = 200
|
||||||
@@ -59,9 +60,9 @@ func getFileName(f fdiff.FilePatch) string {
|
|||||||
fn := "???"
|
fn := "???"
|
||||||
from, to := f.Files()
|
from, to := f.Files()
|
||||||
if from != nil {
|
if from != nil {
|
||||||
return path.Base(from.Path())
|
return from.Path()
|
||||||
} else if to != nil {
|
} else if to != nil {
|
||||||
return path.Base(to.Path())
|
return to.Path()
|
||||||
}
|
}
|
||||||
|
|
||||||
return fn
|
return fn
|
||||||
|
|||||||
+4
-2
@@ -2,11 +2,13 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/BurntSushi/toml"
|
|
||||||
"github.com/zricethezav/gitleaks/options"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/options"
|
||||||
|
|
||||||
|
"github.com/BurntSushi/toml"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Whitelist is struct containing items that if encountered will whitelist
|
// Whitelist is struct containing items that if encountered will whitelist
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module github.com/zricethezav/gitleaks
|
module github.com/zricethezav/gitleaks
|
||||||
|
|
||||||
go 1.12
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
|
|||||||
+7
-5
@@ -2,18 +2,20 @@ package hosts
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/google/go-github/github"
|
"strconv"
|
||||||
log "github.com/sirupsen/logrus"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/audit"
|
"github.com/zricethezav/gitleaks/audit"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/options"
|
||||||
|
|
||||||
|
"github.com/google/go-github/github"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
"golang.org/x/oauth2"
|
"golang.org/x/oauth2"
|
||||||
"gopkg.in/src-d/go-git.v4"
|
"gopkg.in/src-d/go-git.v4"
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing"
|
"gopkg.in/src-d/go-git.v4/plumbing"
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
"gopkg.in/src-d/go-git.v4/plumbing/object"
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"sync"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Github wraps a github client and manager. This struct implements what the Host interface defines.
|
// Github wraps a github client and manager. This struct implements what the Host interface defines.
|
||||||
|
|||||||
+5
-3
@@ -2,12 +2,14 @@ package hosts
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
log "github.com/sirupsen/logrus"
|
"sync"
|
||||||
"github.com/xanzy/go-gitlab"
|
|
||||||
"github.com/zricethezav/gitleaks/audit"
|
"github.com/zricethezav/gitleaks/audit"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/options"
|
||||||
"sync"
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/xanzy/go-gitlab"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gitlab wraps a gitlab client and manager. This struct implements what the Host interface defines.
|
// Gitlab wraps a gitlab client and manager. This struct implements what the Host interface defines.
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/hako/durafmt"
|
"io/ioutil"
|
||||||
log "github.com/sirupsen/logrus"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/zricethezav/gitleaks/audit"
|
"github.com/zricethezav/gitleaks/audit"
|
||||||
"github.com/zricethezav/gitleaks/config"
|
"github.com/zricethezav/gitleaks/config"
|
||||||
"github.com/zricethezav/gitleaks/hosts"
|
"github.com/zricethezav/gitleaks/hosts"
|
||||||
"github.com/zricethezav/gitleaks/manager"
|
"github.com/zricethezav/gitleaks/manager"
|
||||||
"github.com/zricethezav/gitleaks/options"
|
"github.com/zricethezav/gitleaks/options"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"github.com/hako/durafmt"
|
||||||
"time"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|||||||
+8
-6
@@ -6,18 +6,20 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hako/durafmt"
|
|
||||||
"github.com/mattn/go-colorable"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/config"
|
|
||||||
"github.com/zricethezav/gitleaks/options"
|
|
||||||
"gopkg.in/src-d/go-git.v4"
|
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"runtime"
|
"runtime"
|
||||||
"sync"
|
"sync"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/config"
|
||||||
|
"github.com/zricethezav/gitleaks/options"
|
||||||
|
|
||||||
|
"github.com/hako/durafmt"
|
||||||
|
"github.com/mattn/go-colorable"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"gopkg.in/src-d/go-git.v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Manager is a struct containing options and configs as well CloneOptions and CloneDir.
|
// Manager is a struct containing options and configs as well CloneOptions and CloneDir.
|
||||||
|
|||||||
+13
-7
@@ -2,16 +2,18 @@ package options
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/jessevdk/go-flags"
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/zricethezav/gitleaks/version"
|
|
||||||
"gopkg.in/src-d/go-git.v4"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
|
|
||||||
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"os/user"
|
"os/user"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/zricethezav/gitleaks/version"
|
||||||
|
|
||||||
|
"github.com/jessevdk/go-flags"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
"gopkg.in/src-d/go-git.v4"
|
||||||
|
"gopkg.in/src-d/go-git.v4/plumbing/transport/http"
|
||||||
|
"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
|
||||||
)
|
)
|
||||||
|
|
||||||
// No leaks or early exit due to invalid options
|
// No leaks or early exit due to invalid options
|
||||||
@@ -72,7 +74,11 @@ func ParseOptions() (Options, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if opts.Version {
|
if opts.Version {
|
||||||
fmt.Printf("%s\n", version.Version)
|
if version.Version == "" {
|
||||||
|
fmt.Println("Gitleaks uses LDFLAGS to pull most recent version. Build with 'make build' for version")
|
||||||
|
} else {
|
||||||
|
fmt.Printf("%s\n", version.Version)
|
||||||
|
}
|
||||||
os.Exit(Success)
|
os.Exit(Success)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user