Skip to main content
Version: 3.13

Security Scanning Pipelines

KubeRocketCI provides automated security scanning at three levels of the software delivery lifecycle: source code, dependencies, and container images. Scanners are embedded into Tekton pipelines and report findings to DefectDojo, Dependency-Track, and SonarQube.

ToolCategoryReport DestinationDefectDojo Scan Type
SemgrepSASTDefectDojoSemgrep JSON Report
GitleaksSecret DetectionDefectDojoGitleaks Scan
CycloneDX cdxgenSCA / SBOMDependency-TrackN/A (direct API upload)
SonarQubeSAST + Code QualitySonarQube serverN/A
TrivyContainer Vulnerability ScanDefectDojoTrivy Scan
Anchore GrypeContainer Vulnerability ScanDefectDojoAnchore Grype
HadolintDockerfile LintingPipeline logN/A
Helm chart-testingHelm Chart LintingPipeline logN/A

Pipeline Types​

Security scanning is distributed across three pipeline types. Each serves a different stage of the development workflow.

Build and Review Pipelines​

Build and review pipelines are language-specific and run for every codebase. They include SonarQube for code quality and security analysis, Hadolint for Dockerfile validation, and Helm chart-testing for chart linting.

Build pipeline β€” triggered on merge to a tracked branch:

Review pipeline β€” triggered on PR/MR creation or update:

info

For details on SonarQube configuration and Quality Gate behavior, refer to the SonarQube Integration page.

Security-Scan Pipeline​

A dedicated pipeline that runs comprehensive security analysis independently from build/review. Available for all supported VCS providers (GitHub, GitLab, Gerrit, Bitbucket). Triggered via webhook or manually through the KubeRocketCI portal.

After cloning the repository, two tasks execute in parallel:

The pipeline returns two result URLs visible in the portal:

  • SCAN_REPORT_URL β€” DefectDojo link to code security findings (Semgrep + Gitleaks)
  • IMAGE_SCAN_REPORT_URL β€” DefectDojo link to container image findings (Trivy + Grype)

Image-Scan-Remote Pipeline​

An on-demand pipeline for scanning pre-built container images from remote registries without source code. Accepts an array of fully-qualified image references:

params:
- name: IMAGE_NAMES
value:
- "registry.example.com/myapp/backend:1.2.3"
- "registry.example.com/myapp/frontend:1.2.3"
- name: CODEBASE_NAME
value: "myapp"

Uses Trivy only (no Grype) and uploads results to DefectDojo with per-image engagements.

Scanner-to-Pipeline Matrix​

ScannerBuild PipelineReview PipelineSecurity-Scan PipelineImage-Scan-Remote
SonarQubeYesYes (PR mode)--
Semgrep--Yes-
Gitleaks--Yes-
cdxgen (SBOM)--Yes-
Trivy--YesYes
Grype--Yes-
Hadolint-Yes--
Helm Lint-Yes--

Scanner Reference​

This section describes each integrated scanner: what it detects, the command it runs, and where results are reported.

Source Code Scanners​

Semgrep (SAST)​

Semgrep performs Static Application Security Testing across the entire source tree. It runs as the first step of the security task in the security-scan pipeline.

Command:

semgrep --jobs 1 --config=auto . --json \
--output semgrep-report.json --disable-version-check

Key behaviors:

  • Uses --config=auto which downloads community and recommended rules from the Semgrep registry, selecting rules based on detected languages and frameworks.
  • Runs single-threaded (--jobs 1) for stability in container environments.
  • Excludes .docker/config.json via a .semgrepignore file created at scan time.
  • Produces a JSON report consumed by the DefectDojo upload step.
  • Does not fail the pipeline on findings β€” results go to DefectDojo for triage.

DefectDojo mapping: scan type = Semgrep JSON Report, engagement = code-security-{branch}.

Gitleaks (Secret Detection)​

Gitleaks detects hardcoded secrets, API keys, passwords, and tokens in the source code. It runs as the second step of the security task.

Command:

gitleaks detect --source . --report-format=json \
--report-path=gitleaks-report.json \
--no-git --verbose --exit-code=0 --config=gitleaks.toml

Key behaviors:

  • --no-git scans file content only (not git history), which is faster and avoids needing a full git clone.
  • --exit-code=0 ensures the pipeline does not fail on findings β€” all results are sent to DefectDojo.
  • Uses a custom gitleaks.toml config that excludes the .docker/ directory.

DefectDojo mapping: scan type = Gitleaks Scan, engagement = code-security-{branch}.

CycloneDX cdxgen (SCA / SBOM)​

