forked from google/syzkaller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbatch_db_export.go
41 lines (35 loc) · 1.38 KB
/
batch_db_export.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright 2024 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 (
"net/http"
"cloud.google.com/go/batch/apiv1/batchpb"
"google.golang.org/appengine/v2/log"
)
const exportTimeoutSeconds = 60 * 60 * 6
func handleBatchDBExport(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
for ns, nsConfig := range getConfig(ctx).Namespaces {
if nsConfig.ReproExportPath == "" {
continue
}
serviceAccount := &batchpb.ServiceAccount{
Scopes: []string{"https://www.googleapis.com/auth/userinfo.email"},
}
if err := createScriptJob(ctx, "syzkaller", "db-export",
exportDBScript(ns, nsConfig.ReproExportPath), exportTimeoutSeconds, serviceAccount); err != nil {
log.Errorf(ctx, "createScriptJob: %s", err.Error())
}
}
}
func exportDBScript(srcNamespace, archivePath string) string {
return "\n" +
"git clone -q --depth 1 --branch master --single-branch https://github.com/google/syzkaller\n" +
"cd syzkaller\n" +
"token=$(gcloud auth print-access-token)\n" +
"CI=1 ./tools/syz-env \"" + // CI=1 to suppress "The input device is not a TTY".
"go run ./tools/syz-db-export/... -namespace " + srcNamespace + " -output export -token $token -j 10 && " +
"tar -czf export.tar.gz ./export/ && " +
"gsutil -q -m cp export.tar.gz " + archivePath +
"\""
}