Skip to main content
Version: 3.17-dev

Install and Integrate DefectDojo

Install DefectDojo on Kubernetes with Helm and integrate it into KubeRocketCI pipelines for vulnerability management. Once installed, you can enable single sign-on by following the DefectDojo Microsoft Entra OIDC SSO Setup guide.

info

It is also possible to install DefectDojo using the add-ons approach. For details, please refer to the KubeRocketCI addons approach.

note

For details on how KubeRocketCI pipelines report findings to DefectDojo, including the data model, engagement naming, and scan types, refer to Security Scanning Pipelines. For the runtime findings of the cluster workloads, refer to Runtime Security Findings in DefectDojo. To show the findings in the KubeRocketCI Portal, refer to Configure the KubeRocketCI Portal.

Prerequisites​

  • Kubectl version 1.34.0+ is installed. Please refer to the Kubernetes official website for details.
  • Helm version 3.19.0+ is installed. Please refer to the Helm page on GitHub for details.
  • DefectDojo 3.5.0 is the tested and recommended version (chart 1.9.65); earlier versions may work but are not tested.

Installation Options​

To install DefectDojo on Kubernetes, deploy the official DefectDojo Helm chart, which ships the application with its PostgreSQL database and Valkey message broker. KubeRocketCI supports two paths: a GitOps deployment through the Cluster Add-Ons repository (recommended, managed by Argo CD), or a direct helm upgrade --install with your own values.

Upstream reference: DefectDojo Helm chart 1.9.65 README.

Open Source SSO Limitation

DefectDojo 3.x open source has no SSO support. Keycloak/OIDC integration is available only in DefectDojo Pro. The DefectDojo Microsoft Entra OIDC SSO Setup guide applies to DefectDojo 2.x or DefectDojo Pro only. For open source 3.x, only local username/password login is supported.

Install DefectDojo via Cluster Add-Ons​

To install DefectDojo in environment, it's recommended to use the resources provided in the Cluster Add-Ons repository. Leveraging the Cluster Add-Ons simplifies the deployment and management process, providing a streamlined method to integrate DefectDojo into infrastructure.

  1. Navigate to the forked cluster Add-Ons repository and align the defectdojo values.yaml file. Follow the instructions to deploy DefectDojo.

  2. Update the configuration to enable DefectDojo in Add-Ons repository:

    clusters/core/apps/values.yaml
    defectdojo:
    createNamespace: true
    enable: true
  3. Sync resources and wait till the all DefectDojo resources is created:

    DefectDojo ArgoCD applications

