Compare commits

...

2 Commits

Author SHA1 Message Date
Miccah Castorina ca6251632e Always use version.BuildVersion 2023-08-21 07:20:48 -07:00
Hon 2c4b0ca7cb Add flag to get information if trufflehog being ran from TUI
Co-authored-by: mcastorina <m.castorina93@gmail.com>
2023-08-18 13:52:56 -07:00
2 changed files with 17 additions and 14 deletions
+10 -7
View File
@@ -105,11 +105,11 @@ var (
filesystemScanIncludePaths = filesystemScan.Flag("include-paths", "Path to file with newline separated regexes for files to include in scan.").Short('i').String()
filesystemScanExcludePaths = filesystemScan.Flag("exclude-paths", "Path to file with newline separated regexes for files to exclude in scan.").Short('x').String()
s3Scan = cli.Command("s3", "Find credentials in S3 buckets.")
s3ScanKey = s3Scan.Flag("key", "S3 key used to authenticate. Can be provided with environment variable AWS_ACCESS_KEY_ID.").Envar("AWS_ACCESS_KEY_ID").String()
s3ScanRoleArns = s3Scan.Flag("role-arn", "Specify the ARN of an IAM role to assume for scanning. You can repeat this flag.").Strings()
s3ScanSecret = s3Scan.Flag("secret", "S3 secret used to authenticate. Can be provided with environment variable AWS_SECRET_ACCESS_KEY.").Envar("AWS_SECRET_ACCESS_KEY").String()
s3ScanSessionToken = s3Scan.Flag("session-token", "S3 session token used to authenticate temporary credentials. Can be provided with environment variable AWS_SESSION_TOKEN.").Envar("AWS_SESSION_TOKEN").String()
s3Scan = cli.Command("s3", "Find credentials in S3 buckets.")
s3ScanKey = s3Scan.Flag("key", "S3 key used to authenticate. Can be provided with environment variable AWS_ACCESS_KEY_ID.").Envar("AWS_ACCESS_KEY_ID").String()
s3ScanRoleArns = s3Scan.Flag("role-arn", "Specify the ARN of an IAM role to assume for scanning. You can repeat this flag.").Strings()
s3ScanSecret = s3Scan.Flag("secret", "S3 secret used to authenticate. Can be provided with environment variable AWS_SECRET_ACCESS_KEY.").Envar("AWS_SECRET_ACCESS_KEY").String()
s3ScanSessionToken = s3Scan.Flag("session-token", "S3 session token used to authenticate temporary credentials. Can be provided with environment variable AWS_SESSION_TOKEN.").Envar("AWS_SESSION_TOKEN").String()
s3ScanCloudEnv = s3Scan.Flag("cloud-environment", "Use IAM credentials in cloud environment.").Bool()
s3ScanBuckets = s3Scan.Flag("bucket", "Name of S3 bucket to scan. You can repeat this flag.").Strings()
s3ScanMaxObjectSize = s3Scan.Flag("max-object-size", "Maximum size of objects to scan. Objects larger than this will be skipped. (Byte units eg. 512B, 2KB, 4MB)").Default("250MB").Bytes()
@@ -138,6 +138,8 @@ var (
dockerScan = cli.Command("docker", "Scan Docker Image")
dockerScanImages = dockerScan.Flag("image", "Docker image to scan. Use the file:// prefix to point to a local tarball, otherwise a image registry is assumed.").Required().Strings()
usingTUI = false
)
func init() {
@@ -160,6 +162,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:]))
@@ -199,7 +202,7 @@ func main() {
}
if !*noUpdate {
updateCfg.Fetcher = updater.Fetcher(version.BuildVersion)
updateCfg.Fetcher = updater.Fetcher(usingTUI)
}
if version.BuildVersion == "dev" {
updateCfg.Fetcher = nil
@@ -469,7 +472,7 @@ func run(state overseer.State) {
Secret: *s3ScanSecret,
SessionToken: *s3ScanSessionToken,
Buckets: *s3ScanBuckets,
Roles: *s3ScanRoleArns,
Roles: *s3ScanRoleArns,
CloudCred: *s3ScanCloudEnv,
MaxObjectSize: int64(*s3ScanMaxObjectSize),
}
+7 -7
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",
}