Add flag to get information if trufflehog being ran from TUI (#1644)

* Add flag to get information if trufflehog being ran from TUI

Co-authored-by: mcastorina <m.castorina93@gmail.com>

* Always use version.BuildVersion

---------

Co-authored-by: mcastorina <m.castorina93@gmail.com>
This commit is contained in:
Hon 2024-06-05 10:07:50 -07:00 committed by GitHub
parent 024b219dfb
commit c1a2019d5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 8 deletions

View file

@ -195,6 +195,8 @@ var (
jenkinsUsername = jenkinsScan.Flag("username", "Jenkins username").Envar("JENKINS_USERNAME").String()
jenkinsPassword = jenkinsScan.Flag("password", "Jenkins password").Envar("JENKINS_PASSWORD").String()
jenkinsInsecureSkipVerifyTLS = jenkinsScan.Flag("insecure-skip-verify-tls", "Skip TLS verification").Envar("JENKINS_INSECURE_SKIP_VERIFY_TLS").Bool()
usingTUI = false
)
func init() {
@ -220,6 +222,7 @@ func init() {
// Overwrite the Args slice so overseer works properly.
os.Args = os.Args[:1]
os.Args = append(os.Args, args...)
usingTUI = true
}
cmd = kingpin.MustParse(cli.Parse(os.Args[1:]))
@ -259,7 +262,7 @@ func main() {
}
if !*noUpdate {
updateCfg.Fetcher = updater.Fetcher(version.BuildVersion)
updateCfg.Fetcher = updater.Fetcher(usingTUI)
}
if version.BuildVersion == "dev" {
updateCfg.Fetcher = nil

View file

@ -19,16 +19,14 @@ import (
"github.com/trufflesecurity/trufflehog/v3/pkg/version"
)
func Fetcher(version string) fetcher.Interface {
return &OSS{
CurrentVersion: version,
}
func Fetcher(tui bool) fetcher.Interface {
return &OSS{TUI: tui}
}
type OSS struct {
Interval time.Duration
CurrentVersion string
Updated bool
Interval time.Duration
TUI bool
Updated bool
}
// Init validates the provided config
@ -43,6 +41,7 @@ type FormData struct {
OS string
Arch string
CurrentVersion string
TUI bool
Timezone string
Binary string
}
@ -59,6 +58,7 @@ func (g *OSS) Fetch() (io.Reader, error) {
OS: runtime.GOOS,
Arch: runtime.GOARCH,
CurrentVersion: version.BuildVersion,
TUI: g.TUI,
Timezone: zone,
Binary: "trufflehog",
}