aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-kcidb
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-09-29 15:34:54 +0200
committerDmitry Vyukov <dvyukov@google.com>2020-09-30 18:19:39 +0200
commit6dfc77ac6a384fb2cb310edb98695e4c9eed3191 (patch)
tree905fed074e7b33f00ad9a345076ff3384c449bce /tools/syz-kcidb
parentdf5aa83a3e774266970237ad2885ac19de50a663 (diff)
tools/syz-kcidb: add tool
A wrapper for pkg/kcidb that allows to publish a single bug to Kcidb. Just for testing. Update #2144
Diffstat (limited to 'tools/syz-kcidb')
-rw-r--r--tools/syz-kcidb/kcidb.go55
1 files changed, 55 insertions, 0 deletions
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)
+ }
+}