jenkins

package
v3.100.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0 Imports: 20 Imported by: 1

README

Jenkins Source

Overview

The Jenkins source lets TruffleHog scan the console output of Jenkins build logs for secrets, credentials, and sensitive data. It walks a Jenkins instance's jobs and folders through the Jenkins API, then downloads and scans the build log of every build it finds.

Jenkins Fundamentals

What does this source scan?

This source asks the Jenkins API for the list of jobs and folders at a given Jenkins URL, walks into folders recursively, and for every job it finds, downloads the plain text console output of every build and scans it.

Key Jenkins Terminology
Term Description
Job A single configured build task in Jenkins, such as a Freestyle project or a Pipeline
Folder A container that groups jobs and can hold other folders
Build One run of a job, numbered in order
Console Output The full text log produced while a build ran, available as a plain text page

Features

  • Folder Traversal: Recursively walks Jenkins folders to find every job underneath them
  • Multiple Authentication Methods: Username and password, a custom header, or unauthenticated
  • Self Signed Certificate Support: Can skip TLS certificate verification for instances using one

Configuration

Authentication Methods
1. Username and Password

CLI Usage:

trufflehog jenkins --url https://jenkins.example.com --username my-username --password my-password

YAML Configuration:

sources:
- connection:
    '@type': type.googleapis.com/sources.Jenkins
    endpoint: https://jenkins.example.com
    basic_auth:
      username: my-username
      password: my-password
  name: jenkins-scan
  type: SOURCE_TYPE_JENKINS
  verify: true

On the CLI, the URL, username, and password can also be set with the JENKINS_URL, JENKINS_USERNAME, and JENKINS_PASSWORD environment variables instead of the matching flags. This does not apply to a YAML config file, since TruffleHog does not read environment variables while loading YAML.


2. Custom Header

Sends a fixed header, such as an API token header, with every request. This method is only available in the YAML config, not the CLI.

YAML Configuration:

sources:
- connection:
    '@type': type.googleapis.com/sources.Jenkins
    endpoint: https://jenkins.example.com
    header:
      key: "Authorization"
      value: "Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  name: jenkins-scan
  type: SOURCE_TYPE_JENKINS
  verify: true

3. Unauthenticated

CLI Usage:

Leave out --username and --password to scan without authentication. This is also what happens if only one of the two is given, since the CLI only uses basic auth when both are set together.

trufflehog jenkins --url https://jenkins.example.com

YAML Configuration:

In the YAML config, this must be set explicitly. Leaving out the credential entirely is rejected.

sources:
- connection:
    '@type': type.googleapis.com/sources.Jenkins
    endpoint: https://jenkins.example.com
    unauthenticated: {}
  name: jenkins-scan
  type: SOURCE_TYPE_JENKINS
  verify: true
Self Signed Certificates
trufflehog jenkins --url https://jenkins.example.com --username my-username --password my-password --insecure-skip-verify-tls

On the CLI, this can also be set with the JENKINS_INSECURE_SKIP_VERIFY_TLS environment variable.

How Scanning Works

Scanning Process
  1. Job Listing: Asks the Jenkins API for the jobs directly under the given URL
  2. Folder Traversal: For every folder found, repeats the job listing inside that folder, continuing until every nested folder has been walked
  3. Build Listing: For every job that is a Freestyle project or a Pipeline, lists all of its builds
  4. Build Log Scanning: Downloads the console output of every build and scans its text for secrets
  5. Progress Tracking: Reports progress as each job is processed, so a scan can be monitored while it runs
What Gets Scanned
  • The console output of every build of every Freestyle project and Pipeline job found underneath the given URL, including jobs inside nested folders
What Doesn't Get Scanned
  • Job types other than a Freestyle project or a Pipeline, such as a Multi-configuration project (in the Jenkins API this is the hudson.matrix.MatrixProject class)
  • Anything whose Jenkins API class is not recognized as a plain folder or as one of the two scannable job types, including any job container that is not the plain Jenkins folder type
  • Anything outside the build's console output, such as artifacts, build parameters, or job configuration

There is no concurrency for this source: jobs, builds, and their console output are all fetched and scanned one at a time, and there is no flag to change that.

Usage Examples

Scanning with Username and Password
trufflehog jenkins --url https://jenkins.example.com --username my-username --password my-password
Scanning Without Authentication
trufflehog jenkins --url https://jenkins.example.com
Scanning an Instance with a Self Signed Certificate
trufflehog jenkins --url https://jenkins.example.com --username my-username --password my-password --insecure-skip-verify-tls

Debug Logs

With debug on for this source (debug: true in the config), the scan logs:

  • V(1): initialized Jenkins source with the auth method (never the credentials), the endpoint with any password redacted, and whether TLS verification is skipped, then the number of jobs found.
  • V(2): got builds for each job, with its build count.
  • V(3): the objects listed in each folder, each object as it is processed, and chunking build for each build.
  • V(4): each Jenkins API page request, Skipping object with a reason for objects that are not a supported job type, and each retry of a request.
  • V(5): each HTTP request with its auth type, and each response status code.

Lines carry job_name, build_number and the other job and build fields where they apply. Failures to get a job's builds or a build log are logged as errors at the default level.

Troubleshooting

Common Issues

Issue: Authentication failures when connecting to Jenkins Solution: Check that the username and password, or the custom header, are correct and have permission to read the target jobs and builds.


Issue: A username was given but the scan still ran unauthenticated Solution: On the CLI, both --username and --password must be set together for basic authentication to be used. If either one is missing, the scan falls back to unauthenticated without an error.


