8000 Enable Use Of Custom Certificates by nigthknight · Pull Request #299 · secureCodeBox/secureCodeBox · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
f119026
Add CA Certificate Configuration To cascading scans
nigthknight Feb 15, 2021
f0efcce
Add Certificate Configuration For finding-post-processing
nigthknight Feb 15, 2021
25a1d7d
Add Certificate Configuration To generic-webhook
nigthknight Feb 15, 2021
e2b6a3a
Add Certificate Config To Elastic
nigthknight Feb 15, 2021
7bc2970
Add Certificate Config For Teams-webhook
nigthknight Feb 15, 2021
915a254
Temporarily Use TLS For Minio Storage
nigthknight Feb 17, 2021
76575b3
Enable Custom CA Certificates For Operator
nigthknight Feb 17, 2021
fda9029
Enable Custom CA Certificate For Lurcher
nigthknight Feb 17, 2021
1a61f0e
Updating Helm Docs
Feb 17, 2021
200fcb8
Updating Helm Docs
Feb 22, 2021
d3e9cca
Fix CA Certificate Volume For Lurcher
nigthknight Feb 22, 2021
6202d7c
Merge branch 'feature/custom-ca-cert' of github.com:secureCodeBox/sec…
nigthknight Feb 22, 2021
a9a0d31
Updating Helm Docs
Feb 22, 2021
384b2bc
Add Option To Configure Custom CA Cert for nmap
nigthknight Mar 1, 2021
739d4ad
Merge branch 'feature/custom-ca-cert' of github.com:secureCodeBox/sec…
nigthknight Mar 1, 2021
0bddfe6
Updating Helm Docs
Mar 1, 2021
1267e81
Enable Custom CA Cert For Amass
nigthknight Mar 3, 2021
f16c815
Enable Custom CA Cert For git-repo-scanner
nigthknight Mar 3, 2021
25e2ada
Enable Custom CA Cert For gitleaks
nigthknight Mar 3, 2021
7fc13ec
Enable Custom CA Cert For kube-hunter
nigthknight Mar 3, 2021
6515e16
Enable Custom CA Cert For kubeaudit
nigthknight Mar 3, 2021
c4252f9
Enable Custom CA Cert For ncrack
nigthknight Mar 3, 2021
b27ec4b
Enable Custom CA Cert For nikto
nigthknight Mar 3, 2021
78f8f42
Enable Custom CA Cert For screenshooter
nigthknight Mar 3, 2021
dfcac0a
Enable Custom CA Cert For ssh-scan
nigthknight Mar 3, 2021
cc60bff
Enable Custom CA Cert For sslyze
nigthknight Mar 3, 2021
0405737
Enable Custom CA Cert For test-scan
nigthknight Mar 3, 2021
9e840a9
Enable Custom CA Cert For trivy
nigthknight Mar 3, 2021
a994032
Enable Custom CA Cert For wpscan
nigthknight Mar 3, 2021
738d6ce
Enable Custom CA Cert For zap
nigthknight Mar 3, 2021
991a964
Merge branch 'feature/custom-ca-cert' of github.com:secureCodeBox/sec…
nigthknight Mar 3, 2021
3e91a77
Disable TLS for Minio
nigthknight Mar 3, 2021
074df39
Updating Helm Docs
Mar 3, 2021
7fc063d
Update Amass version to `3.11.3`
nigthknight Mar 3, 2021
a841900
Rename var to comply with standard
nigthknight Mar 3, 2021
78911f4
Fix Description for image.tag
nigthknight Mar 3, 2021
b776794
Updating Helm Docs
Mar 3, 2021
4f80f96
Disable Custom CA Cert for Operator and Lurcher
nigthknight Mar 3, 2021
b86e0ed
Updating Helm Docs
Mar 3, 2021
b8edf67
Disable TLS For Minio By Default
nigthknight Mar 3, 2021
0d9838e
Updating Helm Docs
Mar 3, 2021
0dbceb5
Fix Syntax For Ncrack Template
nigthknight Mar 3, 2021
fb5d47d
Change operator config to only have one customCACertificate config
J12934 Mar 4, 2021
214ac12
Change lurcher cert injection code to use unified cert config var
J12934 Mar 4, 2021
a2d6792
Inject global custom ca mount into parser
J12934 Mar 4, 2021
dca5bf8
Inject CA certs automatically into hooks
J12934 Mar 4, 2021
481a953
Updating Helm Docs
J12934 Mar 4, 2021
8afe818
Merge branch 'main' into feature/custom-ca-cert
J12934 Mar 4, 2021
09fc0f2
Remove ca injection from parser helm values
J12934 Mar 4, 2021
24d8043
Remove ca injection from hook helm values
J12934 Mar 4, 2021
bd054fc
Regenerate helm-docs
J12934 Mar 4, 2021
872d1ef
Disable custom certs by default again
J12934 Mar 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ helm install securecodebox-operator secureCodeBox/operator

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| customCACertificate | object | `{"certificate":"public.crt","existingCertificate":null}` | Setup for Custom CA certificates. These are automatically mounted into every secureCodeBox component (lurcher, parser & hooks). Requires that every namespace has a configmap with the CA certificate(s) |
| customCACertificate.certificate | string | `"public.crt"` | key in the configmap holding the certificate(s) |
| customCACertificate.existingCertificate | string | `nil` | name of the configMap holding the ca certificate(s), needs to be the same across all namespaces |
| image.pullPolicy | string | `"Always"` | Image pull policy |
| image.repository | string | `"docker.io/securecodebox/operator"` | The operator image repository |
| image.tag | string | defaults to the charts version | Parser image tag |
8000 Expand All @@ -29,8 +32,10 @@ helm install securecodebox-operator secureCodeBox/operator
| lurcher.image.tag | string | defaults to the charts version | Parser image tag |
| minio.defaultBucket.enabled | bool | `true` | |
| minio.defaultBucket.name | string | `"securecodebox"` | |
| minio.enabled | bool | `true` | |
| minio.enabled | bool | `true` | Enable this to use minio as storage backend instead of a cloud bucket provider like AWS S3, Google Cloud Storage, DigitalOcean Spaces etc. |
| minio.resources.requests.memory | string | `"256Mi"` | |
| minio.tls.certSecret | string | `"minio-tls"` | |
| minio.tls.enabled | bool | `false` | |
| podSecurityContext | object | `{}` | Sets the securityContext on the operators pod level. See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container |
| resources | object | `{"limits":{"cpu":"100m","memory":"30Mi"},"requests":{"cpu":"100m","memory":"20Mi"}}` | CPU/memory resource requests/limits (see: https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/, https://kubernetes.io/docs/tasks/configure-pod-container/assign-cpu-resource/) |
| s3.authType | string | `"access-secret-key"` | Authentication method. Supports access-secret-key (used by most s3 endpoint) and aws-irsa (Used by AWS EKS IAM Role to Kubenetes Service Account Binding. Support for AWS IRSA is considered experimental in the secureCodeBox) |
Expand Down
4 changes: 4 additions & 0 deletions operator/controllers/execution/scans/hook_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ func (r *ScanReconciler) createJobForHook(hook *executionv1.ScanCompletionHook,
},
},
}

