diff --git a/helm/Chart.yaml b/helm/Chart.yaml new file mode 100644 index 00000000..e35070de --- /dev/null +++ b/helm/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: nuclei +description: A Helm chart for Nuclei +type: application +version: 0.1.0 +appVersion: "2.5.7" diff --git a/helm/templates/NOTES.txt b/helm/templates/NOTES.txt new file mode 100644 index 00000000..1f1b27d0 --- /dev/null +++ b/helm/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.interactsh.ingress.enabled }} +{{- range $host := .Values.interactsh.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.interactsh.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.interactsh.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "nuclei.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.interactsh.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "nuclei.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "nuclei.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.interactsh.service.port }} +{{- else if contains "ClusterIP" .Values.interactsh.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "nuclei.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT +{{- end }} diff --git a/helm/templates/_helpers.tpl b/helm/templates/_helpers.tpl new file mode 100644 index 00000000..3289ba1d --- /dev/null +++ b/helm/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "nuclei.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "nuclei.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "nuclei.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "nuclei.labels" -}} +helm.sh/chart: {{ include "nuclei.chart" . }} +{{ include "nuclei.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "nuclei.selectorLabels" -}} +app.kubernetes.io/name: {{ include "nuclei.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "nuclei.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "nuclei.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/helm/templates/hpa.yaml b/helm/templates/hpa.yaml new file mode 100644 index 00000000..1fbc1801 --- /dev/null +++ b/helm/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "nuclei.fullname" . }} + labels: + {{- include "nuclei.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "nuclei.fullname" . }}-interactsh + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/helm/templates/interactsh-deployment.yaml b/helm/templates/interactsh-deployment.yaml new file mode 100644 index 00000000..63b33978 --- /dev/null +++ b/helm/templates/interactsh-deployment.yaml @@ -0,0 +1,62 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "nuclei.fullname" . }}-interactsh + labels: + {{- include "nuclei.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "nuclei.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "nuclei.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "nuclei.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }}-interactsh + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.interactsh.image.repository }}:{{ .Values.interactsh.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.interactsh.image.pullPolicy }} + command: ["interactsh-server", "-skip-acme", "-d", "{{ .Values.interactsh.service.name }}"] + ports: + - name: http + containerPort: 80 + protocol: TCP + livenessProbe: + httpGet: + path: / + port: http + readinessProbe: + httpGet: + path: / + port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/helm/templates/interactsh-ingress.yaml b/helm/templates/interactsh-ingress.yaml new file mode 100644 index 00000000..d76b6cc5 --- /dev/null +++ b/helm/templates/interactsh-ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.interactsh.ingress.enabled -}} +{{- $fullName := include "nuclei.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.interactsh.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.interactsh.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.interactsh.ingress.annotations "kubernetes.io/ingress.class" .Values.interactsh.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "nuclei.labels" . | nindent 4 }} + {{- with .Values.interactsh.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.interactsh.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.interactsh.ingress.className }} + {{- end }} + {{- if .Values.interactsh.ingress.tls }} + tls: + {{- range .Values.interactsh.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.interactsh.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/helm/templates/interactsh-service.yaml b/helm/templates/interactsh-service.yaml new file mode 100644 index 00000000..f19088ec --- /dev/null +++ b/helm/templates/interactsh-service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ .Values.interactsh.service.name }} + labels: + {{- include "nuclei.labels" . | nindent 4 }} +spec: + type: {{ .Values.interactsh.service.type }} + ports: + - port: {{ .Values.interactsh.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "nuclei.selectorLabels" . | nindent 4 }} diff --git a/helm/templates/nuclei-configmap.yaml b/helm/templates/nuclei-configmap.yaml new file mode 100644 index 00000000..6657f4da --- /dev/null +++ b/helm/templates/nuclei-configmap.yaml @@ -0,0 +1,17 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: nuclei-conf +data: + nuclei.conf: |- +{{ .Values.nuclei.config | indent 4 }} + +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: nuclei-target-list +data: + target-list.txt: |- +{{ .Values.nuclei.target_list | indent 4 }} diff --git a/helm/templates/nuclei-cron.yaml b/helm/templates/nuclei-cron.yaml new file mode 100644 index 00000000..16f3d84b --- /dev/null +++ b/helm/templates/nuclei-cron.yaml @@ -0,0 +1,32 @@ +{{- if .Values.nuclei.enabled -}} +apiVersion: batch/v1 +kind: CronJob +metadata: + name: {{ .Chart.Name }}-nuclei-cron +spec: + schedule: "{{ .Values.nuclei.cron }}" + jobTemplate: + spec: + template: + spec: + containers: + - name: {{ .Chart.Name }}-nuclei-cron + image: "{{ .Values.nuclei.image.repository }}:{{ .Values.nuclei.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.nuclei.image.pullPolicy }} + command: [ "nuclei", "-config", "/config/nuclei.conf" ] + volumeMounts: + - name: nuclei-conf + mountPath: /config/nuclei.conf + subPath: nuclei.conf + - name: nuclei-target-list + mountPath: /config/target-list.txt + subPath: target-list.txt + restartPolicy: OnFailure + volumes: + - name: nuclei-conf + configMap: + name: nuclei-conf + - name: nuclei-target-list + configMap: + name: nuclei-target-list +{{- end }} diff --git a/helm/templates/serviceaccount.yaml b/helm/templates/serviceaccount.yaml new file mode 100644 index 00000000..1751e111 --- /dev/null +++ b/helm/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "nuclei.serviceAccountName" . }} + labels: + {{- include "nuclei.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/helm/values.yaml b/helm/values.yaml new file mode 100644 index 00000000..26a49fc8 --- /dev/null +++ b/helm/values.yaml @@ -0,0 +1,121 @@ +# Default values for nuclei. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +nuclei: + enabled: true + image: + repository: docker.io/projectdiscovery/nuclei + pullPolicy: IfNotPresent + tag: "v2.7.5" + + imagePullSecrets: [] + nameOverride: "" + fullnameOverride: "" + cron: "0 0 * * Sun" + + config: | + interactsh-server: http://nuclei-interactsh # should match the name of interactsh.service.name + list: /config/target-list.txt + # Headers to include with all HTTP request + #header: + # - 'X-BugBounty-Hacker: h1/geekboy' + + # Directory based template execution + #templates: + # - cves/ + # - vulnerabilities/ + # - misconfiguration/ + + # Tags based template execution + #tags: exposures,cve + + # Template Filters + #tags: exposures,cve + #author: geeknik,pikpikcu,dhiyaneshdk + #severity: critical,high,medium + + # Template Allowlist + #include-tags: dos,fuzz # Tag based inclusion (allows overwriting nuclei-ignore list) + #include-templates: # Template based inclusion (allows overwriting nuclei-ignore list) + #- vulnerabilities/xxx + #- misconfiguration/xxxx + + # Template Denylist + #exclude-tags: info # Tag based exclusion + #exclude-templates: # Template based exclusion + #- vulnerabilities/xxx + #- misconfiguration/xxxx + + # Rate Limit configuration + #rate-limit: 500 + #bulk-size: 50 + #concurrency: 50 + + target_list: | + https://10.50.50.2 + +interactsh: + image: + repository: docker.io/projectdiscovery/interactsh-server + pullPolicy: IfNotPresent + tag: "v1.0.6" + + service: + name: "nuclei-interactsh" + type: ClusterIP + port: 80 + + ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +serviceAccount: + create: true + annotations: {} + name: "" + +podAnnotations: {} + +podSecurityContext: {} + +securityContext: {} + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {}