Find, verify, and analyze leaked credentials
Go credentialsdevsecopsdynamic-analysisprecommitscanningsecretsecret-managementsecretssecuritysecurity-toolstrufflehogverification
Update Jenkins in tui (#2925)
Hon4b3f8348592f
diff --git a/pkg/tui/pages/source_select/source_select.go b/pkg/tui/pages/source_select/source_select.goindex 8668421a4..d58a73031 100644--- a/pkg/tui/pages/source_select/source_select.go+++ b/pkg/tui/pages/source_select/source_select.go@@ -65,6 +65,7 @@ func New(c common.Common) *SourceSelect {OssItem("Git", "Scan git repositories."),OssItem("GitHub", "Scan GitHub repositories and/or organizations."),OssItem("Filesystem", "Scan your filesystem by selecting what directories to scan."),+ OssItem("Jenkins", "Scan Jenkins, a CI/CD platform. (Recently open-sourced from enterprise!)"),OssItem("Elasticsearch", "Scan your Elasticsearch cluster or Elastic Cloud instance."),OssItem("Postman", "Scan a collection, workspace, or environment from Postman, the API platform."),OssItem("GitLab", "Scan GitLab repositories."),@@ -80,7 +81,6 @@ func New(c common.Common) *SourceSelect {EnterpriseItem("Buildkite", "Scan Buildkite, a CI/CD platform."),EnterpriseItem("Confluence", "Scan Atlassian's web-based wiki and knowledge base."),EnterpriseItem("Gerrit", "Scan Gerrit, a code collaboration tool"),- EnterpriseItem("Jenkins ", "Scan Jenkins, a CI/CD platform."),EnterpriseItem("Jira", "Scan Atlassian's issue & project tracking software."),EnterpriseItem("Slack", "Scan Slack, a messaging and communication platform."),EnterpriseItem("Microsoft Teams", "Scan Microsoft Teams, a messaging and communication platform."),diff --git a/pkg/tui/sources/jenkins/jenkins.go b/pkg/tui/sources/jenkins/jenkins.gonew file mode 100644index 000000000..59886fbe6--- /dev/null+++ b/pkg/tui/sources/jenkins/jenkins.go@@ -0,0 +1,79 @@+package jenkins++import (+ "strings"++ "github.com/trufflesecurity/trufflehog/v3/pkg/tui/common"+ "github.com/trufflesecurity/trufflehog/v3/pkg/tui/components/textinputs"+)++type jenkinsCmdModel struct {+ textinputs.Model+}++func GetNote() string {+ return "If no username and password are provided, TruffleHog will attempt an unauthenticated Jenkins scan."+}++func GetFields() jenkinsCmdModel {+ return jenkinsCmdModel{textinputs.New([]textinputs.InputConfig{+ {+ Label: "Endpoint URL",+ Key: "url",+ Required: true,+ Help: "URL of the Jenkins server.",+ Placeholder: "https://jenkins.example.com",+ },+ {+ Label: "Username",+ Key: "username",+ Required: false,+ Help: "For authenticated scans - pairs with password.",+ },+ {+ Label: "Password",+ Key: "password",+ Required: false,+ Help: "For authenticated scans - pairs with username.",+ }})}+}++func checkIsAuthenticated(inputs map[string]textinputs.Input) bool {+ username := inputs["username"].Value+ password := inputs["password"].Value++ return username != "" && password != ""+}++func (m jenkinsCmdModel) Cmd() string {+ var command []string+ command = append(command, "trufflehog", "jenkins")+ inputs := m.GetInputs()++ keys := []string{"url"}+ if checkIsAuthenticated(inputs) {+ keys = append(keys, "username", "password")+ }++ for _, key := range keys {+ val, ok := inputs[key]+ if !ok || val.Value == "" {+ continue+ }+ command = append(command, "--"+key+"="+val.Value)+ }++ return strings.Join(command, " ")+}++func (m jenkinsCmdModel) Summary() string {+ inputs := m.GetInputs()+ labels := m.GetLabels()++ summaryKeys := []string{"url"}+ if checkIsAuthenticated(inputs) {+ summaryKeys = append(summaryKeys, "username", "password")+ }++ return common.SummarizeSource(summaryKeys, inputs, labels)+}diff --git a/pkg/tui/sources/sources.go b/pkg/tui/sources/sources.goindex 0364afe73..7d24b672f 100644--- a/pkg/tui/sources/sources.go+++ b/pkg/tui/sources/sources.go@@ -12,6 +12,7 @@ import ("github.com/trufflesecurity/trufflehog/v3/pkg/tui/sources/git""github.com/trufflesecurity/trufflehog/v3/pkg/tui/sources/github""github.com/trufflesecurity/trufflehog/v3/pkg/tui/sources/gitlab"+ "github.com/trufflesecurity/trufflehog/v3/pkg/tui/sources/jenkins""github.com/trufflesecurity/trufflehog/v3/pkg/tui/sources/postman""github.com/trufflesecurity/trufflehog/v3/pkg/tui/sources/s3""github.com/trufflesecurity/trufflehog/v3/pkg/tui/sources/syslog"@@ -26,6 +27,8 @@ func GetSourceNotes(sourceName string) string {return postman.GetNote()case "elasticsearch":return elasticsearch.GetNote()+ case "jenkins":+ return jenkins.GetNote()default:return ""@@ -60,6 +63,8 @@ func GetSourceFields(sourceName string) CmdModel {return github.GetFields()case "gitlab":return gitlab.GetFields()+ case "jenkins":+ return jenkins.GetFields()case "postman":return postman.GetFields()case "syslog":