r.Log.V(8).Info("Configuring customCACerts for Hook")
injectCustomCACertsIfConfigured(job)

if err := ctrl.SetControllerReference(scan, job, r.Scheme); err != nil {
r.Log.Error(err, "Unable to set controllerReference on job", "job", job)
return "", err
Expand Down
42 changes: 42 additions & 0 deletions operator/controllers/execution/scans/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ package scancontrollers

import (
"context"
"fmt"
"os"

executionv1 "github.com/secureCodeBox/secureCodeBox/operator/apis/execution/v1"
batch "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -64,3 +67,42 @@ func (r *ScanReconciler) checkIfJobIsCompleted(scan *executionv1.Scan, labels cl

return checkIfAllJobsCompleted(jobs), nil
}

// injectCustomCACertsIfConfigured injects CA Certificates to /etc/ssl/certs/
// currently only supports jobs with a single container
func injectCustomCACertsIfConfigured(job *batch.Job) {
customCACertificate, isConfigured := os.LookupEnv("CUSTOM_CA_CERTIFICATE_EXISTING_CERTIFICATE")
if !isConfigured {
return
}

job.Spec.Template.Spec.Volumes = append(job.Spec.Template.Spec.Volumes, corev1.Volume{
Name: "ca-certificate",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: customCACertificate,
},
},
},
})