Issue: Received non-200 status from get jenkins jobs request Solution: Check the Jenkins URL is correct and reachable, and that the credentials have permission to list jobs at that URL.


Issue: Certificate errors when connecting to a self managed Jenkins instance Solution: Pass --insecure-skip-verify-tls if the instance uses a self signed certificate.


Issue: Some jobs are missing from the scan Solution: TruffleHog only scans Freestyle projects and Pipeline jobs, and only recurses into the plain Jenkins folder type. A job of another type, or one nested inside a different kind of container, is skipped. With debug on, the scan logs Skipping object for each one.

Documentation

Index

Constants

View Source
const SourceUnitKindJob sources.SourceUnitKind = "job"

Variables

This section is empty.

Functions

This section is empty.

Types

type JenkinsBuild

type JenkinsBuild struct {
	Number int64  `json:"number"`
	Url    string `json:"url"`
}

type JenkinsBuildResponse

type JenkinsBuildResponse struct {
	Builds []JenkinsBuild `json:"builds"`
}

type JenkinsJob added in v3.97.2

type JenkinsJob struct {
	Class string `json:"_class"`
	Name  string `json:"name"`
	Url   string `json:"url"`
	// Path is the job's path relative to the Jenkins instance. Jenkins reports
	// absolute job URLs whose host comes from the instance's own root URL
	// setting, which can differ from the endpoint being scanned, so only the
	// path is retained as the identity. Chunks does the same when it scans a
	// job. Path is not part of the Jenkins API response; walkJobs derives it
	// from Url, so it is empty on a value decoded straight from a listing.
	Path string `json:"path"`
}

JenkinsJob is a job as listed by the Jenkins API, and is the source unit the Jenkins source enumerates.

func (JenkinsJob) Display added in v3.97.2

func (j JenkinsJob) Display() string

Display returns the job's folder path without the "job" segments Jenkins interleaves, e.g. /jenkins/job/folder1/job/build becomes folder1/build. It is derived from Path rather than from Name so that a unit rebuilt from its ID alone still renders a name.

func (JenkinsJob) SourceUnitID added in v3.97.2

func (j JenkinsJob) SourceUnitID() (string, sources.SourceUnitKind)

type JenkinsJobResponse

type JenkinsJobResponse struct {
	Jobs []JenkinsJob `json:"jobs"`
}

type Source

type Source struct {
	sources.Progress
	// contains filtered or unexported fields
}

func (*Source) Chunks

func (s *Source) Chunks(ctx context.Context, chunksChan chan *sources.Chunk, _ ...sources.ChunkingTarget) error

Chunks emits chunks of bytes over a channel.

func (*Source) Enumerate added in v3.97.2

func (s *Source) Enumerate(ctx context.Context, reporter sources.UnitReporter) error

Enumerate implements the SourceUnitEnumerator interface. It reports one unit per Jenkins job, walking folders recursively. A folder that cannot be listed is reported to the UnitReporter and the rest of the walk continues.

func (*Source) GetJenkinsBuilds

func (s *Source) GetJenkinsBuilds(ctx context.Context, jobAbsolutePath string) (JenkinsBuildResponse, error)

func (*Source) GetJenkinsJobs

func (s *Source) GetJenkinsJobs(ctx context.Context) (JenkinsJobResponse, error)

GetJenkinsJobs traverses the tree to find all jobs. Example response from http://localhost:8080/api/json?tree=jobs[name,url]{0,100} on our Jenkins instance:

{
	"_class": "hudson.model.Hudson",
	"jobs": [
	  {
		"_class": "com.cloudbees.hudson.plugins.folder.Folder",
		"name": "folder1",
		"url": "http://jenkins:8080/job/folder1/"
	  },
	  {
		"_class": "org.jenkinsci.plugins.workflow.job.WorkflowJob",
		"name": "hon-test",
		"url": "http://jenkins:8080/job/hon-test/"
	  },
	  {
		"_class": "hudson.model.FreeStyleProject",
		"name": "hon-test-project",
		"url": "http://jenkins:8080/job/hon-test-project/"
	  },
	  {
		"_class": "hudson.model.FreeStyleProject",
		"name": "steeeve-freestyle-project",
		"url": "http://jenkins:8080/job/steeeve-freestyle-project/"
	  }
	]
}

func (*Source) GetJenkinsObjectsForPath

func (s *Source) GetJenkinsObjectsForPath(ctx context.Context, absolutePath string) (JenkinsJobResponse, error)

func (*Source) Init

func (s *Source) Init(aCtx context.Context, name string, jobId sources.JobID, sourceId sources.SourceID, verify bool, connection *anypb.Any, _ int) error

Init returns an initialized Jenkins source.

func (*Source) JobID

func (s *Source) JobID() sources.JobID

func (*Source) NewRequest

func (s *Source) NewRequest(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

func (*Source) RecursivelyGetJenkinsObjectsForPath

func (s *Source) RecursivelyGetJenkinsObjectsForPath(ctx context.Context, absolutePath string) (JenkinsJobResponse, error)

func (*Source) SourceID

func (s *Source) SourceID() sources.SourceID

func (*Source) Type

func (s *Source) Type() sourcespb.SourceType

Type returns the type of source. It is used for matching source types in configuration and job input.

func (*Source) UnmarshalSourceUnit added in v3.97.2

func (s *Source) UnmarshalSourceUnit(data []byte) (sources.SourceUnit, error)

UnmarshalSourceUnit implements the SourceUnitUnmarshaller interface. It accepts three shapes: the persisted envelope carrying unit_data (round-trips the unit exactly), the envelope without unit_data (rebuilt from id), and a bare JenkinsJob.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址