Install DefectDojo with the Helm Chart​

  1. Check that a security namespace is created. If not, run the following command to create it:

    kubectl create namespace defectdojo
    For the OpenShift users

    When using the OpenShift platform, install the SecurityContextConstraints resource. In case of using a custom namespace for defectdojo, change the namespace in the users section.

    View: defectdojo-scc.yaml
    allowHostDirVolumePlugin: false
    allowHostIPC: false
    allowHostNetwork: false
    allowHostPID: false
    allowHostPorts: false
    allowPrivilegeEscalation: true
    allowPrivilegedContainer: false
    allowedCapabilities: null
    apiVersion: security.openshift.io/v1
    allowedFlexVolumes: []
    defaultAddCapabilities: []
    fsGroup:
    type: MustRunAs
    ranges:
    - min: 999
    max: 65543
    groups: []
    kind: SecurityContextConstraints
    metadata:
    annotations:
    "helm.sh/hook": "pre-install"
    name: defectdojo
    priority: 1
    readOnlyRootFilesystem: false
    requiredDropCapabilities:
    - KILL
    - MKNOD
    - SETUID
    - SETGID
    runAsUser:
    type: MustRunAsRange
    uidRangeMin: 1
    uidRangeMax: 65543
    seLinuxContext:
    type: MustRunAs
    supplementalGroups:
    type: RunAsAny
    users:
    - system:serviceaccount:defectdojo:defectdojo
    - system:serviceaccount:defectdojo:defectdojo-valkey
    - system:serviceaccount:defectdojo:default
    volumes:
    - configMap
    - downwardAPI
    - emptyDir
    - persistentVolumeClaim
    - projected
    - secret
  2. Add a chart repository:

    helm repo add defectdojo 'https://raw.githubusercontent.com/DefectDojo/django-DefectDojo/helm-charts'
    helm repo update
  3. Create PostgreSQL admin secret:

    kubectl -n defectdojo create secret generic defectdojo-postgresql-specific \
    --from-literal=postgresql-password=<postgresql_password> \
    --from-literal=postgresql-postgres-password=<postgresql_postgres_password>
    note

    The postgresql_password and postgresql_postgres_password passwords must be 16 characters long.

  4. Create Valkey secret:

    kubectl -n defectdojo create secret generic defectdojo-valkey-specific \
    --from-literal=valkey-password=<valkey_password>
    note

    The valkey_password password must be 10 characters long.

  5. Create DefectDojo admin secret:

    kubectl -n defectdojo create secret generic defectdojo \
    --from-literal=DD_ADMIN_PASSWORD=<dd_admin_password> \
    --from-literal=DD_SECRET_KEY=<dd_secret_key> \
    --from-literal=DD_CREDENTIAL_AES_256_KEY=<dd_credential_aes_256_key> \
    --from-literal=METRICS_HTTP_AUTH_PASSWORD=<metric_http_auth_password>
    note

    The dd_admin_password password must be 22 characters long.

    The dd_secret_key password must be 128 characters long.

    The dd_credential_aes_256_key password must be 128 characters long.

    The metric_http_auth_password password must be 32 characters long.

  6. Install DefectDojo 3.5.200 using the defectdojo/defectdojo Helm chart 1.9.70:

    helm upgrade --install \
    defectdojo \
    --version 1.9.70 \
    defectdojo/defectdojo \
    --namespace defectdojo \
    --values values.yaml

    The chart uses the DefectDojo images of its app version, 3.5.200, so the values.yaml file sets no image tag. Check out the values.yaml file sample of the DefectDojo customization:

    View: values.yaml
    fullnameOverride: defectdojo
    host: defectdojo.<ROOT_DOMAIN>
    siteUrl: https://defectdojo.<ROOT_DOMAIN>
    alternativeHosts:
    - defectdojo-django.defectdojo

    initializer:
    # runs the database migrations on install and upgrade; keep it enabled
    run: true
    django:
    ingress:
    enabled: true # change to 'false' for OpenShift
    activateTLS: false
  7. For the OpenShift platform, install a Route:

    View: defectdojo-route.yaml
    kind: Route
    apiVersion: route.openshift.io/v1
    metadata:
    name: defectdojo
    namespace: defectdojo
    spec:
    host: defectdojo.<ROOT_DOMAIN>
    path: /
    tls:
    insecureEdgeTerminationPolicy: Redirect
    termination: edge
    to:
    kind: Service
    name: defectdojo-django
    port:
    targetPort: http
    wildcardPolicy: None

Configure the DefectDojo ci-user​

DefectDojo 3.5.200 has no global roles. A user gets access either as a staff user or as an authorized user of a Product Type, shown as an Organization in the UI. The KubeRocketCI pipelines write to the KubeRocketCI Organization by default. To prepare DefectDojo for integration with KubeRocketCI, follow the steps below:

  1. Create the ci user in the DefectDojo UI:

    • Log in to the DefectDojo UI with the admin credentials:

      echo "DefectDojo admin password: $(kubectl \
      get secret defectdojo \
      --namespace=defectdojo \
      --output jsonpath='{.data.DD_ADMIN_PASSWORD}' \
      | base64 --decode)"
    • Go to Users, click New User, and create the user, for example ci-user.

    • Grant the user access with one of these options:

      • Staff user: select Staff status when you create the user. Only a superuser, such as admin, can set it.

      • Authorized user of the KubeRocketCI Organization: leave Staff status cleared. Go to Organizations -> Add Organization and create the KubeRocketCI Organization. Open it, and in the Authorized Users panel, click Add Users and add the user.

    warning

    With the second option, create the KubeRocketCI Organization before the first pipeline run. A user without the staff status has access only to the Organizations that list it in Authorized Users. DefectDojo does not add the user there when its import creates the Organization.

  2. Get a token of the DefectDojo user:

    • Log in to the DefectDojo UI with the credentials of the user from the previous step.

    • Open the user menu and select API v2 Key.

    • Copy the API key.

      DefectDojo api key

Integrate DefectDojo with KubeRocketCI​

Provision the secret using KubeRocketCI portal, Manifest or with the externalSecrets operator:

Go to the Portal open Configuration -> SECURITY -> DEFECTDOJO. Update or click + ADD INTEGRATION fill fields Quick Link URL, URL and Token click the save button.

DefectDojo update manual secret

After following the instructions provided, you should be able to integrate your DefectDojo with the KubeRocketCI using one of the available scenarios.

Configure the KubeRocketCI Portal​

The KubeRocketCI Portal reads DefectDojo to show the security findings of projects, Deployments, Environments, and the platform. For these views, refer to Security Findings. The portal uses its own DefectDojo user and is tested with DefectDojo 3.5.200.

