aboutsummaryrefslogtreecommitdiffstats
path: root/syz-cluster/pkg
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-05-05 17:07:03 +0200
committerTaras Madan <tarasmadan@google.com>2025-05-09 08:56:10 +0000
commit807b3db2ee615b6c4ab080661c9a02d61d148c3e (patch)
tree808e79bdc7c46ffacf9466a1d6a5eeeeda1df45b /syz-cluster/pkg
parent657668289ca385e77c6c79aab94c57e627a714be (diff)
syz-cluster: extend EmailConfig
Move the configuration from pkg/report to pkg/app and extend it with more information.
Diffstat (limited to 'syz-cluster/pkg')
-rw-r--r--syz-cluster/pkg/app/config.go56
-rw-r--r--syz-cluster/pkg/report/email.go11
-rw-r--r--syz-cluster/pkg/report/email_test.go3
3 files changed, 61 insertions, 9 deletions
diff --git a/syz-cluster/pkg/app/config.go b/syz-cluster/pkg/app/config.go
index b56d32dbd..72230c2c8 100644
--- a/syz-cluster/pkg/app/config.go
+++ b/syz-cluster/pkg/app/config.go
@@ -5,6 +5,7 @@ package app
import (
"fmt"
+ "net/mail"
"os"
"sync"
@@ -16,6 +17,23 @@ type AppConfig struct {
ParallelWorkflows int `yaml:"parallelWorkflows"`
// What Lore archives are to be polled for new patch series.
LoreArchives []string `yaml:"loreArchives"`
+ // Parameters used for sending/generating emails.
+ EmailReporting *EmailConfig `yaml:"emailReporting"`
+}
+
+type EmailConfig struct {
+ // The public name of the system.
+ Name string `yaml:"name"`
+ // Link to the public documentation.
+ DocsLink string `yaml:"docs"`
+ // Contact email.
+ SupportEmail string `yaml:"supportEmail"`
+ // The email from which to send the reports.
+ Sender string `yaml:"sender"`
+ // Moderation requests will be sent there.
+ ModerationList string `yaml:"moderationList"`
+ // The list we listen on.
+ ArchiveList string `yaml:"archiveList"`
}
// The project configuration is expected to be mounted at /config/config.yaml.
@@ -57,5 +75,43 @@ func (c AppConfig) Validate() error {
if c.ParallelWorkflows < 0 {
return fmt.Errorf("parallelWorkflows must be non-negative")
}
+ if c.EmailReporting != nil {
+ if err := c.EmailReporting.Validate(); err != nil {
+ return fmt.Errorf("emailReporting: %w", err)
+ }
+ }
+ return nil
+}
+
+func (c EmailConfig) Validate() error {
+ for _, err := range []error{
+ ensureNonEmpty("name", c.Name),
+ ensureEmail("supportEmail", c.SupportEmail),
+ ensureEmail("sender", c.Sender),
+ ensureEmail("moderationList", c.ModerationList),
+ ensureEmail("archiveList", c.ArchiveList),
+ } {
+ if err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
+func ensureNonEmpty(name, val string) error {
+ if val == "" {
+ return fmt.Errorf("%v must not be empty", name)
+ }
+ return nil
+}
+
+func ensureEmail(name, val string) error {
+ if err := ensureNonEmpty(name, val); err != nil {
+ return err
+ }
+ _, err := mail.ParseAddress(val)
+ if err != nil {
+ return fmt.Errorf("%v contains invalid email address", name)
+ }
return nil
}
diff --git a/syz-cluster/pkg/report/email.go b/syz-cluster/pkg/report/email.go
index 8317d46a6..c00a770b6 100644
--- a/syz-cluster/pkg/report/email.go
+++ b/syz-cluster/pkg/report/email.go
@@ -9,25 +9,20 @@ import (
"html/template"
"github.com/google/syzkaller/syz-cluster/pkg/api"
+ "github.com/google/syzkaller/syz-cluster/pkg/app"
)
-type Config struct {
- Name string
- DocsLink string
- SupportEmail string
-}
-
//go:embed template.txt
var templateFS embed.FS
-func Render(rep *api.SessionReport, config *Config) ([]byte, error) {
+func Render(rep *api.SessionReport, config *app.EmailConfig) ([]byte, error) {
tmpl, err := template.ParseFS(templateFS, "template.txt")
if err != nil {
return nil, err
}
data := struct {
Report *api.SessionReport
- Config *Config
+ Config *app.EmailConfig
}{
Report: rep,
Config: config,
diff --git a/syz-cluster/pkg/report/email_test.go b/syz-cluster/pkg/report/email_test.go
index 5f33fbfda..ff5c13398 100644
--- a/syz-cluster/pkg/report/email_test.go
+++ b/syz-cluster/pkg/report/email_test.go
@@ -12,13 +12,14 @@ import (
"testing"
"github.com/google/syzkaller/syz-cluster/pkg/api"
+ "github.com/google/syzkaller/syz-cluster/pkg/app"
"github.com/stretchr/testify/assert"
)
var flagWrite = flag.Bool("write", false, "overwrite out.txt files")
func TestRender(t *testing.T) {
- config := &Config{
+ config := &app.EmailConfig{
Name: "syzbot",
DocsLink: "http://docs/link",
SupportEmail: "support@email.com",