github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/dashboard/app/batch_db_export.go (about) 1 // Copyright 2024 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package main 5 6 import ( 7 "net/http" 8 9 "cloud.google.com/go/batch/apiv1/batchpb" 10 "google.golang.org/appengine/v2/log" 11 ) 12 13 const exportTimeoutSeconds = 60 * 60 * 6 14 15 func handleBatchDBExport(w http.ResponseWriter, r *http.Request) { 16 ctx := r.Context() 17 for ns, nsConfig := range getConfig(ctx).Namespaces { 18 if nsConfig.ReproExportPath == "" { 19 continue 20 } 21 serviceAccount := &batchpb.ServiceAccount{ 22 Scopes: []string{"https://www.googleapis.com/auth/userinfo.email"}, 23 } 24 if err := createScriptJob(ctx, "syzkaller", "db-export", 25 exportDBScript(ns, nsConfig.ReproExportPath), exportTimeoutSeconds, serviceAccount); err != nil { 26 log.Errorf(ctx, "createScriptJob: %s", err.Error()) 27 } 28 } 29 } 30 31 func exportDBScript(srcNamespace, archivePath string) string { 32 return "\n" + 33 "git clone -q --depth 1 --branch master --single-branch https://github.com/google/syzkaller\n" + 34 "cd syzkaller\n" + 35 "token=$(gcloud auth print-access-token)\n" + 36 "CI=1 ./tools/syz-env \"" + // CI=1 to suppress "The input device is not a TTY". 37 "go run ./tools/syz-db-export/... -namespace " + srcNamespace + " -output export -token $token -j 10 && " + 38 "tar -czf export.tar.gz ./export/ && " + 39 "gsutil -q -m cp export.tar.gz " + archivePath + 40 "\"" 41 }