CycloneDX cdxgen generates a Software Bill of Materials (SBOM) from the project source and uploads it directly to Dependency-Track. It runs as the third step of the security task and is also available as a standalone cdxgen Tekton task.

Command:

/opt/cdxgen/bin/cdxgen.js \
--api-key=$API_TOKEN \
--server-url=$DEPTRACK_URL \
--project-name=$PROJECT_NAME \
--project-version=$PROJECT_BRANCH \
--print

Key behaviors:

  • Automatically detects the project type (Maven, npm, pip, Go, etc.) and generates an appropriate SBOM.
  • Uploads the SBOM directly to Dependency-Track via its API (not through DefectDojo).
  • --project-name maps to the KubeRocketCI Codebase name (e.g., my-java-app).
  • --project-version maps to the git branch being scanned (e.g., main, release/1.0).
  • If the ci-dependency-track secret is missing or empty, the step is skipped gracefully.

After upload, Dependency-Track provides:

  • Full dependency tree visualization
  • Known vulnerability (CVE) matching against NVD and other feeds
  • License risk analysis (GPL, Apache, MIT compliance)
  • Policy evaluation (banned components, outdated versions)
  • Audit workflow for triaging findings
  • Project-level risk scoring

SonarQube (Code Quality and Security)​

SonarQube scanning is embedded in every build and review pipeline. It serves a dual purpose: code quality enforcement and security vulnerability detection. SonarQube is the only scanner that acts as a hard gate β€” if the Quality Gate fails, the pipeline fails.

SonarQube provides language-specific task variants:

Task NameLanguageBuild Tool
sonarqube-mavenJava (Maven)Maven plugin (sonar:sonar)
sonarqube-gradleJava (Gradle)Gradle plugin (sonarqube)
sonarqube-generalGo, Python, JS/TSStandalone sonar-scanner-cli
sonarqube-dotnetC# / .NETdotnet sonarscanner

