From 6dfc77ac6a384fb2cb310edb98695e4c9eed3191 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 29 Sep 2020 15:34:54 +0200 Subject: tools/syz-kcidb: add tool A wrapper for pkg/kcidb that allows to publish a single bug to Kcidb. Just for testing. Update #2144 --- tools/syz-kcidb/kcidb.go | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tools/syz-kcidb/kcidb.go diff --git a/tools/syz-kcidb/kcidb.go b/tools/syz-kcidb/kcidb.go new file mode 100644 index 000000000..fbc42c409 --- /dev/null +++ b/tools/syz-kcidb/kcidb.go @@ -0,0 +1,55 @@ +// Copyright 2020 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" + "flag" + "fmt" + "io/ioutil" + "os" + + "github.com/google/syzkaller/dashboard/dashapi" + "github.com/google/syzkaller/pkg/kcidb" +) + +func main() { + const ( + origin = "syzkcidb" + projectID = "kernelci-production" + topicName = "playground_kernelci_new" + ) + var ( + flagCred = flag.String("cred", "", "application credentials file for KCIDB") + flagDashClient = flag.String("client", "", "dashboard client") + flagDashAddr = flag.String("addr", "", "dashboard address") + flagDashKey = flag.String("key", "", "dashboard API key") + flagBug = flag.String("bug", "", "bug ID to upload to KCIDB") + ) + failf := func(msg string, args ...interface{}) { + fmt.Fprintf(os.Stderr, msg+"\n", args...) + os.Exit(1) + } + flag.Parse() + + dashboard := dashapi.New(*flagDashClient, *flagDashAddr, *flagDashKey) + bug, err := dashboard.LoadBug(*flagBug) + if err != nil { + failf("%v", err) + } + + cred, err := ioutil.ReadFile(*flagCred) + if err != nil { + failf("%v", err) + } + client, err := kcidb.NewClient(context.Background(), origin, projectID, topicName, cred) + if err != nil { + failf("%v", err) + } + defer client.Close() + + if err := client.Publish(bug); err != nil { + failf("%v", err) + } +} -- cgit mrf-deployment