aboutsummaryrefslogtreecommitdiffstats
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
parent1d59f809b4c9163463e5bd6055d71202025f590b (diff)
syz-cluster: add a send-test-email tool
The tool will be used to test email reporter configuration.
-rw-r--r--syz-cluster/Makefile6
-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
4 files changed, 95 insertions, 1 deletions
diff --git a/syz-cluster/Makefile b/syz-cluster/Makefile
index 0a1461a78..09714d1e4 100644
--- a/syz-cluster/Makefile
+++ b/syz-cluster/Makefile
@@ -29,8 +29,9 @@ $(eval $(call build_image_rules,./workflow/build-step,build-step))
$(eval $(call build_image_rules,./workflow/fuzz-step,fuzz-step))
$(eval $(call build_image_rules,./workflow/boot-step,boot-step))
$(eval $(call build_image_rules,./tools/db-mgmt,db-mgmt))
+$(eval $(call build_image_rules,./tools/send-test-email,send-test-email))
-IMAGES := controller web-dashboard reporter-server series-tracker db-mgmt triage-step build-step boot-step fuzz-step
+IMAGES := controller web-dashboard reporter-server series-tracker db-mgmt triage-step build-step boot-step fuzz-step send-test-email
BUILD_TARGETS := $(addprefix build-, $(IMAGES))
PUSH_TARGETS := $(addprefix push-, $(IMAGES))
@@ -100,6 +101,9 @@ k8s-config-gke: ensure-spanner-database-uri-env ensure-blob-storage-env ensure-w
migrate-job.yaml:
@cat tools/db-mgmt/migrate-job.yaml | sed $(SED_EXPRESSIONS)
+send-test-email-job.yaml:
+ @cat tools/send-test-email/job.yaml | sed $(SED_EXPRESSIONS)
+
fetch-kernels-once.yaml:
@cat kernel-disk/fetch-kernels-once.yaml
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"),
+ })
+}