Files
trufflehog/pkg/tui/sources/s3/s3.go
Hon Kwokandmcastorina 4598244167 Use placeholder as default if field left empty and is required (#1642)
* Use placeholder as default if field left empty and is required

Co-authored-by: mcastorina <[email protected]>

* Drop unused func

* uncomment azure source

* update wording

---------

Co-authored-by: mcastorina <[email protected]>
2023-10-02 17:21:40 -07:00

49 lines
1.0 KiB
Go

package s3
import (
"strings"
"github.com/trufflesecurity/trufflehog/v3/pkg/tui/common"
"github.com/trufflesecurity/trufflehog/v3/pkg/tui/components/textinputs"
)
type s3CmdModel struct {
textinputs.Model
}
func GetFields() s3CmdModel {
bucket := textinputs.InputConfig{
Label: "S3 bucket name(s)",
Key: "buckets",
Required: true,
Placeholder: "truffletestbucket",
Help: "Buckets to scan. Separate by space if multiple.",
}
return s3CmdModel{textinputs.New([]textinputs.InputConfig{bucket})}
}
func (m s3CmdModel) Cmd() string {
var command []string
command = append(command, "trufflehog", "s3")
inputs := m.GetInputs()
vals := inputs["buckets"].Value
if vals != "" {
buckets := strings.Fields(vals)
for _, bucket := range buckets {
command = append(command, "--bucket="+bucket)
}
}
return strings.Join(command, " ")
}
func (m s3CmdModel) Summary() string {
inputs := m.GetInputs()
labels := m.GetLabels()
keys := []string{"buckets"}
return common.SummarizeSource(keys, inputs, labels)
}