aboutsummaryrefslogtreecommitdiffstats
path: root/tools/syz-kcidb/kcidb.go
blob: c03d4c1f3cad10be429cab61c747c9f808cf4acf (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
// 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"
	"os"

	"github.com/google/syzkaller/dashboard/dashapi"
	"github.com/google/syzkaller/pkg/kcidb"
	"github.com/google/syzkaller/pkg/tool"
)

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")
	)
	flag.Parse()

	dash, err := dashapi.New(*flagDashClient, *flagDashAddr, *flagDashKey)
	if err != nil {
		tool.Fail(err)
	}
	bug, err := dash.LoadBug(*flagBug)
	if err != nil {
		tool.Fail(err)
	}

	cred, err := os.ReadFile(*flagCred)
	if err != nil {
		tool.Fail(err)
	}
	kcidb.Validate = true
	client, err := kcidb.NewClient(context.Background(), origin, projectID, topicName, cred)
	if err != nil {
		tool.Fail(err)
	}
	defer client.Close()

	if err := client.Publish(bug); err != nil {
		tool.Fail(err)
	}
}