Each DefectDojo user of the platform has one purpose:

UserPurposeToken location
CI user, for example ci-userUploads the results of the security scan pipelinesThe ci-defectdojo Secret
Operator user, one per clusterUploads the runtime findings of krci-security-operatorThe defectdojo.secretName Secret of the operator. See DefectDojo API Token
Portal user, one per KubeRocketCI installationReads the findings for the portalThe DEFECTDOJO_TOKEN key of the portal-secret Secret
warning

Every user signed in to the portal sees all findings of the Product Type that the portal reads, in every namespace and codebase, whatever their Kubernetes access. Decide who gets portal access with this in mind.

To connect the portal to DefectDojo, follow the steps below:

  1. Create the portal user. Log in to the DefectDojo UI as a superuser, such as admin, go to Users, click New User, and create the user, for example krci-portal, with a password. Leave Staff status and Superuser status cleared.

  2. Give the user access to one Organization. Open Organizations and the Organization that the platform writes to, KubeRocketCI by default. If it does not exist yet, create it with Add Organization before the first pipeline run or import: DefectDojo does not add the portal user to an Organization that an import creates. In the Authorized Users panel, click Add Users and add the portal user. Do not add the user to any other Organization.

    The user gets access to the products of this Organization, including the products created later, and to nothing else.

    note

    Open-source DefectDojo has no read-only role. An authorized user of an Organization can also add, edit, and import findings in its products. The portal sends only read requests, but protect its token as the token of the CI user.

  3. Get the token of the portal user. Log in to the DefectDojo UI as this user, open the user menu, select API v2 Key, and copy the API key.

  4. Add the token to the portal-secret Secret as DEFECTDOJO_TOKEN:

    • If the Secret is created manually, add the key to it:

      kubectl -n <krci-namespace> patch secret portal-secret --type merge \
      -p '{"stringData":{"DEFECTDOJO_TOKEN":"<api-key>"}}'
    • If the External Secrets Operator creates the Secret, add DEFECTDOJO_TOKEN as a top-level property of the portal eso.secretPath, next to SERVER_SECRET. Do not put it inside the ci-defectdojo property: the ExternalSecret copies each top-level property into a key of portal-secret, at its next refresh. To apply the key at once, force-sync the ExternalSecret as in Feature Is Not Configured, check that portal-secret holds DEFECTDOJO_TOKEN, and restart the portal.

    For the other keys of the Secret, see Create the portal-secret Kubernetes Secret.

  5. Set the DefectDojo address in the krci-portal values of edp-install and upgrade the release:

    krci-portal:
    configEnv:
    DEFECTDOJO_URL: http://defectdojo-django.defectdojo
    # Browser-facing URL of the links to DefectDojo; needed when DEFECTDOJO_URL is an in-cluster address
    DEFECTDOJO_WEB_URL: https://defectdojo.example.com
    • DEFECTDOJO_URL is the address that the portal server calls. An in-cluster Service address, such as http://defectdojo-django.defectdojo, must be listed in alternativeHosts of the DefectDojo values, as in the sample of Install DefectDojo with the Helm Chart. Otherwise, DefectDojo rejects the requests, and the portal reports it as unreachable.
    • DEFECTDOJO_WEB_URL is the address that the browser uses. The portal builds its links to DefectDojo from it, or from DEFECTDOJO_URL when it is not set, so set it with an in-cluster DEFECTDOJO_URL.
    • DEFECTDOJO_PRODUCT_TYPE is the Product Type, shown as an Organization in the UI, that the portal reads. Keep the default KubeRocketCI. See Product Type.

    The upgrade restarts the portal when configEnv changes. After a change of the Secret alone, restart the portal.

  6. Open Security > Findings > Overview in the portal: the level cards show the findings of the platform. If the page shows DefectDojo is not connected or DefectDojo is unreachable, see Feature Is Not Configured and the states of the views. If every level shows No scan data although scans ran, check that the portal user is an authorized user of the Organization (step 2) and that DEFECTDOJO_PRODUCT_TYPE names it (step 5).

For the Runtime findings, install krci-security-operator 0.4.0 or later on every cluster that runs Environments, with the cluster name that the Environments use and labelTags.namespace set to app.edp.epam.com/tenant. The portal reads the runtime tests by the report-kind tag that 0.4.0 writes. See Cluster Name and Label Tags.

warning

Use one DefectDojo per KubeRocketCI installation. Installations that share one write into the same <codebase> product when their codebases have one name. Installations on two clusters also write into the same in-cluster/<namespace> products, because each names its own cluster in-cluster. Their findings mix.