aboutsummaryrefslogtreecommitdiffstats
path: root/syz-cluster/tools
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-07-07 17:30:42 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-07-08 13:37:33 +0000
commit5aaeec43d491523efc62ea7c6e325a2333f85ccd (patch)
treef45f1118f4eac1351e7e021cd7f358edbbd25b7e /syz-cluster/tools
parent1d59f809b4c9163463e5bd6055d71202025f590b (diff)
syz-cluster: add a send-test-email tool
The tool will be used to test email reporter configuration.
Diffstat (limited to 'syz-cluster/tools')
-rw-r--r--syz-cluster/tools/send-test-email/Dockerfile27
-rw-r--r--syz-cluster/tools/send-test-email/job.yaml31
-rw-r--r--syz-cluster/tools/send-test-email/main.go32
3 files changed, 90 insertions, 0 deletions
diff --git a/syz-cluster/tools/send-test-email/Dockerfile b/syz-cluster/tools/send-test-email/Dockerfile
new file mode 100644
index 000000000..e29aa2e41
--- /dev/null
+++ b/syz-cluster/tools/send-test-email/Dockerfile
@@ -0,0 +1,27 @@
+FROM golang:1.23-alpine AS builder
+
+WORKDIR /build
+
+# Prepare the dependencies.
+COPY go.mod ./
+COPY go.sum ./
+RUN go mod download
+COPY dashboard/dashapi/ dashboard/dashapi/
+COPY pkg/gcs/ pkg/gcs/
+COPY pkg/gce/ pkg/gce/
+COPY pkg/email/ pkg/email/
+COPY pkg/auth/ pkg/auth/
+
+# Build the tool.
+COPY syz-cluster/tools/send-test-email/*.go syz-cluster/tools/send-test-email/
+COPY dashboard/dashapi/ dashboard/dashapi/
+COPY syz-cluster/pkg/ syz-cluster/pkg/
+RUN go build -o /bin/send-email /build/syz-cluster/tools/send-test-email
+
+# Create the actual container.
+FROM alpine:latest
+WORKDIR /app
+
+COPY --from=builder /bin/send-email /bin/send-email
+
+ENTRYPOINT ["/bin/send-email"]
diff --git a/syz-cluster/tools/send-test-email/job.yaml b/syz-cluster/tools/send-test-email/job.yaml
new file mode 100644
index 000000000..7dbe5a4b3
--- /dev/null
+++ b/syz-cluster/tools/send-test-email/job.yaml
@@ -0,0 +1,31 @@
+# Copyright 2025 syzkaller project authors. All rights reserved.
+# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+apiVersion: batch/v1
+kind: Job
+metadata:
+ generateName: send-test-email-
+spec:
+ ttlSecondsAfterFinished: 86400
+ backoffLimit: 0
+ template:
+ metadata:
+ labels:
+ app: send-test-email
+ spec:
+ serviceAccountName: gke-email-reporter-ksa
+ containers:
+ - name: send-test-email
+ image: ${IMAGE_PREFIX}send-test-email:${IMAGE_TAG}
+ imagePullPolicy: IfNotPresent
+ volumeMounts:
+ - name: config-volume
+ mountPath: /config
+ envFrom:
+ - configMapRef:
+ name: global-config-env
+ volumes:
+ - name: config-volume
+ configMap:
+ name: global-config
+ restartPolicy: Never
diff --git a/syz-cluster/tools/send-test-email/main.go b/syz-cluster/tools/send-test-email/main.go
new file mode 100644
index 000000000..9c489636a
--- /dev/null
+++ b/syz-cluster/tools/send-test-email/main.go
@@ -0,0 +1,32 @@
+// Copyright 2025 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+package main
+
+import (
+ "context"
+
+ "github.com/google/syzkaller/syz-cluster/pkg/app"
+ "github.com/google/syzkaller/syz-cluster/pkg/emailclient"
+)
+
+func main() {
+ ctx := context.Background()
+ cfg, err := app.Config()
+ if err != nil {
+ app.Fatalf("failed to load config: %v", err)
+ }
+ emailConfig := cfg.EmailReporting
+ if emailConfig == nil {
+ app.Fatalf("reporting is not configured: %v", err)
+ }
+ sender, err := emailclient.MakeSender(ctx, emailConfig)
+ if err != nil {
+ app.Fatalf("failed to create a sender: %s", err)
+ }
+ sender(ctx, &emailclient.Email{
+ Subject: "test email subject",
+ To: []string{emailConfig.ModerationList},
+ Body: []byte("an test email sent from syz-cluster"),
+ })
+}