certificateName, hasCertificateName := os.LookupEnv("CUSTOM_CA_CERTIFICATE_NAME")
if !hasCertificateName {
panic("Missing CUSTOM_CA_CERTIFICATE_NAME config parameter. Do you have `customCACertificate.certificate` configured you helm values?")
}
mountPath := fmt.Sprintf("/etc/ssl/certs/%s", certificateName)

job.Spec.Template.Spec.Containers[0].VolumeMounts = append(job.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{
Name: "ca-certificate",
ReadOnly: true,
MountPath: mountPath,
SubPath: certificateName,
})

// Add env var for node.js to load the custom ca certs
job.Spec.Template.Spec.Containers[0].Env = append(job.Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{
Name: "NODE_EXTRA_CA_CERTS",
Value: mountPath,
})
}
3 changes: 3 additions & 0 deletions operator/controllers/execution/scans/parse_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
parseDefinition.Spec.Volumes...,
)

r.Log.V(8).Info("Configuring customCACerts for Parser")
injectCustomCACertsIfConfigured(job)

if err := ctrl.SetControllerReference(scan, job, r.Scheme); err != nil {
return err
}
Expand Down
23 changes: 23 additions & 0 deletions operator/controllers/execution/scans/scan_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,29 @@ func (r *ScanReconciler) constructJobForScan(scan *executionv1.Scan, scanType *e
},
}

customCACertificate, isConfigured := os.LookupEnv("CUSTOM_CA_CERTIFICATE_EXISTING_CERTIFICATE")
r.Log.Info("Configuring customCACerts for lurcher", "customCACertificate", customCACertificate, "isConfigured", isConfigured)
if customCACertificate != "" {
job.Spec.Template.Spec.Volumes = append(job.Spec.Template.Spec.Volumes, corev1.Volume{
Name: "ca-certificate",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: customCACertificate,
},
},
},
})

certificateName := os.Getenv("CUSTOM_CA_CERTIFICATE_NAME")
lurcherSidecar.VolumeMounts = append(lurcherSidecar.VolumeMounts, corev1.VolumeMount{
Name: "ca-certificate",
ReadOnly: true,
MountPath: "/etc/ssl/certs/" + certificateName,
SubPath: certificateName,
})
}

job.Spec.Template.Spec.Containers = append(job.Spec.Template.Spec.Containers, *lurcherSidecar)

