diff --git a/internal/pkg/cppdependencyscanner/depsscannerclient/depsscannerclient.go b/internal/pkg/cppdependencyscanner/depsscannerclient/depsscannerclient.go index 9d94d578..22d8defe 100644 --- a/internal/pkg/cppdependencyscanner/depsscannerclient/depsscannerclient.go +++ b/internal/pkg/cppdependencyscanner/depsscannerclient/depsscannerclient.go @@ -193,12 +193,13 @@ func New(ctx context.Context, executor executor, cacheDir string, cacheFileMaxMb } // buildAddress generates an address for the depsscanner process to listen on. -// If reproxy is on UNIX and using a UDS address then it will append .despscan.sock -// to that address. Otherwise a random TCP port will be chosen. +// If reproxy is on UNIX and using a UDS address then it will prepend _ds to +// the sock file name. Otherwise a random TCP port will be chosen. func buildAddress(proxyServerAddress string, openPortFunc func() (int, error)) (string, error) { address := proxyServerAddress if ipc.GrpcCxxSupportsUDS && strings.HasPrefix(address, "unix://") { - return address + ".despscan.sock", nil + dir, sockFile := filepath.Split(address[len("unix://"):]) + return fmt.Sprintf("unix://%s", filepath.Join(dir, "ds_"+sockFile)), nil } if strings.HasPrefix(address, "unix://") || strings.HasPrefix(address, "pipe://") { address = fmt.Sprintf("%s:0", localhost) diff --git a/internal/pkg/cppdependencyscanner/depsscannerclient/depsscannerclient_test.go b/internal/pkg/cppdependencyscanner/depsscannerclient/depsscannerclient_test.go index c9415143..8698ef39 100644 --- a/internal/pkg/cppdependencyscanner/depsscannerclient/depsscannerclient_test.go +++ b/internal/pkg/cppdependencyscanner/depsscannerclient/depsscannerclient_test.go @@ -701,11 +701,32 @@ func TestBuildAddress(t *testing.T) { wantAddr string }{ { - name: "UnixSocketOnUnix", + name: "UnixSocketAbsOnUnix", platforms: []string{"linux", "darwin"}, - serverAddr: "unix://some/dir/somesocket.sock", + serverAddr: "unix:///some/dir/somesocket.sock", + openPortFunc: func() (int, error) { return 111, nil }, + wantAddr: "unix:///some/dir/ds_somesocket.sock", + }, + { + name: "UnixSocketAbsNoDirsOnUnix", + platforms: []string{"linux", "darwin"}, + serverAddr: "unix:///somesocket.sock", + openPortFunc: func() (int, error) { return 111, nil }, + wantAddr: "unix:///ds_somesocket.sock", + }, + { + name: "UnixSocketRelNoDirsOnUnix", + platforms: []string{"linux", "darwin"}, + serverAddr: "unix://somesocket.sock", + openPortFunc: func() (int, error) { return 111, nil }, + wantAddr: "unix://ds_somesocket.sock", + }, + { + name: "UnixSocketRelOnUnix", + platforms: []string{"linux", "darwin"}, + serverAddr: "unix://a/b/somesocket.sock", openPortFunc: func() (int, error) { return 111, nil }, - wantAddr: "unix://some/dir/somesocket.sock.despscan.sock", + wantAddr: "unix://a/b/ds_somesocket.sock", }, { name: "UnixSocketOnWindows",