Skip to content

Commit d32a188

Browse files
committed
Add tinyfilemanager chart
1 parent b395741 commit d32a188

11 files changed

Lines changed: 419 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Contribution guide
2+
3+
## Validate on a test cluster
4+
5+
Create the chart configuration file:
6+
7+
```bash
8+
# example for an Instruqt track, with a Traefik ingress controller, with cert-manager and Let's Encrypt
9+
cat > values.mine.yaml << 'EOF'
10+
ingress:
11+
enabled: true
12+
className: "traefik"
13+
annotations:
14+
cert-manager.io/cluster-issuer: "letsencrypt-prod"
15+
tls:
16+
enabled: true
17+
EOF
18+
```
19+
20+
Install the chart:
21+
22+
```bash
23+
helm upgrade --install tinyfilemanager . -f values.yaml -f values.mine.yaml \
24+
--set ingress.domain=tinyfilemanager.server.$SANDBOX_ID.instruqt.io \
25+
--namespace tinyfilemanager --create-namespace
26+
```
27+
28+
Wait for all pods to be ready:
29+
30+
```bash
31+
kubectl get all -n tinyfilemanager
32+
```
33+
34+
Open the web application in a browser.
35+
36+
```bash
37+
echo "https://tinyfilemanager.server.${SANDBOX_ID}.instruqt.io"
38+
```

charts/tinyfilemanager/Chart.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: v2
2+
name: tinyfilemanager
3+
description: Tiny File Manager - intentionally vulnerable by default for security workshops
4+
type: application
5+
version: 1.0.0
6+
appVersion: "2.4.6"
7+
keywords:
8+
- security
9+
- vulnerable
10+
- workshop
11+
- owasp
12+
maintainers:
13+
- name: devpro
14+
email: bertrand@devpro.fr