Each task performs three phases:

  1. Project setup β€” verifies SonarQube availability, auto-creates the project if missing (using the Codebase's default branch).
  2. Analysis β€” runs the scanner with branch-mode parameters (build pipeline) or pull-request-mode parameters (review pipeline).
  3. Quality Gate β€” with sonar.qualitygate.wait=true, the scanner polls SonarQube until evaluation completes. A failed Quality Gate blocks artifact publishing (build) or sets a failing PR status (review).

SonarQube detects bugs, security vulnerabilities, security hotspots, code smells, coverage gaps, and code duplications.

info

For installation, configuration, and integration instructions, refer to the SonarQube Integration page.

Container Image Scanners​

Container image scanning discovers and reports vulnerabilities in OS packages and application libraries baked into container images. KubeRocketCI provides multiple scanning approaches depending on the context.

Helm-Based Image Discovery (image-scan-chart)​

This is the primary approach, used in all security-scan pipelines. It renders the application's Helm chart to discover which container images are deployed, then scans each one.

Execution flow:

StepDescription
discover-image-repositoryQueries Kubernetes for the CodebaseImageStream CR to extract the image repository and latest tag
helm-template-and-extractRuns helm template with image overrides from the previous step, then parses rendered manifests for all image: references
trivyScans each discovered image using Trivy in client/server mode, producing a JSON report per image
grypeScans each discovered image using Anchore Grype, producing a JSON report per image
upload-reportUploads all Trivy and Grype reports to DefectDojo with per-image engagements

Key details:

  • CodebaseImageStream lookup normalizes the branch name (lowercase, non-alphanumeric characters replaced with -) to locate the correct resource.
  • Helm template uses --set image.repository and --set image.tag overrides so rendered manifests contain real production image references.
  • If no Helm chart exists at deploy-templates/, the scan is skipped gracefully.
  • Trivy runs in client/server mode by default (server at http://trivy-service.trivy-system:4954) for performance. It falls back to standalone mode if no server is configured.
  • Grype always runs standalone (no server mode).
  • Both scanners use soft failure β€” a scan error on one image does not block other images from being scanned. Upload errors do fail the task.

Remote Registry Scanning (image-scan-remote)​

For scanning images that already exist in a remote registry, without needing source code or Helm charts. This approach uses Trivy only (no Grype) and creates per-image engagements in DefectDojo.

Build-Time TAR Scanning (image-scan)​

For scanning container images saved as TAR archives (e.g., output of kaniko --tarPath). Runs both Trivy and Grype. Uses a fixed DefectDojo engagement name container-security.

Standalone Trivy Check (trivy-scan)​

A lightweight task that scans a single image for HIGH and CRITICAL vulnerabilities only:

trivy image --scanners vuln --severity HIGH,CRITICAL "${TARGET_IMAGE}"

Results are printed to the pipeline log. No DefectDojo integration.

Infrastructure-as-Code Linting​

These tools run during review pipelines to catch issues before merge:

  • Hadolint β€” validates Dockerfile best practices: pinned base images, proper instruction ordering, and shell best practices.
  • Helm chart-testing β€” validates Helm chart structure, values schema, and template rendering using ct lint.

Both tools block the review pipeline on failure.

DefectDojo Reporting Model​

Understanding how KubeRocketCI organizes findings in DefectDojo is essential for navigating scan results and configuring alerts.

Data Hierarchy​

Product Type: "KubeRocketCI"
└─ Product: "{CODEBASE_NAME}"
β”œβ”€ Engagement: "code-security-{branch}"
β”‚ β”œβ”€ Test: "Semgrep JSON Report"
β”‚ β”‚ └─ Findings: [...]
β”‚ └─ Test: "Gitleaks Scan"
β”‚ └─ Findings: [...]
β”‚
β”œβ”€ Engagement: "image:registry.example.com/myapp:1.0.0"
β”‚ β”œβ”€ Test: "Trivy Scan"
β”‚ β”‚ └─ Findings: [...]
β”‚ └─ Test: "Anchore Grype"
β”‚ └─ Findings: [...]
β”‚
└─ Engagement: "image:nginx:1.25"
β”œβ”€ Test: "Trivy Scan"
└─ Test: "Anchore Grype"
  • Product Type β€” KubeRocketCI (configurable via DD_PRODUCT_TYPE_NAME). Groups all platform codebases.
  • Product β€” one per KubeRocketCI Codebase. Named after the Codebase (e.g., my-java-app).
  • Engagement β€” groups related scans. Naming depends on the scan source (see table below).
  • Test β€” one per scanner execution. Holds the actual findings.

Engagement Naming Strategy​

Scan SourceEngagement NameRationale
Code security scanscode-security or code-security-{branch}One engagement per branch for SAST and secret findings
Container image scansimage:{full-image-reference}One engagement per image to prevent close_old_findings from cross-contaminating findings between different images
TAR image scanscontainer-securityFixed engagement for build-time scanning

Upload Mechanism​

All uploads use the DefectDojo reimport-scan API:

POST {DD_HOST_URL}/api/v2/reimport-scan/
Authorization: Token {DD_TOKEN}
Content-Type: multipart/form-data

Standard parameters sent with every upload:

ParameterValuePurpose
scan_dateCurrent date (YYYY-MM-DD)When the scan was performed
minimum_severityInfoImport all severity levels
activetrueMark findings as active
verifiedfalseFindings require human verification
auto_create_contexttrueAuto-create product, engagement, and test if missing
close_old_findingstrueClose findings from previous scans that are no longer present
push_to_jirafalseNo automatic Jira integration
environmentDevelopmentEnvironment classification
product_type_nameKubeRocketCIProduct type grouping
product_name{CODEBASE_NAME}Maps to the KubeRocketCI Codebase

Result URLs​

After upload, pipeline tasks return clickable DefectDojo URLs as results:

  • Single image scanned: {DD_HOST_URL}/engagement/{ENGAGEMENT_ID}
  • Multiple images scanned: {DD_HOST_URL}/product/{PRODUCT_ID} (shows all engagements)

These URLs appear in the KubeRocketCI portal pipeline run details.

Configuration​

Required Secrets​

Secret NameKeysUsed ByPurpose
ci-defectdojotoken, urlsecurity, image-scan-chart, image-scan-remote, image-scan tasksDefectDojo report upload
ci-dependency-tracktoken, urlsecurity task (cdxgen step), standalone cdxgen taskSBOM upload to Dependency-Track
ci-sonarqubetoken, urlAll sonarqube-* tasksSonarQube analysis
ci-nexususername, passwordsonarqube-maven, sonarqube-gradle tasksMaven/Gradle artifact resolution during Sonar analysis
tip

All security-related secrets are optional at the task level. If a secret is missing, the corresponding step is skipped gracefully. This means you can incrementally adopt tools: start with SonarQube only, then add DefectDojo, then Dependency-Track.

For secret provisioning instructions, refer to:

Helm Chart Settings​

Security scanning pipelines are controlled by the following values.yaml settings in the pipelines-library Helm chart:

values.yaml
global:
gitProviders:
- github # Determines which security-scan pipeline variants are deployed
- gitlab

pipelines:
deployableResources:
security: true # Enable/disable all security-scan pipelines and tasks

java:
java25SkipSonar: true # Skip SonarQube for Java 25

tekton:
workspaceSize: 7Gi # PVC size for pipeline workspaces
SettingEffect
pipelines.deployableResources.securityWhen true, deploys all security-scan pipelines, tasks, and triggers
global.gitProvidersControls which VCS-specific pipeline variants are deployed (e.g., github-security-scan)
java25SkipSonarWhen true, omits SonarQube from Java 25 pipelines (SonarQube does not yet support Java 25)

External Services​

ServiceDefault EndpointPurpose
Trivy Serverhttp://trivy-service.trivy-system:4954Centralized vulnerability database for faster container scans
SonarQubeFrom ci-sonarqube secretStatic analysis and Quality Gate evaluation
DefectDojoFrom ci-defectdojo secretVulnerability management and reporting
Dependency-TrackFrom ci-dependency-track secretSBOM storage, dependency vulnerability tracking, license analysis

End-to-End Example: Java Maven Application​

This section walks through the complete security scanning lifecycle of a Java Maven application called payment-service on KubeRocketCI.

Setup:

  • Codebase: payment-service (registered in KubeRocketCI)
  • Git provider: GitHub
  • Branch: main
  • Container image: registry.example.com/payment-service:0.1.0-SNAPSHOT.42
  • Helm chart: deploy-templates/ with image.repository and image.tag values

Phase 1: Developer Opens a Pull Request​

A developer pushes a feature branch and opens a PR against main. GitHub fires a webhook, and the review pipeline starts.

Pipeline: github-maven-java17-app-review
StepTaskWhat Happens
1fetch-repositoryClones the PR branch
2init-valuesReads Codebase/CodebaseBranch CRs for pipeline config
3get-cacheRestores Maven .m2/repository cache
4compileRuns mvn compile
5testRuns mvn verify with JaCoCo coverage
6sonarSonarQube PR analysis (see below)
7buildRuns mvn package -DskipTests
8save-cacheSaves Maven cache for next run
9dockerfile-lintHadolint validates Dockerfile
10dockerbuild-verifyDry-run container build (no push)
11helm-lintchart-testing validates deploy-templates/
finallyset-statusReports pass/fail back to GitHub PR

SonarQube during review β€” the sonarqube-maven task runs:

mvn -s /var/configmap/settings.xml -B \
-Dsonar.projectKey=payment-service \
-Dsonar.projectName=payment-service \
-Dsonar.pullrequest.key=42 \
-Dsonar.pullrequest.branch=feature/add-refunds \
-Dsonar.pullrequest.base=main \
-Dsonar.qualitygate.wait=true \
-DskipTests verify sonar:sonar

Result in SonarQube: PR #42 appears as a decoration on the payment-service project. The Quality Gate evaluates new code coverage, bugs, vulnerabilities, and security hotspots. If the Quality Gate fails, the pipeline fails at step 6 and the GitHub PR status shows a red check.

Phase 2: PR Is Merged β€” Build Pipeline Runs​

After the PR is approved and merged, the build pipeline triggers.

Pipeline: github-maven-java17-app-build-default
StepTaskWhat Happens
1fetch-repositoryClones main branch
2init-valuesReads Codebase CR metadata
3get-versionGenerates version: 0.1.0-SNAPSHOT.42
4get-cacheRestores Maven cache
5update-build-numberStamps version into the project
6compileRuns mvn compile
7testRuns mvn verify with JaCoCo
8sonarSonarQube branch analysis
9buildRuns mvn package -DskipTests
10pushPublishes JAR/WAR to Nexus
11container-buildKaniko builds and pushes container image
12save-cacheSaves Maven cache
13git-tagTags commit with 0.1.0-SNAPSHOT.42
14update-cbisUpdates CodebaseImageStream with new image tag and digest
finallyreport-statusReports to JIRA and GitHub

SonarQube during build β€” branch analysis updates the main branch in SonarQube with the latest merged code, enabling long-lived branch trend tracking.

Phase 3: Security-Scan Pipeline Runs​

The security-scan pipeline is triggered via webhook or manually from the portal.

Pipeline: github-security-scan

Two tasks run in parallel after fetch-repository:

Task A: security (SAST + Secrets + SCA)​

StepToolWhat Happens
A.1SemgrepScans all source files for vulnerabilities. Writes semgrep-report.json.
A.2GitleaksScans file content for hardcoded secrets. Writes gitleaks-report.json.
A.3cdxgenAnalyzes pom.xml and transitive dependencies. Generates CycloneDX SBOM. Uploads to Dependency-Track as project payment-service, version main.
A.4UploadUploads Semgrep and Gitleaks reports to DefectDojo.

What appears in DefectDojo after Task A:

Product: payment-service
└─ Engagement: "code-security-main"
β”œβ”€ Test: "Semgrep JSON Report"
β”‚ β”œβ”€ Finding: SQL Injection in PaymentDao.java:45 [HIGH]
β”‚ └─ Finding: Insecure Deserialization in WebConfig.java:112 [CRITICAL]
└─ Test: "Gitleaks Scan"
└─ Finding: AWS Access Key in application-dev.properties:7 [HIGH]

What appears in Dependency-Track after Task A:

Project: payment-service (version: main)
Components: 247
Vulnerabilities:
β”œβ”€ CVE-2024-22262 β€” spring-web 6.1.4 [HIGH]
β”œβ”€ CVE-2024-22243 β€” spring-web 6.1.4 [MEDIUM]
└─ CVE-2023-44487 β€” netty-codec-http2 4.1.97 [HIGH]
License Risk:
β”œβ”€ 198 components: Apache-2.0
β”œβ”€ 41 components: MIT
└─ 8 components: LGPL-2.1 (review required)

Task B: image-scan-chart (Container Scanning)​

StepWhat Happens
B.1 discover-image-repositoryQueries CodebaseImageStream for payment-service-main. Finds image: registry.example.com/payment-service, tag: 0.1.0-SNAPSHOT.42.
B.2 helm-template-and-extractRenders the Helm chart with image overrides. Discovers 2 images: registry.example.com/payment-service:0.1.0-SNAPSHOT.42 and nginx:1.25-alpine (sidecar).
B.3 trivyScans both images against Trivy server.
B.4 grypeScans both images with Grype.
B.5 upload-reportUploads all 4 reports (2 images x 2 scanners) to DefectDojo.

What appears in DefectDojo after Task B:

Product: payment-service
β”œβ”€ Engagement: "code-security-main"
β”‚ └─ (Semgrep + Gitleaks findings from Task A)
β”‚
β”œβ”€ Engagement: "image:registry.example.com/payment-service:0.1.0-SNAPSHOT.42"
β”‚ β”œβ”€ Test: "Trivy Scan" (version: 0.1.0-SNAPSHOT.42, branch: main)
β”‚ β”‚ β”œβ”€ Finding: CVE-2024-32002 β€” git 2.43.0 [HIGH]
β”‚ β”‚ └─ Finding: CVE-2024-6345 β€” setuptools 69.0.3 [HIGH]
β”‚ └─ Test: "Anchore Grype" (version: 0.1.0-SNAPSHOT.42, branch: main)
β”‚ └─ Finding: CVE-2024-32002 β€” git 2.43.0 [High]
β”‚
└─ Engagement: "image:nginx:1.25-alpine"
β”œβ”€ Test: "Trivy Scan"
β”‚ └─ Finding: CVE-2024-24790 β€” Go standard library [CRITICAL]
└─ Test: "Anchore Grype"
└─ Finding: CVE-2024-24790 β€” Go standard library [Critical]

Phase 4: On-Demand Remote Image Scan​

If the security team needs to re-scan specific images without source code (e.g., after a Trivy DB update), they trigger the image-scan-remote pipeline:

params:
IMAGE_NAMES:
- "registry.example.com/payment-service:0.1.0-SNAPSHOT.42"
CODEBASE_NAME: "payment-service"

This runs Trivy against the remote registry and uploads results to the existing payment-service product in DefectDojo, updating the per-image engagement.

Security Coverage Summary​

ScannerWhat It DetectsWhere Results LiveBlocks Pipeline?
SonarQubeCode quality, bugs, security vulnerabilities, coverageSonarQube serverYes (Quality Gate)
SemgrepSAST findings (injection, deserialization, etc.)DefectDojoNo
GitleaksHardcoded secrets and credentialsDefectDojoNo
cdxgen + Dependency-TrackVulnerable dependencies, license risksDependency-TrackNo
TrivyOS-level and library CVEs in container imagesDefectDojoNo
GrypeOS-level and library CVEs in container imagesDefectDojoNo
HadolintDockerfile best practicesPipeline logYes (review only)
Helm LintChart structure and template errorsPipeline logYes (review only)
note

SonarQube is the only scanner that acts as a hard gate. All other security scanners operate in a "report and continue" mode β€” findings are sent to DefectDojo and Dependency-Track for triage by the security team.