Skip to content

Commit

Permalink
Merge pull request #1 from asteurer/main
Browse files Browse the repository at this point in the history
renaming some things
  • Loading branch information
asteurer authored Aug 18, 2024
2 parents 6040bc1 + bb7eb34 commit 8d28364
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 40 deletions.
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM golang

COPY main.go go.mod go.sum ./

RUN go mod download && \
go build -o main main.go

ENTRYPOINT [ "./main" ]
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.PHONY: build push exec_db install uninstall
# Builds the docker image of the database client and tags it
build:
docker build . -f app.Dockerfile -t ghcr.io/kube-hack/sql-injection
docker build . -t ghcr.io/kube-hack/sql-injection

# Pushes the docker image to a container registry
push:
docker push ghcr.io/kube-hack/sql-injection

# Execs user into the database to test SQL commands
exec_db:
kubectl exec -it $$(kubectl get pods | awk '/postgres-db/ {print $$1}') -- psql -U postgres
kubectl exec -it $$(kubectl get pods | awk '/db-sql-injection/ {print $$1}') -- psql -U postgres

# Installs the helm chart
install:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ helm install sql-injection kube-hack/sql-injection
### Port-forward the application

```sh
kubectl port-forward svc/postgres-client 3000:3000
kubectl port-forward svc/client-sql-injection 3000:3000
```

After the application is port-forwarded (accessible via localhost), you can run the below actions:
Expand Down
13 changes: 0 additions & 13 deletions app.Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v2
name: sql-injection
description: A chart that installs a PostgreSQL database with a database client has SQL injection vulnerabilities.
description: A chart that deploys a PostgreSQL database with a database client that has SQL injection vulnerabilities.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
version: 0.2.0
16 changes: 8 additions & 8 deletions chart/templates/client.yaml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-client
name: client-sql-injection
spec:
replicas: 1
selector:
matchLabels:
app: postgres-client
app: client-sql-injection
template:
metadata:
labels:
app: postgres-client
app: client-sql-injection
spec:
containers:
- name: postgres-client
- name: client-sql-injection
image: ghcr.io/kube-hack/sql-injection:latest
imagePullPolicy: Always
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: postgres-secret
name: creds-db-sql-injection

---

apiVersion: v1
kind: Service
metadata:
name: postgres-client
name: client-sql-injection
labels:
app: postgres-client
app: client-sql-injection
spec:
type: ClusterIP
ports:
- port: 3000
targetPort: 8080
selector:
app: postgres-client
app: client-sql-injection
24 changes: 12 additions & 12 deletions chart/templates/postgres.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-secret
name: creds-db-sql-injection
labels:
app: postgres
app: creds-db-sql-injection
data:
POSTGRES_USER: "{{ .Values.postgres.user }}"
POSTGRES_PASSWORD: "{{ .Values.postgres.password }}"
Expand All @@ -14,7 +14,7 @@ data:
apiVersion: v1
kind: ConfigMap
metadata:
name: postgres-sql-schema
name: schema-db-sql-injection
data:
schema.sql: {{ .Files.Get "files/schema.sql" | indent 4 }}

Expand All @@ -23,26 +23,26 @@ data:
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-db
name: db-sql-injection
spec:
replicas: 1
selector:
matchLabels:
app: postgres-db
app: db-sql-injection
template:
metadata:
labels:
app: postgres-db
app: db-sql-injection
spec:
containers:
- name: postgres-db
- name: db-sql-injection
image: postgres
imagePullPolicy: Always
ports:
- containerPort: 5432
envFrom:
- configMapRef:
name: postgres-secret
name: creds-db-sql-injection
volumeMounts:
- mountPath: /docker-entrypoint-initdb.d/
name: schema-volume
Expand All @@ -56,20 +56,20 @@ spec:
volumes:
- name: schema-volume
configMap:
name: postgres-sql-schema
name: schema-db-sql-injection

---

apiVersion: v1
kind: Service
metadata:
name: postgres-db
name: db-sql-injection
labels:
app: postgres-db
app: db-sql-injection
spec:
type: ClusterIP
ports:
- port: 5432
targetPort: 5432
selector:
app: postgres-db
app: db-sql-injection
2 changes: 1 addition & 1 deletion chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ postgres:
user: postgres
database: postgres
password: postgres
host: postgres-db.default.svc.cluster.local:5432
host: db-sql-injection.default.svc.cluster.local:5432
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/asteurer/kh-sql-injection
module sql-injection

go 1.22.4

Expand Down

0 comments on commit 8d28364

Please sign in to comment.