charts/tinyfilemanager/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Tiny File Manager Helm Chart
2+
3+
Helm chart for [Tiny File Manager](https://tinyfilemanager.github.io/) — designed for container security workshops.
4+
5+
## Quick Start
6+
7+
Add the chart repository:
8+
9+
```bash
10+
helm repo add devpro https://devpro.github.io/helm-charts
11+
helm repo update
12+
```
13+
14+
Create the `values.yaml` file to override [default values](values.yaml).
15+
16+
Install the chart:
17+
18+
```bash
19+
helm upgrade --install tinyfilemanager devpro/nextportal -f values.yaml --namespace tinyfilemanager --create-namespace
20+
```
21+
22+
## Uninstall
23+
24+
```bash
25+
helm uninstall tinyfilemanager -n tinyfilemanager
26+
kubectl delete namespace tinyfilemanager
27+
```
28+
29+
## Going further
30+
31+
Check the [contribution guide](CONTRIBUTING.md).
32+
33+
---
34+
> ⚠️ **FOR WORKSHOP USE ONLY** — intentionally vulnerable, never expose to the internet.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
1. Tiny File Manager web application has been deployed.
2+
3+
{{- if .Values.ingress.enabled }}
4+
URL: https://{{ .Values.ingress.domain }}
5+
6+
TLS certificate will be issued automatically by cert-manager.
7+
Watch progress with:
8+
kubectl get certificate -n {{ .Release.Namespace }}
9+
kubectl describe certificaterequest -n {{ .Release.Namespace }}
10+
{{- else }}
11+
Port-forward to access locally:
12+
kubectl port-forward svc/{{ include "tinyfilemanager.fullname" . }} 3000:3000 -n {{ .Release.Namespace }}
13+
then open http://localhost:3000
14+
{{- end }}
15+
16+
2. Check pod status:
17+
kubectl get pods -n {{ .Release.Namespace }} -l app.kubernetes.io/name={{ include "tinyfilemanager.name" . }}
18+
19+
3. View logs:
20+
kubectl logs -n {{ .Release.Namespace }} -l app.kubernetes.io/name={{ include "tinyfilemanager.name" . }} -f
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "tinyfilemanager.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
*/}}
11+
{{- define "tinyfilemanager.fullname" -}}
12+
{{- if .Values.fullnameOverride }}
13+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
14+
{{- else }}
15+
{{- $name := default .Chart.Name .Values.nameOverride }}
16+
{{- if contains $name .Release.Name }}
17+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
18+
{{- else }}
19+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
20+
{{- end }}
21+
{{- end }}
22+
{{- end }}
23+
24+
{{/*
25+
Chart label.
26+
*/}}
27+
{{- define "tinyfilemanager.chart" -}}
28+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
29+
{{- end }}
30+
31+
{{/*
32+
Common labels.
33+
*/}}
34+
{{- define "tinyfilemanager.labels" -}}
35+
helm.sh/chart: {{ include "tinyfilemanager.chart" . }}
36+
{{ include "tinyfilemanager.selectorLabels" . }}
37+
{{- if .Chart.AppVersion }}
38+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
39+
{{- end }}
40+
app.kubernetes.io/managed-by: {{ .Release.Service }}
41+
{{- end }}
42+
43+
{{/*
44+
Selector labels.
45+
*/}}
46+
{{- define "tinyfilemanager.selectorLabels" -}}
47+
app.kubernetes.io/name: {{ include "tinyfilemanager.name" . }}
48+
app.kubernetes.io/instance: {{ .Release.Name }}
49+
{{- end }}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "tinyfilemanager.fullname" . }}
5+
labels:
6+
{{- include "tinyfilemanager.labels" . | nindent 4 }}
7+
spec:
8+
{{- if not .Values.autoscaling.enabled }}
9+
replicas: {{ .Values.replicaCount }}
10+
{{- end }}
11+
strategy:
12+
type: RollingUpdate
13+
selector:
14+
matchLabels:
15+
{{- include "tinyfilemanager.selectorLabels" . | nindent 6 }}
16+
template:
17+
metadata:
18+
annotations:
19+
# forces a rollout when values change even if the image tag is the same
20+
checksum/config: {{ toYaml .Values.env | sha256sum }}
21+
{{- with .Values.podAnnotations }}
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
labels:
25+
{{- include "tinyfilemanager.selectorLabels" . | nindent 8 }}
26+
spec:
27+
{{- with .Values.imagePullSecrets }}
28+
imagePullSecrets:
29+
{{- toYaml . | nindent 8 }}
30+
{{- end }}
31+
{{- if .Values.podSecurityContext }}
32+
securityContext:
33+
{{- toYaml .Values.podSecurityContext | nindent 8 }}
34+
{{- end }}
35+
containers:
36+
- name: {{ .Chart.Name }}
37+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
38+
imagePullPolicy: {{ .Values.image.pullPolicy }}
39+
{{- if .Values.containerSecurityContext }}
40+
securityContext:
41+
{{- toYaml .Values.containerSecurityContext | nindent 12 }}
42+
{{- end }}
43+
ports:
44+
- name: http
45+
containerPort: 80
46+
protocol: TCP
47+
env:
48+
{{- range $key, $val := .Values.env }}
49+
- name: {{ $key }}
50+
value: {{ $val | quote }}
51+
{{- end }}
52+
{{- with .Values.envFrom }}
53+
envFrom:
54+
{{- toYaml . | nindent 12 }}
55+
{{- end }}
56+
livenessProbe:
57+
{{- toYaml .Values.livenessProbe | nindent 12 }}
58+
readinessProbe:
59+
{{- toYaml .Values.readinessProbe | nindent 12 }}
60+
{{- if .Values.resources }}
61+
resources:
62+
{{- toYaml .Values.resources | nindent 12 }}
63+
{{- end }}
64+
{{- with .Values.nodeSelector }}
65+
nodeSelector:
66+
{{- toYaml . | nindent 8 }}
67+
{{- end }}
68+
{{- with .Values.affinity }}
69+
affinity:
70+
{{- toYaml . | nindent 8 }}
71+
{{- end }}
72+
{{- with .Values.tolerations }}
73+
tolerations:
74+
{{- toYaml . | nindent 8 }}
75+
{{- end }}
76+
restartPolicy: Always
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{{- if .Values.autoscaling.enabled }}
2+
apiVersion: autoscaling/v2
3+
kind: HorizontalPodAutoscaler
4+
metadata:
5+
name: {{ include "tinyfilemanager.fullname" . }}
6+
labels:
7+
{{- include "tinyfilemanager.labels" . | nindent 4 }}
8+
spec:
9+
scaleTargetRef:
10+
apiVersion: apps/v1
11+
kind: Deployment
12+
name: {{ include "tinyfilemanager.fullname" . }}
13+
minReplicas: {{ .Values.autoscaling.minReplicas }}
14+
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
15+
metrics:
16+
- type: Resource
17+
resource:
18+
name: cpu
19+
target:
20+
type: Utilization
21+
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
22+
{{- end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "tinyfilemanager.fullname" . }}
6+
labels:
7+
{{- include "tinyfilemanager.labels" . | nindent 4 }}
8+
{{- with .Values.ingress.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- if .Values.ingress.className }}
14+
ingressClassName: {{ .Values.ingress.className }}
15+
{{- end }}
16+
rules:
17+
- host: {{ .Values.ingress.domain | quote }}
18+
http:
19+
paths:
20+
- path: /
21+
pathType: Prefix
22+
backend:
23+
service:
24+
name: {{ include "tinyfilemanager.fullname" $ }}
25+
port:
26+
name: http
27+
{{- if .Values.ingress.tls.enabled }}
28+
tls:
29+
- secretName: tinyfilemanager-tls
30+
hosts:
31+
- {{ .Values.ingress.domain | quote }}
32+
{{- end }}
33+
{{- end }}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{{- if .Values.networkpolicy.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: NetworkPolicy
4+
metadata:
5+
name: {{ include "tinyfilemanager.fullname" . }}
6+
labels:
7+
{{- include "tinyfilemanager.labels" . | nindent 4 }}
8+
spec:
9+
podSelector:
10+
matchLabels:
11+
{{- include "tinyfilemanager.selectorLabels" . | nindent 6 }}
12+
policyTypes:
13+
- Ingress
14+
- Egress
15+
ingress:
16+
# allow traffic only from the ingress controller namespace
17+
- from:
18+
- namespaceSelector:
19+
matchLabels:
20+
kubernetes.io/metadata.name: kube-system
21+
ports:
22+
- protocol: TCP
23+
port: {{ .Values.service.port }}
24+
egress:
25+
# allows DNS resolution
26+
- ports:
27+
- protocol: UDP
28+
port: 53
29+
- protocol: TCP
30+
port: 53
31+
# allows outbound HTTPS (for Google Fonts CDN)
32+
- ports:
33+
- protocol: TCP
34+
port: 443
35+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "tinyfilemanager.fullname" . }}
5+
labels:
6+
{{- include "tinyfilemanager.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
selector:
10+
{{- include "tinyfilemanager.selectorLabels" . | nindent 4 }}
11+
ports:
12+
- name: http
13+
port: {{ .Values.service.port }}
14+
targetPort: http
15+
protocol: TCP

0 commit comments

Comments
 (0)