if err := ctrl.SetControllerReference(scan, job, r.Scheme); err != nil {
Expand Down
20 changes: 19 additions & 1 deletion operator/templates/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ spec:
labels:
control-plane: securecodebox-controller-manager
spec:
{{- if .Values.customCACertificate.existingCertificate }}
volumes:
- name: ca-certificate
configMap:
name: {{ .Values.customCACertificate.existingCertificate }}
{{- end }}
serviceAccountName: {{ .Values.serviceAccount.name }}
securityContext:
{{ .Values.podSecurityContext | toYaml | nindent 8 }}
Expand All @@ -24,6 +30,12 @@ spec:
args:
- --enable-leader-election
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.Version }}"
{{- if .Values.customCACertificate.existingCertificate }}
volumeMounts:
- name: ca-certificate
mountPath: /etc/ssl/certs/{{ .Values.customCACertificate.certificate }}
subPath: {{ .Values.customCACertificate.certificate }}
{{- end }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
name: manager
env:
Expand All @@ -34,7 +46,7 @@ spec:
# TODO: integrate with cert manager and auto gen a cert for minio
{{- if .Values.minio.enabled }}
- name: S3_USE_SSL
value: 'false'
value: "{{ .Values.minio.tls.enabled }}"
- name: S3_ENDPOINT
value: "{{ .Release.Name }}-minio.{{ .Release.Namespace }}.svc.cluster.local"
- name: S3_PORT
Expand Down Expand Up @@ -86,6 +98,12 @@ spec:
value: "{{ .Values.lurcher.image.repository }}:{{ .Values.lurcher.image.tag | default .Chart.Version }}"
- name: LURCHER_PULL_POLICY
value: {{ .Values.lurcher.image.pullPolicy }}
{{- if .Values.customCACertificate.existingCertificate }}
- name: CUSTOM_CA_CERTIFICATE_EXISTING_CERTIFICATE
value: {{ .Values.customCACertificate.existingCertificate | quote }}
- name: CUSTOM_CA_CERTIFICATE_NAME
value: {{ .Values.customCACertificate.certificate | quote }}
{{ end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
securityContext:
Expand Down
12 changes: 11 additions & 1 deletion operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ image:
# image.pullPolicy -- Image pull policy
pullPolicy: Always

# -- Setup for Custom CA certificates. These are automatically mounted into every secureCodeBox component (lurcher, parser & hooks).
# Requires that every namespace has a configmap with the CA certificate(s)
customCACertificate:
# -- name of the configMap holding the ca certificate(s), needs to be the same across all namespaces
existingCertificate: null
# -- key in the configmap holding the certificate(s)
certificate: "public.crt"

serviceAccount:
# -- Name of the serviceAccount the operator uses to talk to the k8s api
Expand Down Expand Up @@ -52,8 +59,11 @@ lurcher:
pullPolicy: Always

minio:
# minio.enabled Enable this to use minio as storage backend instead of a cloud bucket provider like AWS S3, Google Cloud Storage, DigitalOcean Spaces etc.
# -- Enable this to use minio as storage backend instead of a cloud bucket provider like AWS S3, Google Cloud Storage, DigitalOcean Spaces etc.
enabled: true
tls:
enabled: false
certSecret: minio-tls
defaultBucket:
enabled: true
name: "securecodebox"
Expand Down
4 changes: 2 additions & 2 deletions scanners/amass/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ description: A Helm chart for the Amass security scanner that integrates with th
type: application
# version - gets automatically set to the secureCodeBox release version when the helm charts gets published
version: v2.5.0-alpha1
# Latest Amass release version can be found here: https://github.com/OWASP/Amass/releases
appVersion: "v3.10.5"
# Latest Amass release version can be found here: https://github.com/OWASP/Amass/releases
appVersion: "v3.11.3"
kubeVersion: ">=v1.11.0-0"

keywords:
Expand Down
2 changes: 1 addition & 1 deletion scanners/gitleaks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ For more information on how to use cascades take a look at
| Key | Type | Default | Description |
|-----|------|---------|-------------|
| image.repository | string | `"docker.io/securecodebox/scanner-gitleaks"` | Container Image to run the scan |
| image.tag | string | `nil` | defaults to the charts version |
| image.tag | string | `nil` | defaults to the app version |
| parseJob.ttlSecondsAfterFinished | string | `nil` | seconds after which the kubernetes job for the parser will be deleted. Requires the Kubernetes TTLAfterFinished controller: https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/ |
| parserImage.repository | string | `"docker.io/securecodebox/parser-gitleaks"` | Parser image repository |
| parserImage.tag | string | defaults to the charts version | Parser image tag |
Expand Down
2 changes: 1 addition & 1 deletion scanners/gitleaks/values.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image:
# image.repository -- Container Image to run the scan
repository: docker.io/securecodebox/scanner-gitleaks
# image.tag -- defaults to the charts version
# image.tag -- defaults to the app version
tag: null

parserImage:
Expand Down
0