From b14118bbe9ad644f8e16279255fed61d399b96fa Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Fri, 25 Jul 2025 12:54:53 +0200 Subject: syz-cluster: allow finding resubmission Permit the following scenario: a finding is first submitted without a C reproducer and then resubmitted again, now with one. Ensure that it's only possible as long as the session is still in progress. Refactor Finding repository and service and adjust the tests. --- syz-cluster/pkg/controller/api_test.go | 41 ++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'syz-cluster/pkg/controller') diff --git a/syz-cluster/pkg/controller/api_test.go b/syz-cluster/pkg/controller/api_test.go index 1c1c8de9f..e64f3bc78 100644 --- a/syz-cluster/pkg/controller/api_test.go +++ b/syz-cluster/pkg/controller/api_test.go @@ -10,7 +10,9 @@ import ( "github.com/google/syzkaller/syz-cluster/pkg/api" "github.com/google/syzkaller/syz-cluster/pkg/app" + "github.com/google/syzkaller/syz-cluster/pkg/db" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestAPIGetSeries(t *testing.T) { @@ -70,17 +72,52 @@ func TestAPISaveFinding(t *testing.T) { finding := &api.NewFinding{ SessionID: ids.SessionID, TestName: "test", + Title: "title", Report: []byte("report"), Log: []byte("log"), SyzRepro: []byte("syz repro"), SyzReproOpts: []byte("syz_repro_opts"), - CRepro: []byte("C repro"), } err = client.UploadFinding(ctx, finding) assert.NoError(t, err) - // Even if the finding is reported the second time, it must still not fail. + // Even if the same finding is reported the second time, it must still not fail. + err = client.UploadFinding(ctx, finding) + assert.NoError(t, err) + }) + + t.Run("add C repro", func(t *testing.T) { + finding := &api.NewFinding{ + SessionID: ids.SessionID, + TestName: "test", + Title: "title", + Report: []byte("report"), + Log: []byte("log"), + SyzRepro: []byte("syz repro"), + SyzReproOpts: []byte("syz_repro_opts"), + CRepro: []byte("C repro"), + } err = client.UploadFinding(ctx, finding) assert.NoError(t, err) + // Verify that C repro has appeared indeed. + findingRepo := db.NewFindingRepository(env.Spanner) + findings, err := findingRepo.ListForSession(ctx, ids.SessionID, db.NoLimit) + require.NoError(t, err) + require.Len(t, findings, 1) + assert.NotEmpty(t, findings[0].CReproURI) + }) + + t.Run("session stopped", func(t *testing.T) { + MarkSessionFinished(t, env, ids.SessionID) + finding := &api.NewFinding{ + SessionID: ids.SessionID, + TestName: "test", + Title: "new title", + Report: []byte("report"), + Log: []byte("log"), + SyzRepro: []byte("syz repro"), + } + err = client.UploadFinding(ctx, finding) + assert.ErrorContains(t, err, "session is already finished") }) } -- cgit mrf-deployment