diff options
| author | Denys Fedoryshchenko <denys.f@collabora.com> | 2025-09-30 11:45:15 +0300 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-10-06 08:29:13 +0000 |
| commit | 91305dbed501aca571ad5dbf0f1f1d7847966052 (patch) | |
| tree | 3b18f1dd3b3c4a4c12173b88293457f73009d349 /pkg | |
| parent | fd070483688b68ab7c0fef4bfbf2cdc2defd5f63 (diff) | |
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 <denys.f@collabora.com>
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/kcidb/client.go | 18 |
1 files changed, 18 insertions, 0 deletions
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 { |
