From 91305dbed501aca571ad5dbf0f1f1d7847966052 Mon Sep 17 00:00:00 2001 From: Denys Fedoryshchenko Date: Tue, 30 Sep 2025 11:45:15 +0300 Subject: tools/syz-kcidb: add -input and -output flags for testing Add -input and -output flags to syz-kcidb to allow for faster and easier testing of KCIDB submissions. With these flags, it's possible to use a local JSON file as input for a bug report and to save the resulting KCIDB submission locally. This removes the need for communication with the dashboard and KCIDB, which simplifies testing and development. Signed-off-by: Denys Fedoryshchenko --- pkg/kcidb/client.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'pkg') diff --git a/pkg/kcidb/client.go b/pkg/kcidb/client.go index bba811c7e..091cbbefb 100644 --- a/pkg/kcidb/client.go +++ b/pkg/kcidb/client.go @@ -84,6 +84,24 @@ func (c *Client) Publish(bug *dashapi.BugReport) error { return err } +func (c *Client) PublishToFile(bug *dashapi.BugReport, filename string) error { + target := targets.List[bug.OS][bug.VMArch] + if target == nil { + return fmt.Errorf("unsupported OS/arch %v/%v", bug.OS, bug.VMArch) + } + data, err := json.MarshalIndent(c.convert(target, bug), "", " ") + if err != nil { + return fmt.Errorf("failed to marshal kcidb json: %w", err) + } + if err := kcidbValidate(data); err != nil { + return err + } + if err := os.WriteFile(filename, data, 0644); err != nil { + return fmt.Errorf("failed to write kcidb json to file: %w", err) + } + return nil +} + var Validate bool func kcidbValidate(data []byte) error { -- cgit mrf-deployment