Skip to content

Commit a8f07c8

Browse files
Automatically update trufflehog (#121)
Co-authored-by: Dustin Decker <[email protected]>
1 parent aea9374 commit a8f07c8

File tree

6 files changed

+232
-2
lines changed

6 files changed

+232
-2
lines changed

.goreleaser.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
builds:
2+
ldflags:
3+
- -X 'github.com/trufflesecurity/trufflehog/v3/pkg/version.BuildVersion={{ .Version }}'
24
- env: [CGO_ENABLED=0]
35
binary: trufflehog
46
goos:
@@ -42,4 +44,4 @@ docker_manifests:
4244
- name_template: ghcr.io/trufflesecurity/{{ .ProjectName }}:latest
4345
image_templates:
4446
- ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}-amd64
45-
- ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}-arm64v8
47+
- ghcr.io/trufflesecurity/{{ .ProjectName }}:{{ .Version }}-arm64v8

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ go 1.17
44

55
replace github.com/gitleaks/go-gitdiff => github.com/bill-rich/go-gitdiff v0.7.6-custom1
66

7+
replace github.com/jpillora/overseer => github.com/dustin-decker/overseer v1.1.7-custom2
8+
79
require (
810
cloud.google.com/go/secretmanager v1.3.0
911
github.com/Azure/go-autorest/autorest/azure/auth v0.5.11
@@ -13,6 +15,7 @@ require (
1315
github.com/aws/aws-sdk-go-v2/service/sts v1.16.2
1416
github.com/bitfinexcom/bitfinex-api-go v0.0.0-20210608095005-9e0b26f200fb
1517
github.com/bradleyfalzon/ghinstallation/v2 v2.0.4
18+
github.com/denisbrodbeck/machineid v1.0.1
1619
github.com/envoyproxy/protoc-gen-validate v0.6.7
1720
github.com/fatih/color v1.13.0
1821
github.com/felixge/fgprof v0.9.2
@@ -25,6 +28,7 @@ require (
2528
github.com/h2non/filetype v1.1.3
2629
github.com/hashicorp/go-retryablehttp v0.7.0
2730
github.com/joho/godotenv v1.4.0
31+
github.com/jpillora/overseer v1.1.6
2832
github.com/kylelemons/godebug v1.1.0
2933
github.com/mattn/go-colorable v0.1.12
3034
github.com/paulbellamy/ratecounter v0.2.0
@@ -70,6 +74,7 @@ require (
7074
github.com/emirpasic/gods v1.12.0 // indirect
7175
github.com/go-git/gcfg v1.5.0 // indirect
7276
github.com/go-git/go-billy/v5 v5.3.1 // indirect
77+
github.com/go-ole/go-ole v1.2.6 // indirect
7378
github.com/golang-jwt/jwt/v4 v4.2.0 // indirect
7479
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
7580
github.com/golang/protobuf v1.5.2 // indirect
@@ -82,6 +87,7 @@ require (
8287
github.com/imdario/mergo v0.3.12 // indirect
8388
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
8489
github.com/jmespath/go-jmespath v0.4.0 // indirect
90+
github.com/jpillora/s3 v1.1.4 // indirect
8591
github.com/json-iterator/go v1.1.11 // indirect
8692
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
8793
github.com/mattn/go-isatty v0.0.14 // indirect
@@ -90,6 +96,7 @@ require (
9096
github.com/modern-go/reflect2 v1.0.1 // indirect
9197
github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7 // indirect
9298
github.com/xanzy/ssh-agent v0.3.0 // indirect
99+
github.com/yusufpapurcu/wmi v1.2.2 // indirect
93100
go.opencensus.io v0.23.0 // indirect
94101
golang.org/x/mod v0.5.0 // indirect
95102
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 // indirect

go.sum

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,12 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
146146
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
147147
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
148148
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
149+
github.com/denisbrodbeck/machineid v1.0.1 h1:geKr9qtkB876mXguW2X6TU4ZynleN6ezuMSRhl4D7AQ=
150+
github.com/denisbrodbeck/machineid v1.0.1/go.mod h1:dJUwb7PTidGDeYyUBmXZ2GphQBbjJCrnectwCyxcUSI=
149151
github.com/dimchansky/utfbom v1.1.1 h1:vV6w1AhK4VMnhBno/TPVCoK9U/LP0PkLCS9tbxHdi/U=
150152
github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE=
153+
github.com/dustin-decker/overseer v1.1.7-custom2 h1:k6lSAUkdxnICmN5/sEsCKFVYchv2wBfogAdwONk39y0=
154+
github.com/dustin-decker/overseer v1.1.7-custom2/go.mod h1:nT9w37AiO1Nop2VhVhNfzAFaPjthvxgpDV3XKsxYkcI=
151155
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
152156
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
153157
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -186,6 +190,8 @@ github.com/go-git/go-git/v5 v5.4.2/go.mod h1:gQ1kArt6d+n+BGd+/B/I74HwRTLhth2+zti
186190
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
187191
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
188192
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
193+
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
194+
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
189195
github.com/gobwas/httphead v0.0.0-20200921212729-da3d93bc3c58/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
190196
github.com/gobwas/pool v0.2.1/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
191197
github.com/gobwas/ws v1.0.4/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
@@ -331,6 +337,8 @@ github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGw
331337
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
332338
github.com/joho/godotenv v1.4.0 h1:3l4+N6zfMWnkbPEXKng2o2/MR5mSwTrBih4ZEkkz1lg=
333339
github.com/joho/godotenv v1.4.0/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
340+
github.com/jpillora/s3 v1.1.4 h1:YCCKDWzb/Ye9EBNd83ATRF/8wPEy0xd43Rezb6u6fzc=
341+
github.com/jpillora/s3 v1.1.4/go.mod h1:yedE603V+crlFi1Kl/5vZJaBu9pUzE9wvKegU/lF2zs=
334342
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
335343
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
336344
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
@@ -416,7 +424,11 @@ github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMB
416424
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
417425
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
418426
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
427+
github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w=
428+
github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
419429
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
430+
github.com/smartystreets/gunit v1.1.3 h1:32x+htJCu3aMswhPw3teoJ+PnWPONqdNgaGs6Qt8ZaU=
431+
github.com/smartystreets/gunit v1.1.3/go.mod h1:EH5qMBab2UclzXUcpR8b93eHsIlp9u+pDQIRp5DZNzQ=
420432
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
421433
github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4=
422434
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
@@ -447,6 +459,8 @@ github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
447459
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
448460
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
449461
github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
462+
github.com/yusufpapurcu/wmi v1.2.2 h1:KBNDSne4vP5mbSWnJbO+51IMOXJB67QiYCSBrubbPRg=
463+
github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
450464
github.com/zricethezav/gitleaks/v8 v8.5.2 h1:+IiLvmBiMGetpgNtzC71EHktTXc1Zt7m9AwnqhhJ04g=
451465
github.com/zricethezav/gitleaks/v8 v8.5.2/go.mod h1:TxBuxH8eB/1la8Mc7I6j/ZZYNG/mHGpoi09N2oHx5nQ=
452466
go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=

main.go

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"gopkg.in/alecthomas/kingpin.v2"
87
"log"
98
"net/http"
109
_ "net/http/pprof"
1110
"os"
1211
"runtime"
1312
"strconv"
1413
"strings"
14+
"syscall"
1515
"time"
1616

17+
"github.com/jpillora/overseer"
18+
"github.com/trufflesecurity/trufflehog/v3/pkg/updater"
19+
"github.com/trufflesecurity/trufflehog/v3/pkg/version"
20+
"gopkg.in/alecthomas/kingpin.v2"
21+
1722
"github.com/felixge/fgprof"
1823

1924
"github.com/gorilla/mux"
@@ -25,9 +30,91 @@ import (
2530
"github.com/trufflesecurity/trufflehog/v3/pkg/sources/git"
2631
)
2732

33+
var (
34+
cli = kingpin.New("TruffleHog", "TruffleHog is a tool for finding credentials.")
35+
cmd string
36+
debug = cli.Flag("debug", "Run in debug mode").Bool()
37+
versionFlag = cli.Flag("version", "Prints trufflehog version.").Bool()
38+
jsonOut = cli.Flag("json", "Output in JSON format.").Short('j').Bool()
39+
jsonLegacy = cli.Flag("json-legacy", "Use the pre-v3.0 JSON format. Only works with git, gitlab, and github sources.").Bool()
40+
concurrency = cli.Flag("concurrency", "Number of concurrent workers.").Default(strconv.Itoa(runtime.NumCPU())).Int()
41+
noVerification = cli.Flag("no-verification", "Don't verify the results.").Bool()
42+
onlyVerified = cli.Flag("only-verified", "Only output verified results.").Bool()
43+
// rules = cli.Flag("rules", "Path to file with custom rules.").String()
44+
printAvgDetectorTime = cli.Flag("print-avg-detector-time", "Print the average time spent on each detector.").Bool()
45+
noUpdate = cli.Flag("no-update", "Don't check for updates.").Bool()
46+
47+
gitScan = cli.Command("git", "Find credentials in git repositories.")
48+
gitScanURI = gitScan.Arg("uri", "Git repository URL. https:// or file:// schema expected.").Required().String()
49+
gitScanIncludePaths = gitScan.Flag("include-paths", "Path to file with newline separated regexes for files to include in scan.").Short('i').String()
50+
gitScanExcludePaths = gitScan.Flag("exclude-paths", "Path to file with newline separated regexes for files to exclude in scan.").Short('x').String()
51+
gitScanSinceCommit = gitScan.Flag("since-commit", "Commit to start scan from.").String()
52+
gitScanBranch = gitScan.Flag("branch", "Branch to scan.").String()
53+
gitScanMaxDepth = gitScan.Flag("max-depth", "Maximum depth of commits to scan.").Int()
54+
_ = gitScan.Flag("allow", "No-op flag for backwards compat.").Bool()
55+
_ = gitScan.Flag("entropy", "No-op flag for backwards compat.").Bool()
56+
_ = gitScan.Flag("regex", "No-op flag for backwards compat.").Bool()
57+
58+
githubScan = cli.Command("github", "Find credentials in GitHub repositories.")
59+
githubScanEndpoint = githubScan.Flag("endpoint", "GitHub endpoint.").Default("https://api.github.com").String()
60+
githubScanRepos = githubScan.Flag("repo", `GitHub repository to scan. You can repeat this flag. Example: "https://github.com/dustin-decker/secretsandstuff"`).Strings()
61+
githubScanOrgs = githubScan.Flag("org", `GitHub organization to scan. You can repeat this flag. Example: "trufflesecurity"`).Strings()
62+
githubScanToken = githubScan.Flag("token", "GitHub token.").String()
63+
githubIncludeForks = githubScan.Flag("include-forks", "Include forks in scan.").Bool()
64+
githubIncludeMembers = githubScan.Flag("include-members", "Include organization member repositories in scan.").Bool()
65+
66+
gitlabScan = cli.Command("gitlab", "Find credentials in GitLab repositories.")
67+
// TODO: Add more GitLab options
68+
gitlabScanEndpoint = gitlabScan.Flag("endpoint", "GitLab endpoint.").Default("https://gitlab.com").String()
69+
gitlabScanRepos = gitlabScan.Flag("repo", "GitLab repo url. You can repeat this flag. Leave empty to scan all repos accessible with provided credential. Example: https://gitlab.com/org/repo.git").Strings()
70+
gitlabScanToken = gitlabScan.Flag("token", "GitLab token.").Required().String()
71+
72+
filesystemScan = cli.Command("filesystem", "Find credentials in a filesystem.")
73+
filesystemDirectories = filesystemScan.Flag("directory", "Path to directory to scan. You can repeat this flag.").Required().Strings()
74+
// TODO: Add more filesystem scan options. Currently only supports scanning a list of directories.
75+
// filesystemScanRecursive = filesystemScan.Flag("recursive", "Scan recursively.").Short('r').Bool()
76+
// filesystemScanIncludePaths = filesystemScan.Flag("include-paths", "Path to file with newline separated regexes for files to include in scan.").Short('i').String()
77+
// filesystemScanExcludePaths = filesystemScan.Flag("exclude-paths", "Path to file with newline separated regexes for files to exclude in scan.").Short('x').String()
78+
79+
s3Scan = cli.Command("s3", "Find credentials in S3 buckets.")
80+
s3ScanKey = s3Scan.Flag("key", "S3 key used to authenticate.").String()
81+
s3ScanSecret = s3Scan.Flag("secret", "S3 secret used to authenticate.").String()
82+
s3ScanCloudEnv = s3Scan.Flag("cloud-environment", "Use IAM credentials in cloud environment.").Bool()
83+
s3ScanBuckets = s3Scan.Flag("bucket", "Name of S3 bucket to scan. You can repeat this flag.").Strings()
84+
)
85+
86+
func init() {
87+
for i, arg := range os.Args {
88+
if strings.HasPrefix(arg, "--") {
89+
os.Args[i] = strings.ReplaceAll(arg, "_", "-")
90+
}
91+
}
92+
93+
cmd = kingpin.MustParse(cli.Parse(os.Args[1:]))
94+
}
95+
2896
func main() {
97+
updateCfg := overseer.Config{
98+
Program: run,
99+
Debug: *debug,
100+
RestartSignal: syscall.SIGTERM,
101+
// TODO: Eventually add a PreUpgrade func for signature check w/ x509 PKCS1v15
102+
// PreUpgrade: checkUpdateSignature(binaryPath string),
103+
}
104+
105+
if !*noUpdate {
106+
updateCfg.Fetcher = updater.Fetcher(version.BuildVersion)
107+
}
108+
err := overseer.RunErr(updateCfg)
109+
if err != nil {
110+
logrus.WithError(err).Fatal("error occured with trufflehog updater 🐷")
111+
}
112+
}
113+
114+
func run(state overseer.State) {
29115
cli := kingpin.New("TruffleHog", "TruffleHog is a tool for finding credentials.")
30116
debug := cli.Flag("debug", "Run in debug mode").Bool()
117+
versionFlag := cli.Flag("version", "Prints trufflehog version.").Bool()
31118
jsonOut := cli.Flag("json", "Output in JSON format.").Short('j').Bool()
32119
jsonLegacy := cli.Flag("json-legacy", "Use the pre-v3.0 JSON format. Only works with git, gitlab, and github sources.").Bool()
33120
concurrency := cli.Flag("concurrency", "Number of concurrent workers.").Default(strconv.Itoa(runtime.NumCPU())).Int()
@@ -82,6 +169,11 @@ func main() {
82169

83170
cmd := kingpin.MustParse(cli.Parse(os.Args[1:]))
84171

172+
if *versionFlag {
173+
fmt.Println("trufflehog " + version.BuildVersion)
174+
return
175+
}
176+
85177
// When setting a base commit, chunks must be scanned in order.
86178
if *gitScanSinceCommit != "" {
87179
*concurrency = 1

pkg/updater/updater.go

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
package updater
2+
3+
import (
4+
"archive/tar"
5+
"archive/zip"
6+
"bytes"
7+
"compress/gzip"
8+
"encoding/json"
9+
"io"
10+
"io/ioutil"
11+
"net/http"
12+
"runtime"
13+
"strings"
14+
"time"
15+
16+
"github.com/go-errors/errors"
17+
"github.com/jpillora/overseer/fetcher"
18+
log "github.com/sirupsen/logrus"
19+
20+
"github.com/trufflesecurity/trufflehog/v3/pkg/version"
21+
)
22+
23+
func Fetcher(version string) fetcher.Interface {
24+
return &OSS{
25+
CurrentVersion: version,
26+
}
27+
}
28+
29+
type OSS struct {
30+
Interval time.Duration
31+
CurrentVersion string
32+
}
33+
34+
// Init validates the provided config
35+
func (g *OSS) Init() error {
36+
//initiate OSS connection
37+
return nil
38+
}
39+
40+
const url = "https://oss.trufflehog.org/updates"
41+
42+
type FormData struct {
43+
OS string
44+
Arch string
45+
CurrentVersion string
46+
Timezone string
47+
Binary string
48+
}
49+
50+
// Fetch binary from URL via OSS client
51+
func (g *OSS) Fetch() (io.Reader, error) {
52+
log.Debug("fetching trufflehog update")
53+
54+
zone, _ := time.Now().Zone()
55+
data := &FormData{
56+
OS: runtime.GOOS,
57+
Arch: runtime.GOARCH,
58+
CurrentVersion: version.BuildVersion,
59+
Timezone: zone,
60+
Binary: "trufflehog",
61+
}
62+
63+
dataByte, err := json.Marshal(data)
64+
if err != nil {
65+
return nil, err
66+
}
67+
reader := bytes.NewReader(dataByte)
68+
resp, err := http.Post(url, "application/json", reader)
69+
if err != nil || resp == nil {
70+
return nil, err
71+
}
72+
defer resp.Body.Close()
73+
74+
newBinBytes, err := ioutil.ReadAll(resp.Body)
75+
if err != nil {
76+
return nil, err
77+
}
78+
79+
buffer := bytes.NewReader(newBinBytes)
80+
switch runtime.GOOS {
81+
case "windows":
82+
zipReader, err := zip.NewReader(buffer, int64(len(newBinBytes)))
83+
if err != nil {
84+
return nil, errors.Errorf("Failed to read zip archive: %s", err)
85+
}
86+
for _, f := range zipReader.File {
87+
if strings.HasPrefix(f.Name, "trufflehog") {
88+
return f.Open()
89+
}
90+
}
91+
default:
92+
gzipReader, err := gzip.NewReader(buffer)
93+
if err != nil {
94+
return nil, errors.Errorf("Failed to read gzip archive: %s", err)
95+
}
96+
defer gzipReader.Close()
97+
tarReader := tar.NewReader(gzipReader)
98+
for {
99+
header, err := tarReader.Next()
100+
if err == io.EOF {
101+
return nil, errors.New("unable to get update")
102+
}
103+
104+
if header.Typeflag == tar.TypeReg {
105+
if strings.HasPrefix(header.Name, "trufflehog") {
106+
return tarReader, nil
107+
}
108+
}
109+
}
110+
}
111+
return nil, errors.New("unable to get update")
112+
}

pkg/version/version.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package version
2+
3+
var BuildVersion = "dev"

0 commit comments

Comments
 (0)